merge from upstream/4.0.0.0
This commit is contained in:
parent
bd2ac9b5f4
commit
2b8038b74d
|
@ -87,5 +87,22 @@
|
|||
<source>Unable to verify %1, please enter password.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>UKEY AUTHENTICATION</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>BIOMETRIC AUTHENTICATION IS CLOSED</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>AUTHENTICATION END</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Enter the ukey password
|
||||
</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -4,7 +4,16 @@
|
|||
<context>
|
||||
<name>QObject</name>
|
||||
<message>
|
||||
<location filename="../src/main.cpp" line="100"/>
|
||||
<source>Enter the ukey password</source>
|
||||
<translation>输入ukey密码</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/main.cpp" line="110"/>
|
||||
<source>Enter the ukey password</source>
|
||||
<translation>输入ukey密码\n</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/main.cpp" line="131"/>
|
||||
<source>Try it again</source>
|
||||
<translation>再试一次</translation>
|
||||
</message>
|
||||
|
@ -81,7 +90,12 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/main.cpp" line="249"/>
|
||||
<location filename="../src/main.cpp" line="282"/>
|
||||
<source>UKEY AUTHENTICATION</source>
|
||||
<translation>ukey认证</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/main.cpp" line="284"/>
|
||||
<source>BIOMETRIC AUTHENTICATION</source>
|
||||
<translation>生物识别认证</translation>
|
||||
</message>
|
||||
|
@ -116,7 +130,12 @@
|
|||
<translation>无法验证%1,请输入密码.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/main.cpp" line="302"/>
|
||||
<location filename="../src/main.cpp" line="357"/>
|
||||
<source>AUTHENTICATION END</source>
|
||||
<translation>认证结束</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/main.cpp" line="359"/>
|
||||
<source>BIOMETRIC AUTHENTICATION END</source>
|
||||
<translation>生物识别认证结束</translation>
|
||||
</message>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <QTranslator>
|
||||
#include <QCommandLineOption>
|
||||
#include <QCommandLineParser>
|
||||
#include <termios.h>
|
||||
|
||||
#include <pwd.h>
|
||||
|
||||
|
@ -92,6 +93,39 @@ void showMessage(const QString &message, int type)
|
|||
fprintf(stdout, RESET_COLOR);
|
||||
}
|
||||
|
||||
QString inputPinCode()
|
||||
{
|
||||
struct termios current;
|
||||
struct termios save;
|
||||
tcgetattr(0, &save);
|
||||
|
||||
current = save;
|
||||
// current.c_lflag &= ~ICANON;
|
||||
current.c_lflag &= ~ECHO;
|
||||
current.c_cc[VMIN] = 0;
|
||||
current.c_cc[VTIME] = 0;
|
||||
tcsetattr(0, TCSANOW, ¤t);
|
||||
|
||||
QString password = "";
|
||||
showMessage(QObject::tr("Enter the ukey password"), QUESTION);
|
||||
|
||||
char line[1024] = {0};
|
||||
fgets(line, sizeof(line), stdin);
|
||||
//scanf("%s",&line);
|
||||
|
||||
showMessage("\n", QUESTION);
|
||||
|
||||
line[1023] = '\0';
|
||||
|
||||
if(line[strlen(line) - 1] == '\n')
|
||||
line[strlen(line) - 1] = '\0';
|
||||
|
||||
QString str(line);
|
||||
|
||||
tcsetattr(0, TCSANOW, &save); // 恢复原来的终端属性,以免干扰shall和之后的程序运行
|
||||
return line;
|
||||
}
|
||||
|
||||
Option showOption(bool showSelectDevices)
|
||||
{
|
||||
QStringList optionList;
|
||||
|
@ -247,13 +281,18 @@ int main(int argc, char *argv[])
|
|||
if(bioDevices.getFeatureCount(uid)<1)
|
||||
exit(BIO_ERROR);
|
||||
|
||||
showMessage(QObject::tr("BIOMETRIC AUTHENTICATION"), START);
|
||||
if(!isHiddenSwitchButton)
|
||||
showMessage(QObject::tr("Press Q or Esc to cancel"), PROMPT);
|
||||
if(deviceInfo->biotype == 6){
|
||||
showMessage(QObject::tr("UKEY AUTHENTICATION"), START);
|
||||
}else{
|
||||
showMessage(QObject::tr("BIOMETRIC AUTHENTICATION"), START);
|
||||
if(!isHiddenSwitchButton)
|
||||
showMessage(QObject::tr("Press Q or Esc to cancel"), PROMPT);
|
||||
}
|
||||
|
||||
BioAuth bioAuth(uid, deviceInfo);
|
||||
KeyWatcher watcher;
|
||||
QMap<int,int> m_failedTimes;
|
||||
|
||||
QObject::connect(&bioAuth, &BioAuth::notify, &a, [&](const QString &msg){
|
||||
showMessage(msg, NOTIFY);
|
||||
});
|
||||
|
@ -261,7 +300,11 @@ int main(int argc, char *argv[])
|
|||
Q_UNUSED(retErrNo);
|
||||
watcher.stop();
|
||||
bool isBioEnable = bioDevices.GetBioAuthEnable(uid_);
|
||||
if(!isBioEnable){
|
||||
bool isUkeyDevice = false;
|
||||
if(deviceInfo && deviceInfo->biotype == 6){
|
||||
isUkeyDevice = true;
|
||||
}
|
||||
if(!isBioEnable && !isUkeyDevice){
|
||||
showMessage(QObject::tr("BIOMETRIC AUTHENTICATION IS CLOSED"), RESULT);
|
||||
exit(BIO_IGNORE);
|
||||
}
|
||||
|
@ -271,31 +314,43 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
else {
|
||||
showMessage(QObject::tr("AUTHENTICATION FAILED"), RESULT);
|
||||
|
||||
DeviceInfoPtr curDeviceInfo = bioAuth.getDevice();
|
||||
if (m_failedTimes.contains(deviceInfo->device_id)) {
|
||||
m_failedTimes[deviceInfo->device_id] = m_failedTimes[deviceInfo->device_id] + 1;
|
||||
m_failedTimes[curDeviceInfo->device_id] = m_failedTimes[curDeviceInfo->device_id] + 1;
|
||||
} else {
|
||||
m_failedTimes[deviceInfo->device_id] = 1;
|
||||
m_failedTimes[curDeviceInfo->device_id] = 1;
|
||||
}
|
||||
|
||||
if(m_failedTimes[deviceInfo->device_id]<maxFailedTimes)
|
||||
if(m_failedTimes[curDeviceInfo->device_id]<maxFailedTimes)
|
||||
{
|
||||
showMessage(QObject::tr("Failed to verify %1, you still have %2 verification opportunities").arg(bioDevices.bioTypeToString_tr(deviceInfo->biotype)).arg(maxFailedTimes-m_failedTimes[deviceInfo->device_id]),RESULT);
|
||||
showMessage(QObject::tr("Failed to verify %1, you still have %2 verification opportunities").arg(bioDevices.bioTypeToString_tr(curDeviceInfo->biotype)).arg(maxFailedTimes-m_failedTimes[deviceInfo->device_id]),RESULT);
|
||||
}else{
|
||||
showMessage(QObject::tr("Unable to verify %1, please enter password.").arg(bioDevices.bioTypeToString_tr(deviceInfo->biotype)),RESULT);
|
||||
showMessage(QObject::tr("Unable to verify %1, please enter password.").arg(bioDevices.bioTypeToString_tr(curDeviceInfo->biotype)),RESULT);
|
||||
exit(BIO_IGNORE);
|
||||
}
|
||||
Option option = showOption(bioDevices.count() > 1);
|
||||
switch(option) {
|
||||
case OPTION_TRY_AGAIN:
|
||||
|
||||
if(deviceInfo->biotype == 6){
|
||||
QString code = inputPinCode();
|
||||
bioAuth.SetExtraInfo("pincode",code);
|
||||
}
|
||||
|
||||
bioAuth.startAuth();
|
||||
watcher.start();
|
||||
break;
|
||||
case OPTION_SELECT_DEVICE:
|
||||
{
|
||||
DeviceInfoPtr deviceInfo = std::make_shared<DeviceInfo>();
|
||||
deviceInfo = std::make_shared<DeviceInfo>();
|
||||
*deviceInfo = showDevices(bioDevices.getAllDevices());
|
||||
bioAuth.setDevice(deviceInfo);
|
||||
|
||||
if(deviceInfo->biotype == 6){
|
||||
QString code = inputPinCode();
|
||||
bioAuth.SetExtraInfo("pincode",code);
|
||||
}
|
||||
|
||||
bioAuth.startAuth();
|
||||
watcher.start();
|
||||
break;
|
||||
|
@ -305,8 +360,12 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
exit(BIO_ERROR);
|
||||
}else{
|
||||
showMessage(QObject::tr("BIOMETRIC AUTHENTICATION END"), START);
|
||||
exit(BIO_IGNORE);
|
||||
if(deviceInfo->biotype == 6){
|
||||
showMessage(QObject::tr("AUTHENTICATION END"), START);
|
||||
}else{
|
||||
showMessage(QObject::tr("BIOMETRIC AUTHENTICATION END"), START);
|
||||
}
|
||||
exit(BIO_IGNORE);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -314,6 +373,12 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(deviceInfo->biotype == 6){
|
||||
QString code = inputPinCode();
|
||||
bioAuth.SetExtraInfo("pincode",code);
|
||||
}
|
||||
|
||||
bioAuth.startAuth();
|
||||
|
||||
if(!isHiddenSwitchButton){
|
||||
|
|
|
@ -82,6 +82,10 @@
|
|||
<source>QRCode</source>
|
||||
<translation>ཨང་ཀི་ཕྱག་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ukey</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BioDevicesWidget</name>
|
||||
|
@ -108,5 +112,9 @@
|
|||
<source>Login Options</source>
|
||||
<translation>ཐོ་འགོད་ཀྱི་བསལ་འདེམས་ཀྱི་དབང་ཆ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Password</source>
|
||||
<translation type="unfinished">གསང་ཨང་།</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Password</source>
|
||||
<translation type="vanished">密码</translation>
|
||||
<translation>密码</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Current Device: </source>
|
||||
|
@ -99,7 +99,12 @@
|
|||
<translation>声纹</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/biodevices.cpp" line="467"/>
|
||||
<location filename="../src/biodevices.cpp" line="657"/>
|
||||
<source>ukey</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/biodevices.cpp" line="659"/>
|
||||
<source>QRCode</source>
|
||||
<translation>二维码</translation>
|
||||
</message>
|
||||
|
@ -139,6 +144,11 @@
|
|||
<source>Login Options</source>
|
||||
<translation>登录选项</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/loginoptionswidget.cpp" line="294"/>
|
||||
<source>Password</source>
|
||||
<translation>密码</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Wechat</source>
|
||||
<translation type="vanished">微信</translation>
|
||||
|
|
|
@ -36,11 +36,29 @@ public:
|
|||
explicit BioAuth(QObject *parent = nullptr);
|
||||
~BioAuth();
|
||||
void setDevice(const DeviceInfoPtr deviceInfo);
|
||||
DeviceInfoPtr getDevice();
|
||||
void startAuth();
|
||||
void startUkeyAuth();
|
||||
void startAuth(qint32 uid, const DeviceInfoPtr deviceInfo);
|
||||
void stopAuth();
|
||||
bool isAuthenticating();
|
||||
void init();
|
||||
/**
|
||||
* @brief 设置一些认证时所需的额外的信息
|
||||
* @param info_type 额外的信息类型,ukey pincode认证时传 "pincode"
|
||||
* @param extra_info 额外的信息内容,ukey pincode认证时传PIN码内容
|
||||
* @return 结果:<int result> (设置额外信息的结果)
|
||||
*/
|
||||
int SetExtraInfo(QString info_type, QString extra_info);
|
||||
/**
|
||||
* @brief 获取当前用户已连接设备对应特征数目
|
||||
* @param uid 用户id
|
||||
* @param indexStart 用于认证的特征索引范围
|
||||
* @param indexEnd
|
||||
* @return 返回是否存在ukey特征
|
||||
*/
|
||||
bool GetHasUkeyFeature(int uid, int indexStart = 0, int indexEnd = -1);
|
||||
|
||||
|
||||
signals:
|
||||
void authComplete(int uid, bool result, int retErrNo);
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
QMap<int, QList<DeviceInfo>> getUserDevices(int uid);
|
||||
QList<DeviceInfo> getDevices(int type);
|
||||
DeviceInfoPtr getDefaultDevice(uid_t uid);
|
||||
DeviceInfoPtr getDefaultDevice(uid_t uid,int bioType);
|
||||
int GetLastDevice(const QString &userName);
|
||||
void SetLastDevice(const QString &userName, int drvid);
|
||||
DeviceInfoPtr findDevice(const QString &deviceName);
|
||||
|
|
|
@ -34,6 +34,20 @@
|
|||
#endif
|
||||
#define LOG() qDebug() << "[BIOMETRIC]"
|
||||
|
||||
enum LOGINOPT_TYPE {
|
||||
LOGINOPT_TYPE_PASSWORD = 0, // 密码
|
||||
LOGINOPT_TYPE_FACE, // 人脸
|
||||
LOGINOPT_TYPE_FINGERPRINT, // 指纹
|
||||
LOGINOPT_TYPE_IRIS, // 虹膜
|
||||
LOGINOPT_TYPE_VOICEPRINT, // 声纹
|
||||
LOGINOPT_TYPE_FINGERVEIN, // 指静脉
|
||||
LOGINOPT_TYPE_GENERAL_UKEY, // 普通的ukey
|
||||
LOGINOPT_TYPE_ADVANCED_UKEY, // 高阶的ukey
|
||||
LOGINOPT_TYPE_QRCODE, // 二维码
|
||||
LOGINOPT_TYPE_OTHERS, // 其他
|
||||
LOGINOPT_TYPE_COUNT
|
||||
};
|
||||
|
||||
/* the type of device */
|
||||
enum BioType {
|
||||
BIOTYPE_FINGERPRINT,
|
||||
|
@ -173,6 +187,14 @@ struct StatusReslut
|
|||
int notifyMessageId;
|
||||
};
|
||||
|
||||
struct FeatureInfo {
|
||||
int uid;
|
||||
int biotype;
|
||||
QString device_shortname;
|
||||
int index;
|
||||
QString index_name;
|
||||
};
|
||||
|
||||
/* the info of device */
|
||||
struct DeviceInfo {
|
||||
int device_id;
|
||||
|
@ -207,6 +229,8 @@ typedef QMap<int, DeviceList> DeviceMap;
|
|||
QDBusArgument &operator<<(QDBusArgument &argument, const DeviceInfo &deviceInfo);
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument, DeviceInfo &deviceInfo);
|
||||
QDebug operator <<(QDebug stream, const DeviceInfo &deviceInfo);
|
||||
QDBusArgument &operator<<(QDBusArgument &argument, const FeatureInfo &featureInfo);
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument, FeatureInfo &featureInfo);
|
||||
|
||||
QString bioTypeToString(int type);
|
||||
|
||||
|
|
|
@ -30,17 +30,18 @@ class QVBoxLayout;
|
|||
class QToolButton;
|
||||
class QTimer;
|
||||
|
||||
enum LOGINOPT_TYPE {
|
||||
LOGINOPT_TYPE_PASSWORD = 0, // 密码
|
||||
LOGINOPT_TYPE_FACE, // 人脸
|
||||
LOGINOPT_TYPE_FINGERPRINT, // 指纹
|
||||
LOGINOPT_TYPE_IRIS, // 虹膜
|
||||
LOGINOPT_TYPE_VOICEPRINT, // 声纹
|
||||
LOGINOPT_TYPE_FINGERVEIN, // 指静脉
|
||||
LOGINOPT_TYPE_QRCODE, // 二维码
|
||||
LOGINOPT_TYPE_OTHERS, // 其他
|
||||
LOGINOPT_TYPE_COUNT
|
||||
};
|
||||
typedef enum {
|
||||
BioT_FingerPrint, /** 指纹 **/
|
||||
BioT_FingerVein, /** 指静脉 **/
|
||||
BioT_Iris, /** 虹膜 **/
|
||||
BioT_Face, /** 人脸 **/
|
||||
BioT_VoicePrint, /** 声纹 **/
|
||||
|
||||
UniT_KCM, /** 安全管控 **/
|
||||
UniT_General_Ukey, /** 普通的Ukey **/
|
||||
UniT_Advanced_Ukey, /** 高阶的Ukey **/
|
||||
UniT_Remote, /** 远程账户 **/
|
||||
}Bio_Type;
|
||||
|
||||
class LoginOptionsWidget : public QWidget
|
||||
{
|
||||
|
@ -54,6 +55,7 @@ public:
|
|||
DeviceInfoPtr getFirstDevInfo();
|
||||
int convertDeviceType(int nDevType);
|
||||
void updateUIStatus(bool update);
|
||||
void updateUkeyUIStatus(int type);
|
||||
void setUser(int uid);
|
||||
void setCurrentDevice(int drvid);
|
||||
void setCurrentDevice(const QString &deviceName);
|
||||
|
@ -69,6 +71,7 @@ public:
|
|||
* @return
|
||||
*/
|
||||
QString GetDefaultDevice(uid_t uid);
|
||||
QString GetDefaultDevice(uid_t uid,int bioType);
|
||||
|
||||
/**
|
||||
* @brief 进行生物识别认证
|
||||
|
@ -91,6 +94,9 @@ public:
|
|||
}
|
||||
QPixmap loadSvg(QString path, QString color, int size);
|
||||
|
||||
void SetExtraInfo(QString extra_info,QString info_type);
|
||||
bool getHasUkeyOptions();
|
||||
void setSelectedPassword();
|
||||
public slots:
|
||||
void readDevicesInfo();
|
||||
void onIdentifyComplete(int uid, bool ret, int retErrNo);
|
||||
|
@ -155,6 +161,8 @@ private:
|
|||
bool is_Lock = false;
|
||||
QPixmap m_waitingPixmap;
|
||||
QTimer *w_timer;
|
||||
|
||||
bool isShowUkey = false;
|
||||
};
|
||||
|
||||
#endif // LOGINOPTIONSWIDGET_H
|
||||
|
|
|
@ -60,6 +60,30 @@ void BioAuth::setDevice(const DeviceInfoPtr deviceInfo)
|
|||
this->deviceInfo = deviceInfo;
|
||||
}
|
||||
|
||||
void BioAuth::startUkeyAuth()
|
||||
{
|
||||
// stopAuth();
|
||||
if (!deviceInfo) {
|
||||
qDebug()<<"DeviceInfo not valid!!";
|
||||
return;
|
||||
}
|
||||
|
||||
/* 开始认证识别 */
|
||||
LOG() << "start biometric verification";
|
||||
QList<QVariant> args;
|
||||
args << QVariant(deviceInfo->device_id) << QVariant(2)
|
||||
<< QVariant(uid);
|
||||
isInAuthentication = true;
|
||||
|
||||
QDBusPendingCall call = serviceInterface->asyncCallWithArgumentList("UkeyIdentify", args);
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, this, &BioAuth::onIdentityComplete);
|
||||
}
|
||||
DeviceInfoPtr BioAuth::getDevice()
|
||||
{
|
||||
return this->deviceInfo;
|
||||
}
|
||||
|
||||
void BioAuth::startAuth()
|
||||
{
|
||||
// stopAuth();
|
||||
|
@ -75,9 +99,58 @@ void BioAuth::startAuth()
|
|||
<< QVariant(0) << QVariant(-1);
|
||||
isInAuthentication = true;
|
||||
|
||||
QDBusPendingCall call = serviceInterface->asyncCallWithArgumentList("Identify", args);
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, this, &BioAuth::onIdentityComplete);
|
||||
qDebug()<<args;
|
||||
|
||||
if(deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){
|
||||
QList<QVariant> args1;
|
||||
args1 << QVariant(deviceInfo->device_id) << QVariant(2)
|
||||
<< QVariant(uid);
|
||||
|
||||
QDBusPendingCall call = serviceInterface->asyncCallWithArgumentList("UkeyIdentify", args1);
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, this, &BioAuth::onIdentityComplete);
|
||||
}else{
|
||||
QDBusPendingCall call = serviceInterface->asyncCallWithArgumentList("Identify", args);
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, this, &BioAuth::onIdentityComplete);
|
||||
}
|
||||
}
|
||||
|
||||
bool BioAuth::GetHasUkeyFeature(int uid, int indexStart, int indexEnd)
|
||||
{
|
||||
QList<QDBusVariant> qlist;
|
||||
FeatureInfo *featureInfo;
|
||||
int listsize;
|
||||
QDBusMessage result = serviceInterface->call(QStringLiteral("GetAllFeatureList"),uid,indexStart,indexEnd);
|
||||
if(result.type() == QDBusMessage::ErrorMessage)
|
||||
{
|
||||
qWarning() << "GetDevList error:" << result.errorMessage();
|
||||
return false;
|
||||
}
|
||||
QList<QVariant> variantList = result.arguments();
|
||||
listsize = variantList[0].value<int>();
|
||||
variantList[1].value<QDBusArgument>() >> qlist;
|
||||
for (int i = 0; i < listsize; i++) {
|
||||
featureInfo = new FeatureInfo;
|
||||
qlist[i].variant().value<QDBusArgument>() >> *featureInfo;
|
||||
if(featureInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){
|
||||
delete featureInfo;
|
||||
return true;
|
||||
}
|
||||
delete featureInfo;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int BioAuth::SetExtraInfo(QString info_type,QString extra_info)
|
||||
{
|
||||
QDBusReply<int> reply = serviceInterface->call(QStringLiteral("SetExtraInfo"), info_type, extra_info);
|
||||
if(!reply.isValid())
|
||||
{
|
||||
qWarning() << "SetExtraInfo error:" << reply.error();
|
||||
return -1;
|
||||
}
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
void BioAuth::startAuth(qint32 uid, const DeviceInfoPtr deviceInfo)
|
||||
|
|
|
@ -43,6 +43,7 @@ BioDevices::BioDevices(bool isIgnoreQrCode, QObject *parent)
|
|||
m_listPriority.push_back(BIOTYPE_VOICEPRINT);
|
||||
m_listPriority.push_back(BIOTYPE_FINGERVEIN);
|
||||
m_listPriority.push_back(REMOTE_QRCODE_TYPE);
|
||||
m_listPriority.push_back(LOGINOPT_TYPE_GENERAL_UKEY);
|
||||
}
|
||||
|
||||
void BioDevices::setUId(int nUId)
|
||||
|
@ -70,6 +71,7 @@ void BioDevices::onUSBDeviceHotPlug(int deviceId, int action, int devNumNow)
|
|||
{
|
||||
qDebug() << deviceId << action << devNumNow;
|
||||
QString text = "";
|
||||
|
||||
if(action == -1){
|
||||
DeviceInfoPtr device = findDevice(deviceId);
|
||||
if(device)
|
||||
|
@ -102,6 +104,7 @@ void BioDevices::onUSBDeviceHotPlug(int deviceId, int action, int devNumNow)
|
|||
<<(int)-1;
|
||||
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool BioDevices::GetBioAuthEnable(uid_t uid)
|
||||
|
@ -398,6 +401,72 @@ bool BioDevices::GetBioAuthEnable()
|
|||
}
|
||||
}
|
||||
|
||||
DeviceInfoPtr BioDevices::getDefaultDevice(uid_t uid,int bioType)
|
||||
{
|
||||
if(deviceInfos.size() <= 0)
|
||||
return nullptr;
|
||||
|
||||
if (m_uniAuthService && m_uniAuthService->isActivatable()) {
|
||||
QString defaultDeviceName = "";
|
||||
struct passwd *pwdInfo = getpwuid(uid);
|
||||
DeviceInfoPtr ptrDevInfo = nullptr;
|
||||
if (pwdInfo) {
|
||||
QString strDeviceName = m_uniAuthService->getDefaultDevice(pwdInfo->pw_name, bioType);
|
||||
qDebug()<<strDeviceName;
|
||||
if(!strDeviceName.isEmpty()) {
|
||||
ptrDevInfo = findDevice(strDeviceName);
|
||||
if (ptrDevInfo) {
|
||||
if (GetUserDevFeatureCount(uid,ptrDevInfo->device_id) > 0) {
|
||||
defaultDeviceName = strDeviceName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(defaultDeviceName.isEmpty()){
|
||||
return nullptr;
|
||||
}
|
||||
return ptrDevInfo;
|
||||
} else {
|
||||
QString defaultDeviceName;
|
||||
|
||||
struct passwd *pwd = getpwuid(uid);
|
||||
QString userConfigFile = QString(pwd->pw_dir) + "/.biometric_auth/ukui_biometric.conf";
|
||||
QSettings userConfig(userConfigFile, QSettings::IniFormat);
|
||||
qDebug() << userConfig.fileName();
|
||||
defaultDeviceName = userConfig.value(DEFAULT_DEVICE).toString();
|
||||
qDebug() << defaultDeviceName;
|
||||
|
||||
if(defaultDeviceName.isEmpty() || !findDevice(defaultDeviceName)) {
|
||||
QSettings sysConfig(GET_STR(CONFIG_FILE), QSettings::IniFormat);
|
||||
defaultDeviceName = sysConfig.value(DEFAULT_DEVICE).toString();
|
||||
}
|
||||
|
||||
if(defaultDeviceName.isEmpty() || !findDevice(defaultDeviceName)){
|
||||
QString userConfigFile = QString(pwd->pw_dir) + "/.biometric_auth/ukui_biometric.conf";
|
||||
QSettings userConfig(userConfigFile, QSettings::IniFormat);
|
||||
defaultDeviceName = userConfig.value(DEFAULT_DEVICE).toString();
|
||||
}
|
||||
qDebug() << "default device: " << defaultDeviceName;
|
||||
// 终端不默认使用第一个设备
|
||||
if(defaultDeviceName.isEmpty()){
|
||||
return nullptr;
|
||||
}
|
||||
bool defValid = false;
|
||||
DeviceInfoPtr ptrDevInfo = findDevice(defaultDeviceName);
|
||||
if (ptrDevInfo) {
|
||||
if (GetUserDevFeatureCount(uid,ptrDevInfo->device_id) > 0) {
|
||||
defValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!defValid) {
|
||||
ptrDevInfo = nullptr;
|
||||
}
|
||||
|
||||
return ptrDevInfo;
|
||||
}
|
||||
}
|
||||
|
||||
DeviceInfoPtr BioDevices::getDefaultDevice(uid_t uid)
|
||||
{
|
||||
if(deviceInfos.size() <= 0)
|
||||
|
@ -410,6 +479,7 @@ DeviceInfoPtr BioDevices::getDefaultDevice(uid_t uid)
|
|||
if (pwdInfo) {
|
||||
for (auto bioType : m_listPriority) {
|
||||
QString strDeviceName = m_uniAuthService->getDefaultDevice(pwdInfo->pw_name, bioType);
|
||||
qDebug()<<strDeviceName;
|
||||
if(!strDeviceName.isEmpty()) {
|
||||
ptrDevInfo = findDevice(strDeviceName);
|
||||
if (ptrDevInfo) {
|
||||
|
@ -583,6 +653,8 @@ QString BioDevices::bioTypeToString_tr(int type)
|
|||
return tr("Face");
|
||||
case BIOTYPE_VOICEPRINT:
|
||||
return tr("VoicePrint");
|
||||
case LOGINOPT_TYPE_GENERAL_UKEY:
|
||||
return tr("ukey");
|
||||
case REMOTE_QRCODE_TYPE:
|
||||
return tr("QRCode");
|
||||
}
|
||||
|
|
|
@ -75,6 +75,27 @@ QDebug operator <<(QDebug stream, const DeviceInfo &deviceInfo)
|
|||
return stream;
|
||||
}
|
||||
|
||||
/* For the type FeatureInfo */
|
||||
QDBusArgument &operator<<(QDBusArgument &argument, const FeatureInfo &featureInfo)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument << featureInfo.uid << featureInfo.biotype
|
||||
<< featureInfo.device_shortname << featureInfo.index
|
||||
<< featureInfo.index_name;
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument, FeatureInfo &featureInfo)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument >> featureInfo.uid >> featureInfo.biotype
|
||||
>> featureInfo.device_shortname >> featureInfo.index
|
||||
>> featureInfo.index_name;
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
QString bioTypeToString(int type)
|
||||
{
|
||||
switch(type) {
|
||||
|
@ -86,6 +107,8 @@ QString bioTypeToString(int type)
|
|||
return ("Iris");
|
||||
case BIOTYPE_FACE:
|
||||
return ("Face");
|
||||
case LOGINOPT_TYPE_GENERAL_UKEY:
|
||||
return ("ukey");
|
||||
case BIOTYPE_VOICEPRINT:
|
||||
return ("VoicePrint");
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <QButtonGroup>
|
||||
#include <QToolButton>
|
||||
#include <QSizePolicy>
|
||||
#include <QTimer>
|
||||
#include <QPixmap>
|
||||
#include <QPainter>
|
||||
|
@ -40,6 +41,7 @@
|
|||
#include <QFont>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
LoginOptionsWidget::LoginOptionsWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_biomericProxy(new BioAuth(this))
|
||||
|
@ -72,19 +74,21 @@ void LoginOptionsWidget::initUI()
|
|||
m_layoutImage->setAlignment(Qt::AlignCenter);
|
||||
|
||||
m_labelOptTitle = new QLabel();
|
||||
m_labelOptTitle->setAlignment(Qt::AlignCenter);
|
||||
m_labelOptTitle->setAlignment(Qt::AlignLeft);
|
||||
m_labelOptTitle->setText(tr("Login Options"));
|
||||
m_layoutMain->addWidget(m_labelOptTitle);
|
||||
|
||||
m_btnGroup = new QButtonGroup(this);
|
||||
m_btnGroup->setExclusive(true);
|
||||
|
||||
m_layoutOptBtns->setAlignment(Qt::AlignCenter);
|
||||
m_layoutOptBtns->setAlignment(Qt::AlignLeft);
|
||||
m_layoutMain->addLayout(m_layoutOptBtns);
|
||||
|
||||
m_widgetImage = new QWidget();
|
||||
m_widgetImage->setFixedSize(154,154);
|
||||
m_layoutImage->addSpacerItem(new QSpacerItem(109, 0, QSizePolicy::Expanding));
|
||||
m_layoutImage->addWidget(m_widgetImage);
|
||||
m_layoutImage->addSpacerItem(new QSpacerItem(109, 0, QSizePolicy::Expanding));
|
||||
m_widgetImage->hide();
|
||||
// 人脸识别
|
||||
m_labelFace = new QLabel(m_widgetImage);
|
||||
|
@ -100,6 +104,8 @@ void LoginOptionsWidget::initUI()
|
|||
m_labelFaceLoad->setFixedSize(142, 142);
|
||||
m_labelFaceLoad->setStyleSheet(QString("QLabel{background-color: rgba(230,230,230,0.39); border-radius: %1px; border: 8px solid white;}").arg(71));
|
||||
layoutFace->addWidget(m_labelFaceLoad, 0, Qt::AlignVCenter);
|
||||
|
||||
|
||||
// QImage img;
|
||||
// setFaceImg(img);
|
||||
m_labelFace->hide();
|
||||
|
@ -127,6 +133,21 @@ void LoginOptionsWidget::initUI()
|
|||
layoutQRCode->addWidget(m_labelQRCodeMsg, 0, Qt::AlignHCenter);
|
||||
|
||||
this->setLayout(m_layoutMain);
|
||||
|
||||
//设置水平扩展
|
||||
QSizePolicy sizePolicy = this->sizePolicy();
|
||||
sizePolicy.setHorizontalPolicy(QSizePolicy::Expanding);
|
||||
this->setSizePolicy(sizePolicy);
|
||||
}
|
||||
|
||||
void LoginOptionsWidget::SetExtraInfo(QString extra_info, QString info_type)
|
||||
{
|
||||
if(!m_biomericProxy)
|
||||
{
|
||||
qWarning() << "BiometricProxy doesn't exist.";
|
||||
return;
|
||||
}
|
||||
m_biomericProxy->SetExtraInfo(info_type,extra_info);
|
||||
}
|
||||
|
||||
void LoginOptionsWidget::initConnections()
|
||||
|
@ -205,11 +226,17 @@ DeviceInfoPtr LoginOptionsWidget::getFirstDevInfo()
|
|||
return devInfo;
|
||||
}
|
||||
|
||||
bool LoginOptionsWidget::getHasUkeyOptions()
|
||||
{
|
||||
return isShowUkey;
|
||||
}
|
||||
|
||||
void LoginOptionsWidget::addOptionButton(unsigned uLoginOptType, int nDrvId, QString strDrvName)
|
||||
{
|
||||
if (m_mapOptBtns.contains(nDrvId)) {
|
||||
return ;
|
||||
}
|
||||
|
||||
QToolButton *newButton = new QToolButton();
|
||||
// newButton->setStyleSheet(QString("QToolButton{text-align:center;border: none;border-radius: 6px;outline: none;background-color: rgba(230, 230, 230, 100%);} \
|
||||
// QToolButton::hover{background-color: rgba(55, 144, 250, 40%);} \
|
||||
|
@ -220,19 +247,22 @@ void LoginOptionsWidget::addOptionButton(unsigned uLoginOptType, int nDrvId, QSt
|
|||
newButton->setChecked(false);
|
||||
newButton->setFocusPolicy(Qt::NoFocus);
|
||||
newButton->setContentsMargins(16,16,16,16);
|
||||
if (nDrvId == -1) {
|
||||
newButton->setEnabled(false);
|
||||
newButton->setChecked(true);
|
||||
} else {
|
||||
// if (nDrvId == -1) {
|
||||
// newButton->setEnabled(false);
|
||||
// newButton->setChecked(true);
|
||||
// } else {
|
||||
int nLength = m_btnGroup->buttons().length();
|
||||
m_btnGroup->addButton(newButton, nLength);
|
||||
m_listDriveId.append(nDrvId);
|
||||
}
|
||||
// }
|
||||
QIcon icon;
|
||||
switch (uLoginOptType) {
|
||||
case LOGINOPT_TYPE_PASSWORD:
|
||||
icon = QIcon(QString("%1/images/ukui-loginopt-password.svg").arg(GET_STR(UKUI_BIOMETRIC)));
|
||||
break;
|
||||
case LOGINOPT_TYPE_GENERAL_UKEY:
|
||||
icon = QIcon(QString("%1/images/ukui-loginopt-ukey.svg").arg(GET_STR(UKUI_BIOMETRIC)));
|
||||
break;
|
||||
case LOGINOPT_TYPE_FACE:
|
||||
icon = QIcon(QString("%1/images/ukui-loginopt-face.svg").arg(GET_STR(UKUI_BIOMETRIC)));
|
||||
break;
|
||||
|
@ -281,17 +311,43 @@ void LoginOptionsWidget::clearOptionButtons()
|
|||
|
||||
void LoginOptionsWidget::updateOptionButtons()
|
||||
{
|
||||
isShowUkey = false;
|
||||
clearOptionButtons();
|
||||
//addOptionButton(LOGINOPT_TYPE_PASSWORD, -1, tr("Password"));
|
||||
addOptionButton(LOGINOPT_TYPE_PASSWORD, -1, tr("Password"));
|
||||
DeviceMap::iterator itMapDev = m_mapDevices.begin();
|
||||
for ( ; itMapDev != m_mapDevices.end(); itMapDev++) {
|
||||
for (DeviceInfoPtr devPtr : itMapDev.value()) {
|
||||
if (devPtr) {
|
||||
addOptionButton(itMapDev.key(), devPtr->device_id, BioDevices::bioTypeToString_tr(devPtr->biotype));
|
||||
if(devPtr->biotype == LOGINOPT_TYPE_GENERAL_UKEY){
|
||||
//ukey 设备类型排在二维码前,但实际上应该显示在二维码之后,因此暂时不添加
|
||||
isShowUkey = true;
|
||||
continue;
|
||||
}
|
||||
addOptionButton(itMapDev.key(), devPtr->device_id, BioDevices::bioTypeToString_tr(devPtr->biotype));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
itMapDev = m_mapDevices.begin();
|
||||
if(isShowUkey){
|
||||
for ( ; itMapDev != m_mapDevices.end(); itMapDev++) {
|
||||
for (DeviceInfoPtr devPtr : itMapDev.value()) {
|
||||
if(devPtr && devPtr->biotype == LOGINOPT_TYPE_GENERAL_UKEY){
|
||||
//此处才添加ukey
|
||||
addOptionButton(itMapDev.key(), devPtr->device_id, BioDevices::bioTypeToString_tr(devPtr->biotype));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_mapOptBtns.size() <= 1) {
|
||||
|
||||
//存在特征但没有插入ukey
|
||||
if( !isShowUkey && m_biomericProxy->GetHasUkeyFeature(m_uid)){
|
||||
addOptionButton(LOGINOPT_TYPE_GENERAL_UKEY,-2,BioDevices::bioTypeToString_tr(LOGINOPT_TYPE_GENERAL_UKEY));
|
||||
isShowUkey = true;
|
||||
}
|
||||
|
||||
if (m_mapOptBtns.size() <= 2 && !isShowUkey) {
|
||||
//因为默认添加一个密码选项,因此当ukey没有显示出来时,按钮数小于等于2时就隐藏选项界面
|
||||
m_labelOptTitle->hide();
|
||||
QMap<int, QToolButton*>::iterator itMapBtn = m_mapOptBtns.begin();
|
||||
for ( ; itMapBtn != m_mapOptBtns.end(); itMapBtn++) {
|
||||
|
@ -312,6 +368,12 @@ void LoginOptionsWidget::updateOptionButtons()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_mapOptBtns[-1]->hide();
|
||||
if(m_mapOptBtns.size() == 2 && isShowUkey) {
|
||||
m_mapOptBtns[-1]->show();
|
||||
}
|
||||
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
|
@ -397,6 +459,17 @@ void LoginOptionsWidget::startAuth(DeviceInfoPtr device, int uid)
|
|||
startAuth_();
|
||||
}
|
||||
|
||||
void LoginOptionsWidget::setSelectedPassword()
|
||||
{
|
||||
if (m_mapOptBtns.contains(-1)) {
|
||||
QToolButton* btn = m_mapOptBtns[-1];
|
||||
if (btn && btn->isVisible()) {
|
||||
btn->setChecked(true);
|
||||
}
|
||||
m_curDevInfo = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void LoginOptionsWidget::startAuth_()
|
||||
{
|
||||
if (!m_curDevInfo)
|
||||
|
@ -559,9 +632,13 @@ QPixmap LoginOptionsWidget::scaledPixmap(int width, int height, QString url)
|
|||
|
||||
void LoginOptionsWidget::onFrameWritten(int drvid)
|
||||
{
|
||||
if (m_curDevInfo->device_id != drvid || !m_isInAuth) {
|
||||
if(!m_curDevInfo)
|
||||
return;
|
||||
|
||||
if (m_curDevInfo && m_curDevInfo->device_id != drvid || !m_isInAuth) {
|
||||
return ;
|
||||
}
|
||||
|
||||
if(m_dupFD == -1){
|
||||
m_dupFD = get_server_gvariant_stdout(drvid);
|
||||
}
|
||||
|
@ -737,6 +814,18 @@ DeviceInfoPtr LoginOptionsWidget::findDeviceByName(const QString &name)
|
|||
return DeviceInfoPtr();
|
||||
}
|
||||
|
||||
QString LoginOptionsWidget::GetDefaultDevice(uid_t uid,int bioType)
|
||||
{
|
||||
QString defaultDeviceName = "";
|
||||
DeviceInfoPtr pDeviceInfo = m_bioDevices->getDefaultDevice(uid,bioType);
|
||||
if (pDeviceInfo) {
|
||||
defaultDeviceName = pDeviceInfo->device_shortname;
|
||||
}
|
||||
qDebug() << "default device: " << defaultDeviceName;
|
||||
|
||||
return defaultDeviceName;
|
||||
}
|
||||
|
||||
QString LoginOptionsWidget::GetDefaultDevice(uid_t uid)
|
||||
{
|
||||
QString defaultDeviceName = "";
|
||||
|
@ -761,7 +850,7 @@ void LoginOptionsWidget::onUSBDeviceCountChange(int newNum)
|
|||
int count = 0;
|
||||
for(int type : m_mapDevices.keys())
|
||||
count += m_mapDevices.value(type).count();
|
||||
|
||||
|
||||
//设备数量发生了变化
|
||||
if(count != savedCount) {
|
||||
updateOptionButtons();
|
||||
|
@ -770,11 +859,36 @@ void LoginOptionsWidget::onUSBDeviceCountChange(int newNum)
|
|||
updateUIStatus(false);
|
||||
}
|
||||
|
||||
void LoginOptionsWidget::updateUkeyUIStatus(int type)
|
||||
{
|
||||
if (type == LOGINOPT_TYPE_FACE) {
|
||||
m_labelFace->setStyleSheet(QString("border-radius: %1px; border:0px solid white;background-color: rgba(255,255,255,10%);").arg(77));
|
||||
m_labelFace->show();
|
||||
m_labelQRCode->hide();
|
||||
m_widgetImage->show();
|
||||
} else if (type == LOGINOPT_TYPE_QRCODE) {
|
||||
m_labelQRCode->setStyleSheet(QString("border-radius: %1px; border:0px solid white;background-color: rgba(255,255,255,100%);").arg(6));
|
||||
QImage img;
|
||||
setQRCode(img);
|
||||
m_labelQRCode->show();
|
||||
m_labelFace->hide();
|
||||
m_widgetImage->show();
|
||||
} else {
|
||||
m_labelFace->hide();
|
||||
m_labelQRCode->hide();
|
||||
m_widgetImage->hide();
|
||||
}
|
||||
|
||||
QTimer::singleShot(0,this,[&,this](){
|
||||
Q_EMIT this->updateWndSize(this->m_curLoginOptType, this->m_mapOptBtns.size());
|
||||
});
|
||||
}
|
||||
|
||||
void LoginOptionsWidget::updateUIStatus(bool update)
|
||||
{
|
||||
if (m_mapOptBtns.contains(-1)) {
|
||||
QToolButton* btn = m_mapOptBtns[-1];
|
||||
if (btn) {
|
||||
if (btn && btn->isVisible()) {
|
||||
btn->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
@ -786,6 +900,7 @@ void LoginOptionsWidget::updateUIStatus(bool update)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (update) {
|
||||
if (m_curLoginOptType == LOGINOPT_TYPE_FACE) {
|
||||
m_labelFace->setStyleSheet(QString("border-radius: %1px; border:0px solid white;background-color: rgba(255,255,255,10%);").arg(77));
|
||||
|
@ -818,6 +933,19 @@ void LoginOptionsWidget::onOptionSelected(int nIndex)
|
|||
DeviceInfoPtr info = findDeviceById(m_listDriveId[nIndex]);
|
||||
if (info && !isDeviceDisable(info->device_id)) {
|
||||
Q_EMIT optionSelected(convertDeviceType(info->biotype), info);
|
||||
this->m_curLoginOptType = convertDeviceType(info->biotype);
|
||||
}else if(nIndex == 0 && m_listDriveId[nIndex] == -1){
|
||||
stopAuth();
|
||||
m_curDevInfo = nullptr;
|
||||
Q_EMIT optionSelected(LOGINOPT_TYPE_PASSWORD,nullptr);
|
||||
this->m_curLoginOptType = LOGINOPT_TYPE_PASSWORD;
|
||||
|
||||
}else if(m_listDriveId[nIndex] == -2){
|
||||
//存在ukey特征,但未插入ukey
|
||||
stopAuth();
|
||||
m_curDevInfo = nullptr;
|
||||
Q_EMIT optionSelected(LOGINOPT_TYPE_GENERAL_UKEY,nullptr);
|
||||
this->m_curLoginOptType = LOGINOPT_TYPE_GENERAL_UKEY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -841,6 +969,12 @@ int LoginOptionsWidget::convertDeviceType(int nDevType)
|
|||
case BIOTYPE_VOICEPRINT:
|
||||
nLoginOptType = LOGINOPT_TYPE_VOICEPRINT;
|
||||
break;
|
||||
case UniT_General_Ukey:
|
||||
nLoginOptType = LOGINOPT_TYPE_GENERAL_UKEY;
|
||||
break;
|
||||
case UniT_Advanced_Ukey:
|
||||
nLoginOptType = LOGINOPT_TYPE_ADVANCED_UKEY;
|
||||
break;
|
||||
case REMOTE_QRCODE_TYPE:
|
||||
nLoginOptType = LOGINOPT_TYPE_QRCODE;
|
||||
break;
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
ukui-biometric-auth (4.0.0.0-ok1~0426) yangtze; urgency=medium
|
||||
|
||||
* BUG号:无
|
||||
* 需求号:无
|
||||
* 其他修改说明:合并V101、V101-tablet代码
|
||||
|
||||
-- Yang Min <yangmin@kylinos.cn> Wed, 26 Apr 2023 21:58:51 +0800
|
||||
|
||||
ukui-biometric-auth (3.22.0.0-ok7~0420) yangtze; urgency=medium
|
||||
|
||||
* BUG号:无
|
||||
|
|
|
@ -15,7 +15,8 @@ Build-Depends: cmake (>= 2.6),
|
|||
qtbase5-dev,
|
||||
qttools5-dev,
|
||||
qttools5-dev-tools,
|
||||
libkysdk-sysinfo-dev
|
||||
libkysdk-sysinfo-dev,
|
||||
libukui-log4qt-dev
|
||||
Standards-Version: 4.5.0
|
||||
Rules-Requires-Root: no
|
||||
Homepage: https://github.com/ukui/ukui-biometric-auth
|
||||
|
|
|
@ -1 +1 @@
|
|||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M1.5,6.14a.5.5,0,0,1-.5-.5V4.34A3.35,3.35,0,0,1,4.34,1H5.42a.5.5,0,0,1,0,1H4.34A2.34,2.34,0,0,0,2,4.34v1.3A.5.5,0,0,1,1.5,6.14Z" fill="#262626"/><path d="M5.32,15h-1A3.35,3.35,0,0,1,1,11.66V10.57a.5.5,0,0,1,1,0v1.09A2.34,2.34,0,0,0,4.34,14h1a.5.5,0,0,1,0,1Z" fill="#262626"/><path d="M11.66,15h-1.1a.5.5,0,0,1,0-1h1.1A2.34,2.34,0,0,0,14,11.66v-1a.5.5,0,1,1,1,0v1A3.35,3.35,0,0,1,11.66,15Z" fill="#262626"/><path d="M14.5,5.88a.5.5,0,0,1-.5-.5v-1A2.34,2.34,0,0,0,11.66,2h-1a.5.5,0,0,1,0-1h1A3.35,3.35,0,0,1,15,4.34v1A.5.5,0,0,1,14.5,5.88Z" fill="#262626"/><path d="M5.91,5a.92.92,0,1,0,.92.91A.91.91,0,0,0,5.91,5Z" fill="#1a1a1a"/><path d="M11,5l-.19,0A1,1,0,0,0,11,7l.19,0A1,1,0,0,0,11,5Z" fill="#1a1a1a"/><path d="M5.63,10.65s0,1.35,2,1.35a2.94,2.94,0,0,0,2.71-1.35" fill="none" stroke="#1a1a1a" stroke-linecap="round" stroke-miterlimit="10"/><line x1="8" y1="7.27" x2="8" y2="9" fill="none" stroke="#1a1a1a" stroke-linecap="round" stroke-miterlimit="10"/></svg>
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M1.5,6.14a.5.5,0,0,1-.5-.5V4.34A3.36,3.36,0,0,1,4.34,1H5.42a.5.5,0,0,1,0,1H4.34A2.34,2.34,0,0,0,2,4.34H2v1.3A.5.5,0,0,1,1.5,6.14Z" fill="#262626"/><path d="M5.32,15h-1A3.36,3.36,0,0,1,1,11.66V10.57a.5.5,0,0,1,1,0v1.09A2.34,2.34,0,0,0,4.34,14h1a.5.5,0,0,1,0,1Z" fill="#262626"/><path d="M11.66,15h-1.1a.5.5,0,0,1,0-1h1.1A2.34,2.34,0,0,0,14,11.66h0v-1a.5.5,0,0,1,1,0v1A3.36,3.36,0,0,1,11.66,15Z" fill="#262626"/><path d="M14.5,5.88a.5.5,0,0,1-.5-.5v-1A2.34,2.34,0,0,0,11.7,2h-1a.5.5,0,0,1,0-1h1A3.36,3.36,0,0,1,15,4.34v1a.5.5,0,0,1-.46.54Z" fill="#262626"/><path d="M5.91,5a.92.92,0,1,0,.92.92h0A.91.91,0,0,0,5.92,5Z" fill="#262626"/><path d="M11,5h-.19A1,1,0,0,0,11,7h.19A1,1,0,0,0,11,5Z" fill="#262626"/><path d="M7.86,12.51H7.59c-1.94,0-2.46-1.21-2.46-1.85a.5.5,0,0,1,1,0c0,.1.08.86,1.5.86a2.45,2.45,0,0,0,2.29-1.12.5.5,0,0,1,.84.54A3.42,3.42,0,0,1,7.86,12.51ZM6.13,10.65h0Z" fill="#262626"/><path d="M8,9.5A.5.5,0,0,1,7.5,9V7.27a.5.5,0,0,1,1,0V9A.5.5,0,0,1,8,9.5Z" fill="#262626"/></svg>
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.1 KiB |
|
@ -1 +1 @@
|
|||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M2.35,5.66,2,5.48A.68.68,0,0,0,2.35,5.66Z" fill="#262626"/><path d="M2,10.63l.32-.18A.68.68,0,0,0,2,10.63Z" fill="#262626"/><path d="M13.58,10a.42.42,0,0,1,.42.42v3.16a.42.42,0,0,1-.42.42H8.42A.42.42,0,0,1,8,13.58V10.42A.42.42,0,0,1,8.42,10h5.16m0-1H8.42A1.43,1.43,0,0,0,7,10.42v3.16A1.43,1.43,0,0,0,8.42,15h5.16A1.43,1.43,0,0,0,15,13.58V10.42A1.43,1.43,0,0,0,13.58,9Z"/><path d="M11.85,7a.15.15,0,0,1,.15.15V9H10V7.15A.15.15,0,0,1,10.15,7h1.7m0-1h-1.7A1.16,1.16,0,0,0,9,7.15V10h4V7.15A1.16,1.16,0,0,0,11.85,6Z"/><path d="M2.5,4.42a.54.54,0,0,0-.22,0,.61.61,0,0,0-.41.58A.65.65,0,0,0,2,5.48a.68.68,0,0,0,.32.18l.15,0a.64.64,0,0,0,.63-.64.52.52,0,0,0,0-.11A.62.62,0,0,0,2.5,4.42Z" fill="none"/><path d="M2.5,10.42l-.15,0a.68.68,0,0,0-.32.18.65.65,0,0,0-.16.42.61.61,0,0,0,.41.59.54.54,0,0,0,.22,0,.62.62,0,0,0,.61-.52.5.5,0,0,0,0-.12A.63.63,0,0,0,2.5,10.42Z" fill="none"/><path d="M7.5,2.69A.64.64,0,0,0,8,2.43a.62.62,0,0,0,.13-.38A.62.62,0,0,0,8,1.68a.8.8,0,0,0-.13-.13.59.59,0,0,0-.74,0A.8.8,0,0,0,7,1.68a.62.62,0,0,0-.13.37A.62.62,0,0,0,7,2.43.64.64,0,0,0,7.5,2.69Z" fill="none"/><path d="M8,8V8a2,2,0,0,1,.36-1.14A1.31,1.31,0,0,0,8,6.65a1.3,1.3,0,0,0-1,0,1.47,1.47,0,0,0-.47.27,1.51,1.51,0,0,0-.5.86,1.24,1.24,0,0,0,0,.27,1.27,1.27,0,0,0,0,.28,1.42,1.42,0,0,0,.4.74A2.4,2.4,0,0,1,8,8Z" fill="none"/><path d="M8.13,2.05A.62.62,0,0,0,8,1.68a.8.8,0,0,0-.13-.13.59.59,0,0,0-.74,0A.8.8,0,0,0,7,1.68a.62.62,0,0,0-.13.37A.62.62,0,0,0,7,2.43a.61.61,0,0,0,1,0A.62.62,0,0,0,8.13,2.05Z" fill="none"/><path d="M2.5,4.42a.54.54,0,0,0-.22,0,.61.61,0,0,0-.41.58A.65.65,0,0,0,2,5.48a.68.68,0,0,0,.32.18l.15,0a.64.64,0,0,0,.63-.64.52.52,0,0,0,0-.11A.62.62,0,0,0,2.5,4.42Z" fill="none"/><path d="M2.5,10.42l-.15,0a.68.68,0,0,0-.32.18.65.65,0,0,0-.16.42.61.61,0,0,0,.41.59.54.54,0,0,0,.22,0,.62.62,0,0,0,.61-.52.5.5,0,0,0,0-.12A.63.63,0,0,0,2.5,10.42Z" fill="none"/><path d="M13.12,5.11s0,0,0-.06a.61.61,0,0,0-.41-.58.54.54,0,0,0-.22,0,.65.65,0,0,0-.34.11A1.68,1.68,0,0,1,13.12,5.11Z" fill="none"/><path d="M14,5.05a1.5,1.5,0,0,0-2.89-.55h.74a1.63,1.63,0,0,1,.31,0,.65.65,0,0,1,.34-.11.54.54,0,0,1,.22,0,.61.61,0,0,1,.41.58s0,0,0,.06a1.68,1.68,0,0,1,.38,1h0A1.45,1.45,0,0,0,14,5.05Z" fill="#262626"/><path d="M8.54,5.8A2,2,0,0,0,8,5.61V3.46A1.49,1.49,0,0,0,9,2.05a1.5,1.5,0,1,0-3,0A1.49,1.49,0,0,0,7,3.46V5.61a2.45,2.45,0,0,0-1.36.79L4,5.43a1.58,1.58,0,0,0,0-.38,1.5,1.5,0,1,0-1.5,1.5,1.53,1.53,0,0,0,.89-.29l1.75,1A2.56,2.56,0,0,0,5,8.05a2.57,2.57,0,0,0,.14.79l-1.75,1a1.54,1.54,0,0,0-.89-.3A1.5,1.5,0,1,0,4,11.05a1.57,1.57,0,0,0,0-.37l1.69-1a2.57,2.57,0,0,0,.39.35,2.46,2.46,0,0,1,.4-1A1.42,1.42,0,0,1,6,8.33a1.27,1.27,0,0,1,0-.28,1.24,1.24,0,0,1,0-.27,1.51,1.51,0,0,1,.5-.86A1.47,1.47,0,0,1,7,6.65a1.3,1.3,0,0,1,1,0,1.31,1.31,0,0,1,.36.21c0-.06.1-.1.14-.15V6.15A2,2,0,0,1,8.54,5.8Zm-6-.11-.15,0A.68.68,0,0,1,2,5.48a.65.65,0,0,1-.16-.43.61.61,0,0,1,.41-.58.54.54,0,0,1,.22,0,.62.62,0,0,1,.61.52.52.52,0,0,1,0,.11A.64.64,0,0,1,2.5,5.69Zm.61,5.48a.62.62,0,0,1-.61.52.54.54,0,0,1-.22,0,.61.61,0,0,1-.41-.59A.65.65,0,0,1,2,10.63a.68.68,0,0,1,.32-.18l.15,0a.63.63,0,0,1,.63.63A.5.5,0,0,1,3.11,11.17ZM7.5,2.69A.64.64,0,0,1,7,2.43a.62.62,0,0,1-.13-.38A.62.62,0,0,1,7,1.68a.8.8,0,0,1,.13-.13.59.59,0,0,1,.74,0A.8.8,0,0,1,8,1.68a.62.62,0,0,1,.13.37A.62.62,0,0,1,8,2.43.64.64,0,0,1,7.5,2.69Z" fill="#262626"/></svg>
|
||||
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M4.5,5A2.5,2.5,0,0,1,7,7.14L7,7.5l0,.36A2.49,2.49,0,1,1,4.5,5m0-1A3.5,3.5,0,1,0,8,8h6.58A.47.47,0,0,0,15,7.53V7.47A.47.47,0,0,0,14.53,7H8A3.49,3.49,0,0,0,4.5,4Z" fill="#262626"/><rect x="9" y="7" width="1" height="3" rx="0.5" fill="#262626"/><rect x="12" y="7" width="1" height="3" rx="0.5" fill="#262626"/></svg>
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 417 B |
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{display:none;}
|
||||
.st1{display:inline;fill:#262626;}
|
||||
.st2{display:inline;fill:none;stroke:#262626;stroke-linecap:round;stroke-miterlimit:10;}
|
||||
.st3{fill:#262626;}
|
||||
.st4{fill:none;stroke:#262626;stroke-linecap:round;stroke-miterlimit:10;}
|
||||
</style>
|
||||
<g id="图层_1" class="st0">
|
||||
<path class="st1" d="M5,5.6C5,5.3,5.3,5,5.6,5c0,0,0,0,0,0h5.8C11.7,5,12,5.3,12,5.6v0v7.8c0,0.3-0.3,0.6-0.6,0.6l0,0H5.6
|
||||
C5.3,14,5,13.7,5,13.4V5.6 M4,5.6v7.8C4,14.3,4.7,15,5.6,15h5.8c0.9,0,1.6-0.7,1.6-1.6c0,0,0,0,0,0V5.6C13,4.7,12.3,4,11.4,4
|
||||
c0,0,0,0,0,0H5.6C4.7,4,4,4.7,4,5.6L4,5.6z"/>
|
||||
<path class="st1" d="M7,3h3v1H7V3 M6,3v2h5V3c0-0.6-0.4-1-1-1H7C6.4,2,6,2.4,6,3z"/>
|
||||
<path class="st1" d="M8,6.5v6C8,12.8,8.2,13,8.5,13S9,12.8,9,12.5v-6C9,6.2,8.8,6,8.5,6S8,6.2,8,6.5z"/>
|
||||
<path class="st2" d="M8,10.5L8,10.5c-0.8,0-1.5-0.7-1.5-1.5V8"/>
|
||||
<path class="st2" d="M9,9.5L9,9.5c0.8,0,1.5-0.7,1.5-1.5V7"/>
|
||||
</g>
|
||||
<g id="图层_1_x5F_复制">
|
||||
<path class="st3" d="M3,4.6C3,4.3,3.3,4,3.6,4c0,0,0,0,0,0h7.8C11.7,4,12,4.3,12,4.6v0v8.8c0,0.3-0.3,0.6-0.6,0.6l0,0H3.6
|
||||
C3.3,14,3,13.7,3,13.4V4.6 M2,4.6v8.8C2,14.3,2.7,15,3.6,15h7.8c0.9,0,1.6-0.7,1.6-1.6c0,0,0,0,0,0V4.6C13,3.7,12.3,3,11.4,3
|
||||
c0,0,0,0,0,0H3.6C2.7,3,2,3.7,2,4.6L2,4.6z"/>
|
||||
<path class="st3" d="M5,2h5v1H5V2 M4,2v2h7V2c0-0.6-0.4-1-1-1H5C4.4,1,4,1.4,4,2z"/>
|
||||
<path class="st3" d="M7,6.5v6C7,12.8,7.2,13,7.5,13S8,12.8,8,12.5v-6C8,6.2,7.8,6,7.5,6S7,6.2,7,6.5z"/>
|
||||
<path class="st4" d="M7,10.5L7,10.5c-0.8,0-1.5-0.7-1.5-1.5V8"/>
|
||||
<path class="st4" d="M8,9.5L8,9.5c0.8,0,1.5-0.7,1.5-1.5V7"/>
|
||||
<rect x="7" y="1" class="st3" width="1" height="2"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.9 KiB |
|
@ -29,11 +29,12 @@ set(pam_SRCS
|
|||
include_directories(
|
||||
../common
|
||||
${PAM_INCLUDE_DIR}
|
||||
${GLIB2_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
|
||||
add_library(pam_biometric SHARED ${pam_SRCS})
|
||||
target_link_libraries(pam_biometric ${PAM_LIB})
|
||||
target_link_libraries(pam_biometric ${PAM_LIB} ${GLIB2_LIBRARIES})
|
||||
#去除lib前缀
|
||||
set_target_properties(pam_biometric PROPERTIES PREFIX "")
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include <security/pam_ext.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define USER_CONFIG_FILE "/home/%s/.biometric_auth/ukui_biometric.conf"
|
||||
|
||||
|
@ -86,11 +88,9 @@ int service_filter(char *service)
|
|||
|
||||
//syslog(LOG_INFO,"is_enable = %d service = %s\n",is_enable,service);
|
||||
if (strcmp(service, "lightdm") == 0) {
|
||||
int ret = system("/bin/chmod -f a+wr /tmp/bio.log");
|
||||
(void)ret; /* Suppress gcc ignoring return value warning */
|
||||
//if(is_enable & 1 == 0)
|
||||
// return 0;
|
||||
return 1;
|
||||
// return 0;
|
||||
return 1;
|
||||
}
|
||||
if (strcmp(service, "ukui-screensaver-qt") == 0){
|
||||
//if((is_enable & (1<<1)) == 0)
|
||||
|
@ -163,12 +163,11 @@ int call_conversation(pam_handle_t *pamh, int msg_style, char *msg, char *resp)
|
|||
/* GUI child process */
|
||||
void child(char *service, char *username, char *xdisp)
|
||||
{
|
||||
char *gui = "/usr/bin/bioauth";
|
||||
pam_logger("Child process will be replaced.\n");
|
||||
int fd = open("/dev/null", O_WRONLY);
|
||||
dup2(fd, 2);
|
||||
|
||||
execl(gui, "bioauth",
|
||||
execl("/usr/bin/bioauth", "bioauth",
|
||||
"--service", service,
|
||||
"--user", username,
|
||||
// "--display", xdisp,
|
||||
|
@ -318,15 +317,15 @@ int biometric_auth_independent(pam_handle_t *pamh , char *service, int need_call
|
|||
/* Detach child process */
|
||||
unsigned int pid;
|
||||
pid = fork();
|
||||
if (pid == 0 ) {
|
||||
child(service, username, xdisp);
|
||||
pam_logger("Should never reach here.\n");
|
||||
return PAM_SYSTEM_ERR;
|
||||
} else if (pid > 0) {
|
||||
return parent(pid, pamh, need_call_conv);
|
||||
} else {
|
||||
if (pid < 0) {
|
||||
pam_logger("Fork Error!\n");
|
||||
return PAM_SYSTEM_ERR;
|
||||
return PAM_SYSTEM_ERR;
|
||||
} else if (pid != 0) {
|
||||
return parent(pid, pamh, need_call_conv);
|
||||
} else {
|
||||
child(service, username, xdisp);
|
||||
pam_logger("Should never reach here.\n");
|
||||
return PAM_SYSTEM_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -398,24 +397,82 @@ int biometric_auth_embeded(pam_handle_t *pamh)
|
|||
|
||||
void get_greeter_session(char buf[], int len)
|
||||
{
|
||||
FILE *stream;
|
||||
char cmd[] = "ps -aux | grep greeter-session | grep -v grep | awk '{print $13}' | awk -F '/' '{print $4}'";
|
||||
memset(buf, 0, len);
|
||||
stream = popen(cmd, "r");
|
||||
if(fgets(buf, len, stream) == NULL)
|
||||
pam_logger("get greeter session error: %d\n", errno);
|
||||
buf[strlen(buf)-1] = '\0';
|
||||
if(strlen(buf) == 0) {
|
||||
char cmd1[] = "ps aux | grep ukui-greeter | grep -v grep | wc -l";
|
||||
pclose(stream);
|
||||
stream = popen(cmd1, "r");
|
||||
if(fgets(buf, len, stream) == NULL)
|
||||
pam_logger("get greeter session error: %d\n", errno);
|
||||
int i = atoi(buf);
|
||||
if(i > 0)
|
||||
strcpy(buf, "ukui-greeter");
|
||||
GPtrArray *args_ps = NULL;
|
||||
gchar *stdout_ps = NULL;
|
||||
gchar *greeter_name = NULL;
|
||||
|
||||
args_ps = g_ptr_array_new ();
|
||||
g_ptr_array_add(args_ps, (gpointer)"/usr/bin/ps");
|
||||
g_ptr_array_add(args_ps, (gpointer)"-aux");
|
||||
g_ptr_array_add(args_ps, (gpointer)"--columns");
|
||||
g_ptr_array_add(args_ps, (gpointer)"256");
|
||||
g_ptr_array_add(args_ps, NULL);
|
||||
|
||||
if (!g_spawn_sync(NULL, (char**)args_ps->pdata, NULL, G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, &stdout_ps, NULL, NULL, NULL)) {
|
||||
if (stdout_ps)
|
||||
g_free(stdout_ps);
|
||||
g_ptr_array_free (args_ps, TRUE);
|
||||
return ;
|
||||
}
|
||||
if (stdout_ps) {
|
||||
gchar **lines = NULL;
|
||||
lines = g_strsplit(stdout_ps, "\n", 0);
|
||||
for (int n = 0; lines[n] != NULL; n++) {
|
||||
if (lines[n][0] == '\0')
|
||||
continue;
|
||||
gchar *res = g_strstr_len(lines[n], 1024, "greeter-session");
|
||||
if (res) {
|
||||
gchar **greeter_args = g_strsplit(res, " ", 0);
|
||||
int arg_index = 0;
|
||||
for (int m = 0; greeter_args[m] != NULL; m++) {
|
||||
if (greeter_args[m][0] == '\0')
|
||||
continue;
|
||||
// greeter-session arg1
|
||||
if (arg_index == 1) {
|
||||
gchar *greeter = g_strrstr_len(greeter_args[m], 256, "/");
|
||||
if (greeter && strlen(greeter) > 1) {
|
||||
greeter_name = g_strdup(greeter + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
arg_index ++;
|
||||
}
|
||||
g_strfreev(greeter_args);
|
||||
if (greeter_name) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
g_strfreev(lines);
|
||||
g_free(stdout_ps);
|
||||
}
|
||||
g_ptr_array_free (args_ps, TRUE);
|
||||
if (greeter_name) {
|
||||
g_strlcpy(buf, greeter_name, len);
|
||||
g_free(greeter_name);
|
||||
} else {
|
||||
GPtrArray *args_pidof = NULL;
|
||||
gchar *stdout_pidof = NULL;
|
||||
|
||||
args_pidof = g_ptr_array_new ();
|
||||
g_ptr_array_add(args_pidof, (gpointer)"/usr/bin/pidof");
|
||||
g_ptr_array_add(args_pidof, (gpointer)"ukui-greeter");
|
||||
g_ptr_array_add(args_pidof, NULL);
|
||||
|
||||
if (!g_spawn_sync(NULL, (char**)args_pidof->pdata, NULL, G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, &stdout_pidof, NULL, NULL, NULL)) {
|
||||
if (stdout_pidof)
|
||||
g_free(stdout_pidof);
|
||||
g_ptr_array_free (args_pidof, TRUE);
|
||||
return ;
|
||||
}
|
||||
if (stdout_pidof) {
|
||||
if (strlen(stdout_pidof) > 0 && atoi(stdout_pidof) > 0) {
|
||||
g_strlcpy(buf, "ukui-greeter", len);
|
||||
}
|
||||
g_free(stdout_pidof);
|
||||
}
|
||||
g_ptr_array_free (args_pidof, TRUE);
|
||||
}
|
||||
pclose(stream);
|
||||
}
|
||||
|
||||
int enable_by_polkit()
|
||||
|
|
|
@ -40,6 +40,10 @@ include_directories(
|
|||
|
||||
qt5_add_resources(polkit_SRCS assets.qrc)
|
||||
|
||||
qt5_wrap_ui(polkit_SRCS
|
||||
src/mainwindow.ui
|
||||
)
|
||||
|
||||
set(polkit_SRCS
|
||||
${polkit_SRCS}
|
||||
src/PolkitAgent.cpp
|
||||
|
@ -59,6 +63,7 @@ target_link_libraries(polkit-ukui-authentication-agent-1
|
|||
${POLKITQT-1_LIBRARIES}
|
||||
BioAuthWidgets
|
||||
-lrt
|
||||
-lukui-log4qt
|
||||
)
|
||||
install(TARGETS polkit-ukui-authentication-agent-1
|
||||
DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}/ukui-polkit)
|
||||
|
|
|
@ -304,7 +304,17 @@
|
|||
<translation>ནང་འཇུག་གི་གསང་གྲངས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.cpp" line="627"/>
|
||||
<location filename="../src/mainwindow.cpp" line="104"/>
|
||||
<source>Insert the ukey into the USB port</source>
|
||||
<translation>བདེ་འཇགས་ཀྱི་གསང་བའི་ལྡེ་མིག་དེ་USBཡི་སྣེ་འདྲེན་དུ་འཇུག་རོགས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.cpp" line="106"/>
|
||||
<source>Enter the ukey password</source>
|
||||
<translation>གསང་བའི་ཨང་གྲངས་ནང་འཇུག་བྱེད་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.cpp" line="764"/>
|
||||
<source>hours left</source>
|
||||
<translation>དུས་ཚོད་འགའ་ལས་ལྷག་མེད</translation>
|
||||
</message>
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Password</source>
|
||||
<translation type="vanished">密码</translation>
|
||||
<translation>密码</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.ui" line="302"/>
|
||||
|
@ -304,7 +304,17 @@
|
|||
<translation>输入密码</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.cpp" line="627"/>
|
||||
<location filename="../src/mainwindow.cpp" line="104"/>
|
||||
<source>Insert the ukey into the USB port</source>
|
||||
<translation>请将安全密钥插入USB端口</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.cpp" line="106"/>
|
||||
<source>Enter the ukey password</source>
|
||||
<translation>输入安全密钥密码</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/mainwindow.cpp" line="764"/>
|
||||
<source>hours left</source>
|
||||
<translation>小时后解锁</translation>
|
||||
</message>
|
||||
|
|
|
@ -24,19 +24,19 @@
|
|||
#include "generic.h"
|
||||
#include "sessionmanager.h"
|
||||
#include "biodevices.h"
|
||||
#include <ukui-log4qt.h>
|
||||
|
||||
bool enableDebug;
|
||||
QString logPrefix;
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
enableDebug = true;
|
||||
logPrefix = "[ukui-polkit]:";
|
||||
qInstallMessageHandler(outputMessage);
|
||||
//qInstallMessageHandler(outputMessage);
|
||||
initUkuiLog4qt("ukui-polkit");
|
||||
qDebug() << "Polkit Agent Started";
|
||||
|
||||
#if(QT_VERSION>=QT_VERSION_CHECK(5,6,0))
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
|
|
@ -184,6 +184,10 @@ void PolkitListener::initiateAuthentication(
|
|||
startAuthentication();
|
||||
});
|
||||
|
||||
connect(mainWindow, &MainWindow::restartAuth, this, [&]{
|
||||
startAuthentication();
|
||||
});
|
||||
|
||||
connect(mainWindow, &MainWindow::userChanged, this, [&](const QString &userName){
|
||||
for(int i = 0; i < this->identities.size(); i++) {
|
||||
auto identity = this->identities.at(i);
|
||||
|
|
|
@ -1,20 +1,3 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "kalabel.h"
|
||||
|
||||
|
||||
|
|
|
@ -1,20 +1,3 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef KALABEL_H
|
||||
#define KALABEL_H
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <QPainterPath>
|
||||
#include <QDir>
|
||||
#include <QFont>
|
||||
#include <QLineEdit>
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
#include <QFontMetrics>
|
||||
|
@ -94,25 +95,74 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
m_loginOptsWidget = new LoginOptionsWidget();
|
||||
m_loginOptsWidget->hide();
|
||||
ui->titleTipLayout->addWidget(m_labelTip);
|
||||
ui->loginOptionsLayout->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
|
||||
ui->loginOptionsLayout->setAlignment(Qt::AlignTop|Qt::AlignCenter);
|
||||
ui->loginOptionsLayout->addWidget(m_loginOptsWidget);
|
||||
|
||||
ui->loadingUkeyWidget->hide();
|
||||
ui->widgetUkeyAuth->hide();
|
||||
ui->loadingUkeyBtn->setAttribute(Qt::WA_TransparentForMouseEvents, true);
|
||||
ui->ukeyPassword->setEchoMode(QLineEdit::Password);
|
||||
ui->loadingUkeyLbl->setText(tr("Insert the ukey into the USB port"));
|
||||
ui->loadingUkeyLbl->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
|
||||
ui->ukeyTipLbl->setText(tr("Enter the ukey password"));
|
||||
ui->ukeyPassword->setPlaceholderText(tr("Input Password"));
|
||||
ui->loadingUkeyWidget->adjustSize();
|
||||
maxFailedTimes = bioDevices.getFailedTimes();
|
||||
isHiddenSwitchButton = bioDevices.GetHiddenSwitchButton();
|
||||
|
||||
connect(m_loginOptsWidget, &LoginOptionsWidget::optionSelected,
|
||||
this, [&](unsigned uCurLoginOptType, const DeviceInfoPtr &deviceInfo){
|
||||
qDebug() << "device changed: " << deviceInfo->biotype;
|
||||
if(m_failMap[getUid(userName)][deviceInfo->device_id] >= maxFailedTimes){
|
||||
|
||||
isLoadingUkey = false;
|
||||
|
||||
if(uCurLoginOptType == LOGINOPT_TYPE_GENERAL_UKEY){
|
||||
stopLoadingUkey();
|
||||
}
|
||||
|
||||
if(uCurLoginOptType == LOGINOPT_TYPE_PASSWORD){
|
||||
switchLoginOptType(uCurLoginOptType);
|
||||
if(m_loginOptsWidget){
|
||||
m_loginOptsWidget->stopAuth();
|
||||
}
|
||||
m_deviceInfo = nullptr;
|
||||
authMode = PASSWORD;
|
||||
emit restartAuth();
|
||||
return;
|
||||
}
|
||||
|
||||
if (uCurLoginOptType != LOGINOPT_TYPE_GENERAL_UKEY && !deviceInfo)
|
||||
return;
|
||||
|
||||
if(deviceInfo)
|
||||
qDebug() << "device changed: " << deviceInfo->biotype;
|
||||
|
||||
if(deviceInfo && m_failMap[getUid(userName)][deviceInfo->device_id] >= maxFailedTimes){
|
||||
qDebug() << "Failed MAX!!";
|
||||
return ;
|
||||
}
|
||||
|
||||
if (uCurLoginOptType == LOGINOPT_TYPE_GENERAL_UKEY && !deviceInfo){
|
||||
isLoadingUkey = true;
|
||||
startLoadingUkey();
|
||||
m_loginOptsWidget->updateUkeyUIStatus(LOGINOPT_TYPE_GENERAL_UKEY);
|
||||
}else if(uCurLoginOptType == LOGINOPT_TYPE_GENERAL_UKEY && deviceInfo){
|
||||
stopLoadingUkey();
|
||||
m_loginOptsWidget->updateUkeyUIStatus(LOGINOPT_TYPE_GENERAL_UKEY);
|
||||
}
|
||||
|
||||
if (deviceInfo == m_deviceInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (uCurLoginOptType != LOGINOPT_TYPE_GENERAL_UKEY && deviceInfo == m_deviceInfo) {
|
||||
return ;
|
||||
}
|
||||
|
||||
if(m_bioTimer)
|
||||
m_bioTimer->stop();
|
||||
|
||||
m_deviceInfo = deviceInfo;
|
||||
switchLoginOptType(uCurLoginOptType);
|
||||
if(!isbioSuccess) {
|
||||
if(!isbioSuccess && m_deviceInfo) {
|
||||
startBioAuth();
|
||||
}
|
||||
});
|
||||
|
@ -122,10 +172,15 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
if (uOptionsCount > 0) {
|
||||
m_loginOptsWidget->show();
|
||||
} else {
|
||||
m_loginOptsWidget->hide();
|
||||
//m_loginOptsWidget->hide();
|
||||
}
|
||||
|
||||
if (m_deviceInfo && m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){
|
||||
stopLoadingUkey();
|
||||
}
|
||||
|
||||
if (!m_deviceInfo || !m_loginOptsWidget->findDeviceById(m_deviceInfo->device_id)
|
||||
|| m_loginOptsWidget->isDeviceDisable(m_deviceInfo->device_id)) {
|
||||
|| m_loginOptsWidget->isDeviceDisable(m_deviceInfo->device_id)) {
|
||||
m_loginOptsWidget->stopAuth();
|
||||
if (authMode != UNDEFINED) {
|
||||
authMode = UNDEFINED;
|
||||
|
@ -138,6 +193,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
this, [&](uid_t uid, bool ret, int nStatus){
|
||||
qDebug() << "biometric authentication complete: " << uid << ret << nStatus;
|
||||
|
||||
if(m_deviceInfo && m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY && ui->widgetUkeyAuth->isVisible()){
|
||||
ui->ukeyPassword->setText("");
|
||||
}
|
||||
|
||||
if(uid == getUid(userName) && ret) {
|
||||
isbioSuccess = true;
|
||||
emit switchToBiometric();
|
||||
|
@ -168,17 +227,27 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
setLoginTypeTip(tr("Failed to verify %1, please enter password to unlock").arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype)));
|
||||
QImage nullImage;
|
||||
m_loginOptsWidget->setQRCode(nullImage);
|
||||
} else {
|
||||
} else if(m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){
|
||||
ui->ukeyPassword->setReadOnly(true);
|
||||
setUkeyTypeTip(tr("Unable to verify %1, please enter password to unlock").arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype)));
|
||||
}else {
|
||||
setLoginTypeTip(tr("Unable to verify %1, please enter password to unlock").arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype)));
|
||||
}
|
||||
|
||||
m_loginOptsWidget->setDeviceDisable(m_deviceInfo->device_id, true);
|
||||
useDoubleAuth = false;
|
||||
return ;
|
||||
}
|
||||
no_changes = false;
|
||||
setLoginTypeTip(tr("Failed to verify %1, you still have %2 verification opportunities")
|
||||
.arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype))
|
||||
.arg(maxFailedTimes-m_failMap[curUid][m_deviceInfo->device_id]));
|
||||
if(m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){
|
||||
setUkeyTypeTip(tr("Failed to verify %1, you still have %2 verification opportunities")
|
||||
.arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype))
|
||||
.arg(maxFailedTimes-m_failMap[curUid][m_deviceInfo->device_id]));
|
||||
}else{
|
||||
setLoginTypeTip(tr("Failed to verify %1, you still have %2 verification opportunities")
|
||||
.arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype))
|
||||
.arg(maxFailedTimes-m_failMap[curUid][m_deviceInfo->device_id]));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!isbioSuccess) {
|
||||
|
@ -222,6 +291,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
ui->lblContent->height();
|
||||
ui->lblMessage->adjustSize();
|
||||
ui->widgetPasswdAuth->adjustSize();
|
||||
ui->widgetUkeyAuth->adjustSize();
|
||||
ui->lblMessage->height();
|
||||
ui->cmbUsers->view()->setTextElideMode(Qt::ElideRight);
|
||||
|
||||
|
@ -239,6 +309,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
this, SLOT(onLockStatus()));
|
||||
connect(interfaceScreensaver, SIGNAL(unlock()),
|
||||
this, SLOT(onUnlockStatus()));
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -275,6 +346,64 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||
return QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::setUkeyTypeTip(QString text)
|
||||
{
|
||||
QString textTip = text;
|
||||
if (!textTip.isEmpty()) {
|
||||
// QFontMetrics font(m_ukeyMessageLabel->font());
|
||||
// QString textTip = font.elidedText(textTip, Qt::ElideRight, m_messageLabel->width()-8);
|
||||
QPalette pe;
|
||||
pe.setColor(QPalette::WindowText,Qt::red);
|
||||
ui->ukeyMessage->setPalette(pe);
|
||||
ui->ukeyMessage->setText(textTip);
|
||||
ui->ukeyMessage->setToolTip(text);
|
||||
ui->ukeyMessage->show();
|
||||
} else {
|
||||
ui->ukeyMessage->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::startLoadingUkey()
|
||||
{
|
||||
isLoadingUkey = true;
|
||||
ui->loadingUkeyWidget->show();
|
||||
if(!m_loadingTimer)
|
||||
{
|
||||
m_loadingTimer = new QTimer(this);
|
||||
m_loadingTimer->setInterval(150);
|
||||
connect(m_loadingTimer, &QTimer::timeout, this, &MainWindow::updateLoadingPixmap);
|
||||
}
|
||||
|
||||
m_loadingPixmap = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(27,27);
|
||||
ui->loadingUkeyBtn->setIcon(m_loadingPixmap);
|
||||
ui->loadingUkeyBtn->setIconSize(QSize(27, 27));
|
||||
m_loadingTimer->start();
|
||||
ui->loadingUkeyWidget->adjustSize();
|
||||
ui->cmbUsers->hide();
|
||||
ui->widgetUkeyAuth->hide();
|
||||
ui->lePassword->hide();
|
||||
ui->widgetPasswdAuth->hide();
|
||||
}
|
||||
|
||||
void MainWindow::stopLoadingUkey()
|
||||
{
|
||||
isLoadingUkey = false;
|
||||
if(m_loadingTimer){
|
||||
m_loadingTimer->stop();
|
||||
}
|
||||
ui->loadingUkeyWidget->hide();
|
||||
//ui->cmbUsers->show();
|
||||
ui->widgetUkeyAuth->show();
|
||||
}
|
||||
|
||||
void MainWindow::updateLoadingPixmap()
|
||||
{
|
||||
QMatrix matrix;
|
||||
matrix.rotate(90.0);
|
||||
m_loadingPixmap = m_loadingPixmap.transformed(matrix, Qt::FastTransformation);
|
||||
ui->loadingUkeyBtn->setIcon(QIcon(m_loadingPixmap));
|
||||
}
|
||||
|
||||
void MainWindow::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
|
||||
|
@ -331,6 +460,13 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if(event->type() == QEvent::MouseButtonRelease) { //禁用鼠标中键
|
||||
QMouseEvent *mouseevent = static_cast<QMouseEvent*>(event);
|
||||
if(mouseevent->button() == Qt::MidButton){
|
||||
event->ignore();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -406,7 +542,11 @@ void MainWindow::on_btnCancel_clicked()
|
|||
|
||||
void MainWindow::on_btnAuth_clicked()
|
||||
{
|
||||
on_lePassword_returnPressed();
|
||||
if(ui->widgetUkeyAuth->isVisible()){
|
||||
on_ukeyPassword_returnPressed();
|
||||
}else{
|
||||
on_lePassword_returnPressed();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onLockStatus()
|
||||
|
@ -442,6 +582,14 @@ void MainWindow::editIcon()
|
|||
ui->lePassword->setTextMargins(1, 1, 4+ m_modeButton->width(), 1);
|
||||
}
|
||||
|
||||
void MainWindow::on_ukeyPassword_returnPressed()
|
||||
{
|
||||
if(m_loginOptsWidget && m_deviceInfo){
|
||||
m_loginOptsWidget->SetExtraInfo(ui->ukeyPassword->text(),"pincode");
|
||||
m_loginOptsWidget->startAuth(m_deviceInfo, getUid(userName));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_lePassword_returnPressed()
|
||||
{
|
||||
emit accept(ui->lePassword->text());
|
||||
|
@ -469,10 +617,8 @@ void MainWindow::on_btnBioAuth_clicked()
|
|||
|
||||
void MainWindow::on_returnButton_clicked()
|
||||
{
|
||||
|
||||
m_loginOptsWidget->stopAuth();
|
||||
accept(BIOMETRIC_IGNORE);
|
||||
|
||||
}
|
||||
/*** end of control's slot ***/
|
||||
|
||||
|
@ -557,8 +703,7 @@ void MainWindow::setUsers(const QStringList &usersList)
|
|||
}
|
||||
|
||||
ui->cmbUsers->show();
|
||||
ui->cmbUsers->adjustSize();
|
||||
ui->cmbUsers->height();
|
||||
//ui->cmbUsers->adjustSize();
|
||||
}
|
||||
/*
|
||||
void MainWindow::setDetails(const QString &subPid, const QString &callerPid, const QString &actionId,
|
||||
|
@ -593,10 +738,11 @@ void MainWindow::setPrompt(const QString &text, bool echo)
|
|||
}
|
||||
//qDebug() << "6666";
|
||||
m_timer->start();
|
||||
unlock_countdown();
|
||||
|
||||
ui->lePassword->clear();
|
||||
ui->lePassword->setPlaceholderText(prompt);
|
||||
switchWidget(PASSWORD);
|
||||
// switchWidget(PASSWORD);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -618,6 +764,7 @@ QString MainWindow::check_is_pam_message(QString text)
|
|||
char l_str[1024];
|
||||
int a,b;
|
||||
//兼容旧版本翻译,以及适配新版本翻译
|
||||
//因为不知道什么原因,pam发过来的始终为英文,因此这里主动加载pam的翻译文件,使用gettext获取翻译
|
||||
if(text.contains("attemps",Qt::CaseSensitive) && sscanf(str,"Authenticated failed, %d login attemps left",&a))
|
||||
snprintf(l_str,1024,_("Authenticated failed, %d login attemps left"),a);
|
||||
else if(text.contains("attempts",Qt::CaseSensitive) && sscanf(str,"Authenticated failed, %d login attempts left",&a))
|
||||
|
@ -625,6 +772,7 @@ QString MainWindow::check_is_pam_message(QString text)
|
|||
else if(text.contains("attempt",Qt::CaseSensitive) && sscanf(str,"Authenticated failed, %d login attempt left",&a))
|
||||
snprintf(l_str,1024,_("Authenticated failed, %d login attempt left"),a);
|
||||
else if(text.contains("days",Qt::CaseSensitive) && sscanf(str,"Account locked, %d days left",&a)){
|
||||
//这里的消息是多个字符串拼接起来的,无法在翻译文件中找到对应的句子,只能自己翻译
|
||||
strTrans = tr("Account locked,") + QString("%1 ").arg(a) + tr("days left");
|
||||
return strTrans;
|
||||
}
|
||||
|
@ -639,6 +787,10 @@ QString MainWindow::check_is_pam_message(QString text)
|
|||
else if(text.contains("seconds",Qt::CaseSensitive) && sscanf(str,"Account locked, %d seconds left",&a)){
|
||||
strTrans = tr("Account locked,") + QString("%1 ").arg(a) + tr("seconds left");
|
||||
return strTrans;
|
||||
}else if(text.contains("Warning: ",Qt::CaseSensitive) && sscanf(str,"Warning: your password will expire in %d day",&a)){
|
||||
snprintf(l_str,1024,_("Warning: your password will expire in %d day"),a);
|
||||
}else if(text.contains("Warning: ",Qt::CaseSensitive) && sscanf(str,"Warning: your password will expire in %d days",&a)){
|
||||
snprintf(l_str,1024,_("Warning: your password will expire in %d days"),a);
|
||||
}
|
||||
else{
|
||||
return _(str);
|
||||
|
@ -661,7 +813,7 @@ void MainWindow::setMessage(const QString &text,situation situat)
|
|||
QColor color = palette().color(QPalette::WindowText);
|
||||
QPalette pal(this->palette());
|
||||
pal.setColor(QPalette::WindowText,QColor(color));
|
||||
ui->lblMessage->setPalette(pal);
|
||||
ui->lblMessage->setPalette(pal);
|
||||
}
|
||||
|
||||
// qDebug()<<"receive:text = "<<text;
|
||||
|
@ -683,7 +835,7 @@ void MainWindow::setMessage(const QString &text,situation situat)
|
|||
ui->lblMessage->setToolTip(text);
|
||||
}
|
||||
ui->lblMessage->adjustSize();
|
||||
ui->widgetPasswdAuth->adjustSize();
|
||||
//ui->widgetPasswdAuth->adjustSize();
|
||||
// ui->lblMessage->setText(text);
|
||||
}
|
||||
|
||||
|
@ -708,6 +860,7 @@ void MainWindow::setAuthResult(bool result, const QString &text)
|
|||
void MainWindow::clearEdit()
|
||||
{
|
||||
ui->lePassword->setText("");
|
||||
ui->ukeyPassword->setText("");
|
||||
}
|
||||
|
||||
void MainWindow::switchAuthMode(Mode mode)
|
||||
|
@ -727,6 +880,10 @@ void MainWindow::switchAuthMode(Mode mode)
|
|||
m_loginOptsWidget->setEnabled(true);
|
||||
}
|
||||
|
||||
if(m_loginOptsWidget->getHasUkeyOptions()){
|
||||
m_loginOptsWidget->show();
|
||||
}
|
||||
|
||||
switch(mode){
|
||||
case PASSWORD:
|
||||
{
|
||||
|
@ -743,6 +900,7 @@ void MainWindow::switchAuthMode(Mode mode)
|
|||
if(isHiddenSwitchButton)
|
||||
ui->btnBioAuth->hide();
|
||||
|
||||
|
||||
// if(enableBioAuth && useDoubleAuth){
|
||||
// DeviceInfoPtr device = bioDevices.getDefaultDevice(getUid(userName));
|
||||
// if(device){
|
||||
|
@ -753,6 +911,11 @@ void MainWindow::switchAuthMode(Mode mode)
|
|||
break;
|
||||
case BIOMETRIC:
|
||||
{
|
||||
if(authMode == PASSWORD){
|
||||
emit accept(BIOMETRIC_IGNORE);
|
||||
isFirstAuth = false;
|
||||
return;
|
||||
}
|
||||
authMode = mode;
|
||||
qDebug() << "switch to biometric";
|
||||
if (m_deviceInfo) {
|
||||
|
@ -761,22 +924,28 @@ void MainWindow::switchAuthMode(Mode mode)
|
|||
m_deviceInfo = DeviceInfoPtr();
|
||||
}
|
||||
}
|
||||
/*if(authMode == PASSWORD) {
|
||||
emit accept(BIOMETRIC_IGNORE);
|
||||
return;
|
||||
}else */if(!enableBioAuth){
|
||||
|
||||
if(!enableBioAuth){
|
||||
qDebug() << "It doesn't meet the condition for enabling biometric authentication, switch to password.";
|
||||
emit accept(BIOMETRIC_IGNORE);
|
||||
isFirstAuth = false;
|
||||
return;
|
||||
} else if(authMode == BIOMETRIC) {
|
||||
QString strDeviceName = m_loginOptsWidget->GetDefaultDevice(uid);
|
||||
//如果默认设备为空的话,第一次不启动生物识别认证
|
||||
QString strDeviceName;
|
||||
if(isLoadingUkey){
|
||||
strDeviceName = m_loginOptsWidget->GetDefaultDevice(uid, UniT_General_Ukey);
|
||||
}else{
|
||||
strDeviceName = m_loginOptsWidget->GetDefaultDevice(uid);
|
||||
}
|
||||
//如果默认设备为空的话,第一次不启动生物识别认证
|
||||
if(strDeviceName.isEmpty() && !m_deviceInfo)
|
||||
{
|
||||
qDebug() << "No default device";
|
||||
emit accept(BIOMETRIC_IGNORE);
|
||||
isFirstAuth = false;
|
||||
return;
|
||||
}
|
||||
|
||||
//第一次,获取默认设备的设备信息,之后使用的则是从设备选择窗口传出的设备信息
|
||||
if(!m_deviceInfo)
|
||||
{
|
||||
|
@ -784,13 +953,34 @@ void MainWindow::switchAuthMode(Mode mode)
|
|||
}
|
||||
if(!m_deviceInfo){
|
||||
emit accept(BIOMETRIC_IGNORE);
|
||||
isFirstAuth = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_failMap.contains(uid) && m_failMap[uid].contains(m_deviceInfo->device_id)
|
||||
&& m_failMap[uid][m_deviceInfo->device_id] >= maxFailedTimes){
|
||||
emit accept(BIOMETRIC_IGNORE);
|
||||
isFirstAuth = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){
|
||||
if(isFirstAuth){
|
||||
isFirstAuth = false;
|
||||
m_deviceInfo = nullptr;
|
||||
emit accept(BIOMETRIC_IGNORE);
|
||||
return ;
|
||||
}
|
||||
switchLoginOptType(LOGINOPT_TYPE_GENERAL_UKEY);
|
||||
stopLoadingUkey();
|
||||
startBioAuth();
|
||||
m_loginOptsWidget->setCurrentDevice(m_deviceInfo);
|
||||
m_loginOptsWidget->updateUIStatus(false);
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
isFirstAuth = false;
|
||||
startBioAuth();
|
||||
emit accept(BIOMETRIC_IGNORE);
|
||||
return;
|
||||
|
@ -887,6 +1077,7 @@ void MainWindow::switchWidget(Mode mode)
|
|||
if(is_Mavis){
|
||||
ui->cmbUsers->setFixedHeight(48);
|
||||
ui->lePassword->setFixedHeight(48);
|
||||
ui->ukeyPassword->setFixedHeight(48);
|
||||
ui->btnAuth->setFixedHeight(48);
|
||||
ui->btnCancel->setFixedHeight(48);
|
||||
}
|
||||
|
@ -895,6 +1086,7 @@ void MainWindow::switchWidget(Mode mode)
|
|||
{
|
||||
setMinimumWidth(420);
|
||||
setMaximumWidth(420);
|
||||
|
||||
if (m_deviceInfo && m_loginOptsWidget->findDeviceById(m_deviceInfo->device_id)) {
|
||||
switchLoginOptType(m_loginOptsWidget->convertDeviceType(m_deviceInfo->biotype));
|
||||
} else {
|
||||
|
@ -905,27 +1097,27 @@ void MainWindow::switchWidget(Mode mode)
|
|||
}
|
||||
int height;
|
||||
if(fontSize = 10){
|
||||
height = 120 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
height = 130 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
+ ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height()
|
||||
+ ui->btnAuth->height();
|
||||
} else if(fontSize = 11 ){
|
||||
height = 140 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
+ ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height()
|
||||
+ ui->btnAuth->height();
|
||||
} else if (fontSize = 12){
|
||||
height = 150 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
+ ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height()
|
||||
+ ui->btnAuth->height();
|
||||
} else if (fontSize = 13){
|
||||
} else if (fontSize = 12){
|
||||
height = 160 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
+ ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height()
|
||||
+ ui->btnAuth->height();
|
||||
} else if (fontSize = 13){
|
||||
height = 170 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
+ ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height()
|
||||
+ ui->btnAuth->height();
|
||||
} else if (fontSize = 14){
|
||||
height = 180 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
height = 190 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
+ ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height()
|
||||
+ ui->btnAuth->height();
|
||||
} else if (fontSize = 15){
|
||||
height = 220 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
height = 230 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
+ ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height()
|
||||
+ ui->btnAuth->height();
|
||||
}
|
||||
|
@ -940,6 +1132,8 @@ void MainWindow::switchWidget(Mode mode)
|
|||
}
|
||||
setMinimumHeight(height + uOptsWidgetHeight + 10);
|
||||
setMaximumHeight(height + uOptsWidgetHeight + 10);
|
||||
|
||||
|
||||
//m_loginOptsWidget->updateUIStatus();
|
||||
ui->btnBioAuth->setStyleSheet("QPushButton{font-size:14px;}QPushButton:hover{border:none;color:#3E6CE5;}QPushButton:pressed{border:none;}");
|
||||
ui->btnBioAuth->setFlat(true);
|
||||
|
@ -956,7 +1150,7 @@ void MainWindow::switchWidget(Mode mode)
|
|||
}
|
||||
ui->btnAuth->show();
|
||||
ui->btnLoading->hide();
|
||||
ui->lePassword->setDisabled(false);
|
||||
//ui->lePassword->setDisabled(false);
|
||||
if(w_timer && w_timer->isActive())
|
||||
{
|
||||
w_timer->stop();
|
||||
|
@ -978,6 +1172,7 @@ void MainWindow::switchWidget(Mode mode)
|
|||
setMinimumHeight(482+ui->cmbUsers->height()+ui->lblHeader->height());
|
||||
setMaximumHeight(482+ui->cmbUsers->height()+ui->lblHeader->height());
|
||||
}
|
||||
|
||||
ui->btnCancel->hide();
|
||||
ui->lblContent->hide();
|
||||
ui->btnBioAuth->hide();
|
||||
|
@ -995,6 +1190,7 @@ void MainWindow::switchWidget(Mode mode)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// adjustSize();
|
||||
}
|
||||
|
||||
|
@ -1024,6 +1220,7 @@ void MainWindow::unlock_countdown()
|
|||
//ui->lblMessage->setToolTip(tr("Please try again in %1 minutes.").arg(nMinute));
|
||||
ui->lePassword->setText("");
|
||||
ui->lePassword->setDisabled(true);
|
||||
ui->btnAuth->setDisabled(true);
|
||||
isLockingFlg = true;
|
||||
return ;
|
||||
}
|
||||
|
@ -1034,6 +1231,7 @@ void MainWindow::unlock_countdown()
|
|||
//ui->lblMessage->setToolTip(tr("Please try again in %1 seconds.").arg(time_left%60));
|
||||
ui->lePassword->setText("");
|
||||
ui->lePassword->setDisabled(true);
|
||||
ui->btnAuth->setDisabled(true);
|
||||
isLockingFlg = true;
|
||||
return ;
|
||||
}
|
||||
|
@ -1043,6 +1241,7 @@ void MainWindow::unlock_countdown()
|
|||
ui->lblMessage->setToolTip(tr("Account locked permanently."));
|
||||
ui->lePassword->setText("");
|
||||
ui->lePassword->setDisabled(true);
|
||||
ui->btnAuth->setDisabled(true);
|
||||
isLockingFlg = true;
|
||||
return ;
|
||||
}
|
||||
|
@ -1052,6 +1251,9 @@ void MainWindow::unlock_countdown()
|
|||
ui->lePassword->setDisabled(false);
|
||||
ui->lePassword->setFocus();
|
||||
}
|
||||
if(ui->btnAuth){
|
||||
ui->btnAuth->setDisabled(false);
|
||||
}
|
||||
|
||||
if (isLockingFlg) {
|
||||
//setMessage(tr("Authentication failed, please try again."),ERROR);
|
||||
|
@ -1132,12 +1334,27 @@ void MainWindow::root_unlock_countdown()
|
|||
return ;
|
||||
}
|
||||
|
||||
void MainWindow::onRespondUkey(const QString &text)
|
||||
{
|
||||
if (m_loginOptsWidget){
|
||||
m_loginOptsWidget->SetExtraInfo(text,"pincode");
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::switchLoginOptType(unsigned uLoginOptType)
|
||||
{
|
||||
switch(uLoginOptType) {
|
||||
case LOGINOPT_TYPE_PASSWORD:
|
||||
{
|
||||
m_loginOptsWidget->hide();
|
||||
//m_loginOptsWidget->hide();
|
||||
ui->lePassword->show();
|
||||
ui->cmbUsers->show();
|
||||
ui->widgetPasswdAuth->show();
|
||||
ui->widgetUkeyAuth->hide();
|
||||
ui->ukeyPassword->clearFocus();
|
||||
ui->loadingUkeyWidget->hide();
|
||||
setFocusProxy(ui->lePassword);
|
||||
ui->cmbUsers->show();
|
||||
}
|
||||
break;
|
||||
case LOGINOPT_TYPE_FACE:
|
||||
|
@ -1155,6 +1372,31 @@ void MainWindow::switchLoginOptType(unsigned uLoginOptType)
|
|||
m_loginOptsWidget->setQRCodeMsg("");
|
||||
}
|
||||
});
|
||||
|
||||
//m_loginOptsWidget->hide();
|
||||
ui->lePassword->show();
|
||||
ui->widgetUkeyAuth->hide();
|
||||
ui->loadingUkeyWidget->hide();
|
||||
ui->ukeyPassword->clearFocus();
|
||||
setFocusProxy(ui->lePassword);
|
||||
ui->cmbUsers->show();
|
||||
ui->widgetPasswdAuth->show();
|
||||
}
|
||||
break;
|
||||
case LOGINOPT_TYPE_GENERAL_UKEY:
|
||||
{
|
||||
ui->lePassword->hide();
|
||||
ui->cmbUsers->hide();
|
||||
if(m_deviceInfo){
|
||||
stopLoadingUkey();
|
||||
ui->widgetUkeyAuth->show();
|
||||
}else{
|
||||
startLoadingUkey();
|
||||
}
|
||||
setFocusProxy(ui->ukeyPassword);
|
||||
ui->ukeyPassword->setFocusPolicy(Qt::StrongFocus);
|
||||
ui->ukeyPassword->setFocus();
|
||||
ui->widgetPasswdAuth->hide();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -1171,7 +1413,9 @@ void MainWindow::switchLoginOptType(unsigned uLoginOptType)
|
|||
no_changes = true;
|
||||
if (m_deviceInfo->biotype == REMOTE_QRCODE_TYPE) {
|
||||
setLoginTypeTip(tr("Failed to verify %1, please enter password to unlock").arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype)));
|
||||
} else {
|
||||
}else if(m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){
|
||||
setUkeyTypeTip(tr("Failed to verify %1, please enter password to unlock").arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype)));
|
||||
}else {
|
||||
setLoginTypeTip(tr("Unable to verify %1, please enter password to unlock").arg(BioDevices::bioTypeToString_tr(m_deviceInfo->biotype)));
|
||||
}
|
||||
m_loginOptsWidget->setDeviceDisable(m_deviceInfo->device_id, true);
|
||||
|
@ -1215,6 +1459,11 @@ void MainWindow::switchLoginOptType(unsigned uLoginOptType)
|
|||
setLoginTypeTip(tr("Use the bound wechat scanning code or enter the password to unlock"));
|
||||
}
|
||||
break;
|
||||
case LOGINOPT_TYPE_GENERAL_UKEY:
|
||||
{
|
||||
setLoginTypeTip("");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
@ -1248,7 +1497,11 @@ void MainWindow::setLoginTypeTip(QString strLoginTypeTip)
|
|||
void MainWindow::startBioAuthDelay()
|
||||
{
|
||||
if (m_deviceInfo) {
|
||||
m_loginOptsWidget->startAuth(m_deviceInfo, getUid(userName));
|
||||
if(m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){
|
||||
|
||||
}else{
|
||||
m_loginOptsWidget->startAuth(m_deviceInfo, getUid(userName));
|
||||
}
|
||||
switchLoginOptType(m_loginOptsWidget->convertDeviceType(m_deviceInfo->biotype));
|
||||
} else {
|
||||
switchLoginOptType(LOGINOPT_TYPE_PASSWORD);
|
||||
|
@ -1259,6 +1512,11 @@ void MainWindow::startBioAuthDelay()
|
|||
void MainWindow::startBioAuth(unsigned uTimeout)
|
||||
{
|
||||
m_loginOptsWidget->stopAuth();
|
||||
|
||||
if(m_deviceInfo && m_deviceInfo->biotype == LOGINOPT_TYPE_GENERAL_UKEY){
|
||||
switchLoginOptType(m_loginOptsWidget->convertDeviceType(m_deviceInfo->biotype));
|
||||
}
|
||||
|
||||
if(!m_bioTimer){
|
||||
m_bioTimer = new QTimer(this);
|
||||
connect(m_bioTimer, SIGNAL(timeout()), this, SLOT(startBioAuthDelay()));
|
||||
|
@ -1306,35 +1564,43 @@ void MainWindow::onUpdateWndSize(unsigned uLoginOptType, unsigned uLoginOptSize)
|
|||
// ui->lblHeader->adjustSize();
|
||||
int height;
|
||||
if(fontSize = 10){
|
||||
height = 120 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
height = 130 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
+ ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height()
|
||||
+ ui->btnAuth->height();
|
||||
} else if(fontSize = 11 ){
|
||||
height = 140 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
+ ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height()
|
||||
+ ui->btnAuth->height();
|
||||
} else if (fontSize = 12){
|
||||
height = 150 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
+ ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height()
|
||||
+ ui->btnAuth->height();
|
||||
} else if (fontSize = 13){
|
||||
} else if (fontSize = 12){
|
||||
height = 160 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
+ ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height()
|
||||
+ ui->btnAuth->height();
|
||||
} else if (fontSize = 13){
|
||||
height = 170 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
+ ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height()
|
||||
+ ui->btnAuth->height();
|
||||
} else if (fontSize = 14){
|
||||
height = 180 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
height = 190 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
+ ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height()
|
||||
+ ui->btnAuth->height();
|
||||
} else if (fontSize = 15){
|
||||
height = 220 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
height = 230 + ui->lblHeader->height() /*+ ui->lblContent->height()*/
|
||||
+ ui->cmbUsers->height() + ui->lePassword->height() + ui->lblMessage->height()
|
||||
+ ui->btnAuth->height();
|
||||
}
|
||||
if (m_loginOptsWidget->isHidden()) {
|
||||
height -= 20 ;
|
||||
}
|
||||
setMinimumHeight(height + uOptsWidgetHeight);
|
||||
setMaximumHeight(height + uOptsWidgetHeight);
|
||||
|
||||
if(uLoginOptType == LOGINOPT_TYPE_GENERAL_UKEY){
|
||||
|
||||
setMinimumHeight(height + uOptsWidgetHeight + 10);
|
||||
setMaximumHeight(height + uOptsWidgetHeight + 10);
|
||||
}else{
|
||||
|
||||
setMinimumHeight(height + uOptsWidgetHeight);
|
||||
setMaximumHeight(height + uOptsWidgetHeight);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setEditInputMethod(bool bEnable)
|
||||
|
|
|
@ -64,6 +64,10 @@ public:
|
|||
void switchLoginOptType(unsigned uLoginOptType);
|
||||
void setEditInputMethod(bool bEnable);
|
||||
void setCurProject(bool isMavis);
|
||||
void setUkeyTypeTip(QString text);
|
||||
void startLoadingUkey();
|
||||
void stopLoadingUkey();
|
||||
void updateLoadingPixmap();
|
||||
|
||||
private:
|
||||
uid_t getUid(const QString &userName);
|
||||
|
@ -88,6 +92,7 @@ public slots:
|
|||
private slots:
|
||||
void on_btnDetails_clicked();
|
||||
void on_lePassword_returnPressed();
|
||||
void on_ukeyPassword_returnPressed();
|
||||
void on_btnBioAuth_clicked();
|
||||
void on_returnButton_clicked();
|
||||
void on_cmbUsers_currentTextChanged(const QString &userName);
|
||||
|
@ -98,6 +103,7 @@ private slots:
|
|||
void onConfigurationChanged(QString key);
|
||||
void onLockStatus();
|
||||
void onUnlockStatus();
|
||||
void onRespondUkey(const QString &text);
|
||||
|
||||
signals:
|
||||
void accept(const QString &text);
|
||||
|
@ -105,6 +111,7 @@ signals:
|
|||
void switchToPassword();
|
||||
void switchToBiometric();
|
||||
void userChanged(const QString &userName);
|
||||
void restartAuth();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
@ -125,6 +132,9 @@ private:
|
|||
bool pwdShow = false;
|
||||
bool isHover = false;
|
||||
|
||||
//ukey优先级比密码低,该变量用于判断是否第一次认证,并选中密码
|
||||
bool isFirstAuth = true;
|
||||
|
||||
QTimer *m_timer;
|
||||
//const DeviceInfo *device = NULL;
|
||||
bool isLockingFlg; //判断当前是否正在锁定倒计时
|
||||
|
@ -154,6 +164,10 @@ private:
|
|||
|
||||
QTimer *w_timer;
|
||||
QPixmap m_waitingPixmap;
|
||||
|
||||
QTimer *m_loadingTimer = nullptr;
|
||||
QPixmap m_loadingPixmap;
|
||||
bool isLoadingUkey = false;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>459</width>
|
||||
<height>432</height>
|
||||
<height>547</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -42,7 +42,7 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>12</number>
|
||||
<number>24</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
|
@ -67,6 +67,37 @@
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lblHeader">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>382</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>382</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lblContent">
|
||||
<property name="styleSheet">
|
||||
|
@ -95,35 +126,155 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="cmbUsers">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="loadingUkeyWidget" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>36</height>
|
||||
<height>116</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>36</height>
|
||||
</size>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="loadingUkeyBtn">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="loadingUkeyLbl">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QComboBox" name="cmbUsers">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="7" column="1">
|
||||
<layout class="QFormLayout" name="bioDeviceLayout">
|
||||
<property name="bottomMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="8" column="1">
|
||||
<widget class="QWidget" name="widgetUkeyAuth" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>116</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<property name="horizontalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLineEdit" name="ukeyPassword">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="KALabel" name="ukeyMessage">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="ukeyTipLbl">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QWidget" name="widgetPasswdAuth" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
|
@ -131,6 +282,9 @@
|
|||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
|
@ -154,18 +308,6 @@
|
|||
</property>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLineEdit" name="lePassword">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>372</width>
|
||||
<height>36</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>36</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
|
@ -204,37 +346,6 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lblHeader">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>382</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>382</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -255,9 +366,15 @@
|
|||
<property name="spacing">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>24</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>24</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
|
|
@ -1,20 +1,3 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#include "modeButton.h"
|
||||
|
||||
#include <QIcon>
|
||||
|
|
|
@ -1,20 +1,3 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
#ifndef MODEBUTTON_H
|
||||
#define MODEBUTTON_H
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ set(bin_SRCS
|
|||
)
|
||||
|
||||
add_executable(uniauth-backend ${bin_SRCS})
|
||||
target_link_libraries(uniauth-backend Qt5::Core Qt5::DBus)
|
||||
target_link_libraries(uniauth-backend Qt5::Core Qt5::DBus -lukui-log4qt)
|
||||
|
||||
install(TARGETS uniauth-backend DESTINATION bin)
|
||||
install(FILES org.ukui.UniauthBackend.conf DESTINATION /etc/dbus-1/system.d/)
|
||||
|
|
|
@ -47,6 +47,7 @@ enum BioType {
|
|||
__MAX_NR_BIOTYPES
|
||||
};
|
||||
|
||||
#define UNIT_GENERAL_UKEY (6)
|
||||
#define REMOTE_QRCODE_TYPE (8)
|
||||
|
||||
Q_DECLARE_METATYPE(DeviceInfo)
|
||||
|
|
|
@ -17,9 +17,11 @@
|
|||
**/
|
||||
#include <QCoreApplication>
|
||||
#include "serviceinterface.h"
|
||||
#include <ukui-log4qt.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
initUkuiLog4qt("ukui-biometric-uniauth");
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
ServiceInterface serviveInterface;
|
||||
|
|
|
@ -86,6 +86,9 @@ void ServiceInterface::setDefaultDevice(QString userName, int bioDevType, QStrin
|
|||
case BIOTYPE_VOICEPRINT:
|
||||
settings.setValue("VP_DefaultDevice", deviceName);
|
||||
break;
|
||||
case UNIT_GENERAL_UKEY:
|
||||
settings.setValue("GU_DefaultDevice",deviceName);
|
||||
break;
|
||||
case REMOTE_QRCODE_TYPE:
|
||||
settings.setValue("WC_DefaultDevice", deviceName);
|
||||
break;
|
||||
|
@ -138,6 +141,9 @@ QString ServiceInterface::getDefaultDevice(QString userName, int bioDevType)
|
|||
case BIOTYPE_VOICEPRINT:
|
||||
strBioDefType = "VP_DefaultDevice";
|
||||
break;
|
||||
case UNIT_GENERAL_UKEY:
|
||||
strBioDefType = "GU_DefaultDevice";
|
||||
break;
|
||||
case REMOTE_QRCODE_TYPE:
|
||||
strBioDefType = "WC_DefaultDevice";
|
||||
break;
|
||||
|
@ -173,6 +179,9 @@ QString ServiceInterface::getDefaultDevice(QString userName, int bioDevType)
|
|||
case BIOTYPE_VOICEPRINT:
|
||||
defaultDevice = settings.value("VP_DefaultDevice").toString();
|
||||
break;
|
||||
case UNIT_GENERAL_UKEY:
|
||||
defaultDevice = settings.value("GU_DefaultDevice").toString();
|
||||
break;
|
||||
case REMOTE_QRCODE_TYPE:
|
||||
defaultDevice = settings.value("WC_DefaultDevice").toString();
|
||||
break;
|
||||
|
@ -198,6 +207,9 @@ QString ServiceInterface::getDefaultDevice(QString userName, int bioDevType)
|
|||
case BIOTYPE_VOICEPRINT:
|
||||
defaultDevice = settings2.value("VP_DefaultDevice").toString();
|
||||
break;
|
||||
case UNIT_GENERAL_UKEY:
|
||||
defaultDevice = settings2.value("GU_DefaultDevice").toString();
|
||||
break;
|
||||
case REMOTE_QRCODE_TYPE:
|
||||
defaultDevice = settings2.value("WC_DefaultDevice").toString();
|
||||
break;
|
||||
|
@ -238,6 +250,9 @@ QStringList ServiceInterface::getAllDefaultDevice(QString userName)
|
|||
case BIOTYPE_VOICEPRINT:
|
||||
strBioDefType = "VP_DefaultDevice";
|
||||
break;
|
||||
case UNIT_GENERAL_UKEY:
|
||||
strBioDefType = "GU_DefaultDevice";
|
||||
break;
|
||||
case REMOTE_QRCODE_TYPE:
|
||||
strBioDefType = "WC_DefaultDevice";
|
||||
break;
|
||||
|
@ -277,6 +292,9 @@ QStringList ServiceInterface::getAllDefaultDevice(QString userName)
|
|||
case BIOTYPE_VOICEPRINT:
|
||||
defaultDevice = settings.value("VP_DefaultDevice").toString();
|
||||
break;
|
||||
case UNIT_GENERAL_UKEY:
|
||||
defaultDevice = settings.value("GU_DefaultDevice").toString();
|
||||
break;
|
||||
case REMOTE_QRCODE_TYPE:
|
||||
defaultDevice = settings.value("WC_DefaultDevice").toString();
|
||||
break;
|
||||
|
@ -300,6 +318,9 @@ QStringList ServiceInterface::getAllDefaultDevice(QString userName)
|
|||
case BIOTYPE_VOICEPRINT:
|
||||
defaultDevice = settings2.value("VP_DefaultDevice").toString();
|
||||
break;
|
||||
case UNIT_GENERAL_UKEY:
|
||||
defaultDevice = settings2.value("GU_DefaultDevice").toString();
|
||||
break;
|
||||
case REMOTE_QRCODE_TYPE:
|
||||
defaultDevice = settings2.value("WC_DefaultDevice").toString();
|
||||
break;
|
||||
|
@ -334,6 +355,9 @@ void ServiceInterface::setCommDefaultDevice(int bioDevType, QString deviceName)
|
|||
case BIOTYPE_VOICEPRINT:
|
||||
settings.setValue("VP_DefaultDevice", deviceName);
|
||||
break;
|
||||
case UNIT_GENERAL_UKEY:
|
||||
settings.setValue("GU_DefaultDevice", deviceName);
|
||||
break;
|
||||
case REMOTE_QRCODE_TYPE:
|
||||
settings.setValue("WC_DefaultDevice", deviceName);
|
||||
break;
|
||||
|
@ -366,6 +390,9 @@ QString ServiceInterface::getCommDefaultDevice(int bioDevType)
|
|||
case BIOTYPE_VOICEPRINT:
|
||||
defaultDevice = settings2.value("VP_DefaultDevice").toString();
|
||||
break;
|
||||
case UNIT_GENERAL_UKEY:
|
||||
defaultDevice = settings2.value("GU_DefaultDevice").toString();
|
||||
break;
|
||||
case REMOTE_QRCODE_TYPE:
|
||||
defaultDevice = settings2.value("WC_DefaultDevice").toString();
|
||||
break;
|
||||
|
@ -707,6 +734,9 @@ void ServiceInterface::initData()
|
|||
case BIOTYPE_VOICEPRINT:
|
||||
strBioDefType = "VP_DefaultDevice";
|
||||
break;
|
||||
case UNIT_GENERAL_UKEY:
|
||||
strBioDefType = "GU_DefaultDevice";
|
||||
break;
|
||||
case REMOTE_QRCODE_TYPE:
|
||||
strBioDefType = "WC_DefaultDevice";
|
||||
break;
|
||||
|
@ -742,6 +772,9 @@ void ServiceInterface::initData()
|
|||
case BIOTYPE_VOICEPRINT:
|
||||
strBioDefType = "VP_DefaultDevice";
|
||||
break;
|
||||
case UNIT_GENERAL_UKEY:
|
||||
strBioDefType = "GU_DefaultDevice";
|
||||
break;
|
||||
case REMOTE_QRCODE_TYPE:
|
||||
strBioDefType = "WC_DefaultDevice";
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue