Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ add_subdirectory("global_util/dbus")
add_subdirectory("dde-bluetooth-dialog")
add_subdirectory("dde-hints-dialog")
add_subdirectory("dde-license-dialog")
add_subdirectory("deepin-login-reminder")
add_subdirectory("dde-lowpower")
#add_subdirectory("dde-osd")
add_subdirectory("dde-pixmix")
Expand Down
2 changes: 1 addition & 1 deletion REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ SPDX-FileCopyrightText = "UnionTech Software Technology Co., Ltd."
SPDX-License-Identifier = "GPL-3.0-or-later"

[[annotations]]
path = "dde-osd/files/dde-osd.desktop"
path = ["dde-osd/files/dde-osd.desktop", "deepin-login-reminder/deepin-login-reminder.desktop", "deepin-login-reminder/dconf/org.deepin.login-reminder.json"]
precedence = "aggregate"
SPDX-FileCopyrightText = "UnionTech Software Technology Co., Ltd."
SPDX-License-Identifier = "GPL-3.0-or-later"
Expand Down
44 changes: 44 additions & 0 deletions deepin-login-reminder/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later

set(BIN_NAME deepin-login-reminder)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Network DBus REQUIRED)
find_package(Dtk${DTK_VERSION_MAJOR} COMPONENTS Core REQUIRED)

find_package(PkgConfig REQUIRED)

message(${PROJECT_SOURCE_DIR})

add_executable(${BIN_NAME}
main.cpp
loginreminderinfo.h
loginreminderinfo.cpp
)

target_link_libraries(${BIN_NAME}
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::DBus
Qt${QT_VERSION_MAJOR}::Network
Dtk${DTK_VERSION_MAJOR}::Core
)

target_compile_definitions(${BIN_NAME} PRIVATE
CMAKE_INSTALL_FULL_DATADIR="${CMAKE_INSTALL_FULL_DATADIR}"
)

install(TARGETS ${BIN_NAME} DESTINATION bin)

# Install desktop file to autostart directory
install(FILES deepin-login-reminder.desktop DESTINATION /etc/xdg/autostart/)

# Install dconf configuration files
dtk_add_config_meta_files(
APPID org.deepin.login-reminder
FILES ${CMAKE_CURRENT_SOURCE_DIR}/dconf/org.deepin.login-reminder.json
)
17 changes: 17 additions & 0 deletions deepin-login-reminder/dconf/org.deepin.login-reminder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"magic": "dsg.config.meta",
"version": "1.0",
"contents": {
"LoginReminder": {
"value": false,
"serial": 0,
"flags": [],
"name": "login reminder",
"name[zh_CN]": "登录提醒",
"description": "Display login reminder notification including login information, password expiration warning and failed login attempts",
"description[zh_CN]": "显示登录提醒通知,包括登录信息、密码过期警告和登录失败次数",
"permissions": "readwrite",
"visibility": "public"
}
}
}
10 changes: 10 additions & 0 deletions deepin-login-reminder/deepin-login-reminder.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Desktop Entry]
Type=Application
Name=Deepin Login Reminder
Comment=Display login reminder notification
Exec=/usr/bin/deepin-login-reminder
Icon=preferences-system
Terminal=false
Categories=System;
X-Deepin-AutoStart=true
NoDisplay=true
95 changes: 95 additions & 0 deletions deepin-login-reminder/loginreminderinfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// SPDX-FileCopyrightText: 2021 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "loginreminderinfo.h"

void registerLoginReminderInfoMetaType()
{
qRegisterMetaType<LoginUtmpx>("LoginUtmpx");
qDBusRegisterMetaType<LoginUtmpx>();

qRegisterMetaType<Spent>("Spent");
qDBusRegisterMetaType<Spent>();

qRegisterMetaType<LoginReminderInfo>("LoginReminderInfo");
qDBusRegisterMetaType<LoginReminderInfo>();
}

bool Spent::operator ==(const Spent &other)
{
return (LastChange == other.LastChange)
&& (Min == other.Min)
&& (Max == other.Max)
&& (Warn == other.Warn)
&& (Inactive == other.Inactive)
&& (Expire == other.Expire);
}

bool LoginUtmpx::operator ==(const LoginUtmpx &other)
{
return (InittabID == other.InittabID)
&& (Line == other.Line)
&& (Host == other.Host)
&& (Address == other.Address)
&& (Time == other.Time);
}

bool LoginReminderInfo::operator ==(const LoginReminderInfo &other)
{
return (Username == other.Username)
&& (spent == other.spent)
&& (CurrentLogin == other.CurrentLogin)
&& (LastLogin == other.LastLogin)
&& (FailCountSinceLastLogin == other.FailCountSinceLastLogin);
}

QDBusArgument &operator<<(QDBusArgument &arg, const Spent &other)
{
arg.beginStructure();
arg << other.LastChange << other.Min << other.Max << other.Warn << other.Inactive << other.Expire;
arg.endStructure();
return arg;
}

const QDBusArgument &operator>>(const QDBusArgument &arg, Spent &other)
{
arg.beginStructure();
arg >> other.LastChange >> other.Min >> other.Max >> other.Warn >> other.Inactive >> other.Expire;
arg.endStructure();
return arg;
}

QDBusArgument &operator<<(QDBusArgument &arg, const LoginUtmpx &other)
{
arg.beginStructure();
arg << other.InittabID << other.Line << other.Host << other.Address<< other.Time;
arg.endStructure();
return arg;
}

const QDBusArgument &operator>>(const QDBusArgument &arg, LoginUtmpx &other)
{
arg.beginStructure();
arg >> other.InittabID >> other.Line >> other.Host >> other.Address >> other.Time;
arg.endStructure();
return arg;
}

QDBusArgument &operator<<(QDBusArgument &arg, const LoginReminderInfo &other)
{
arg.beginStructure();
arg << other.Username << other.spent << other.CurrentLogin
<< other.LastLogin << other.FailCountSinceLastLogin;
arg.endStructure();
return arg;
}

const QDBusArgument &operator>>(const QDBusArgument &arg, LoginReminderInfo &other)
{
arg.beginStructure();
arg >> other.Username >> other.spent >> other.CurrentLogin
>> other.LastLogin >> other.FailCountSinceLastLogin;
arg.endStructure();
return arg;
}
52 changes: 52 additions & 0 deletions deepin-login-reminder/loginreminderinfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-FileCopyrightText: 2021 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef LOGINREMINDERINFO_H
#define LOGINREMINDERINFO_H

#include <QDBusMetaType>
#include <QDBusObjectPath>
struct Spent{
int LastChange;
int Min;
int Max;
int Warn;
int Inactive;
int Expire;

bool operator ==(const Spent &other);
};
Q_DECLARE_METATYPE(Spent)
QDBusArgument &operator<<(QDBusArgument &arg, const Spent &other);
const QDBusArgument &operator>>(const QDBusArgument &arg, Spent &other);

struct LoginUtmpx {
QString InittabID;
QString Line;
QString Host;
QString Address;
QString Time;

bool operator ==(const LoginUtmpx &other);
};
Q_DECLARE_METATYPE(LoginUtmpx)
QDBusArgument &operator<<(QDBusArgument &arg, const LoginUtmpx &other);
const QDBusArgument &operator>>(const QDBusArgument &arg, LoginUtmpx &other);

struct LoginReminderInfo {
QString Username;
Spent spent;
LoginUtmpx CurrentLogin;
LoginUtmpx LastLogin;
int FailCountSinceLastLogin;

bool operator ==(const LoginReminderInfo &other);
};
Q_DECLARE_METATYPE(LoginReminderInfo)
QDBusArgument &operator<<(QDBusArgument &arg, const LoginReminderInfo &other);
const QDBusArgument &operator>>(const QDBusArgument &arg, LoginReminderInfo &other);

void registerLoginReminderInfoMetaType();

#endif // LOGINREMINDERINFO_H
Loading
Loading