MCPcopy Create free account
hub / github.com/Zalafina/QKeyMapper / doFunctionMappingProc

Method doFunctionMappingProc

QKeyMapper/qkeymapper_worker.cpp:11777–11922  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11775}
11776
11777void QKeyMapper_Worker::doFunctionMappingProc(const QString &func_keystring)
11778{
11779#ifdef DEBUG_LOGOUT_ON
11780 qDebug() << "[doFunctionMappingProc]" << "Function KeyString ->" << func_keystring;
11781#endif
11782
11783 if (func_keystring == FUNC_REFRESH) {
11784 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
11785 }
11786 else if (func_keystring == FUNC_LOCKSCREEN) {
11787 if( !LockWorkStation() ) {
11788#ifdef DEBUG_LOGOUT_ON
11789 qDebug() << "[doFunctionMappingProc]" << "LockWorkStation Failed with ->" << GetLastError();
11790#endif
11791 }
11792 else {
11793#ifdef DEBUG_LOGOUT_ON
11794 qDebug() << "[doFunctionMappingProc]" << "LockWorkStation Success.";
11795#endif
11796 }
11797 }
11798 else if (func_keystring == FUNC_SHUTDOWN) {
11799 bool adjust_priv;
11800 adjust_priv = EnablePrivilege(SE_SHUTDOWN_NAME);
11801 if (adjust_priv) {
11802 if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCEIFHUNG, SHTDN_REASON_FLAG_PLANNED)) {
11803#ifdef DEBUG_LOGOUT_ON
11804 qDebug() << "[doFunctionMappingProc]" << "System Shutdown Failed with ->" << GetLastError();
11805#endif
11806 }
11807 else {
11808#ifdef DEBUG_LOGOUT_ON
11809 qDebug() << "[doFunctionMappingProc]" << "System Shutdown Success.";
11810#endif
11811 }
11812 }
11813 else {
11814#ifdef DEBUG_LOGOUT_ON
11815 qDebug() << "[doFunctionMappingProc]" << "System Shutdown EnablePrivilege Failed with ->" << GetLastError();
11816#endif
11817 }
11818 adjust_priv = DisablePrivilege(SE_SHUTDOWN_NAME);
11819
11820 if (!adjust_priv) {
11821#ifdef DEBUG_LOGOUT_ON
11822 qDebug() << "[doFunctionMappingProc]" << "System Shutdown DisablePrivilege Failed with ->" << GetLastError();
11823#endif
11824 }
11825 }
11826 else if (func_keystring == FUNC_REBOOT) {
11827 bool adjust_priv;
11828 adjust_priv = EnablePrivilege(SE_SHUTDOWN_NAME);
11829 if (adjust_priv) {
11830 if (!ExitWindowsEx(EWX_REBOOT | EWX_FORCEIFHUNG, SHTDN_REASON_FLAG_PLANNED)) {
11831#ifdef DEBUG_LOGOUT_ON
11832 qDebug() << "[doFunctionMappingProc]" << "System Reboot Failed with ->" << GetLastError();
11833#endif
11834 }

Callers

nothing calls this directly

Calls 2

EnablePrivilegeFunction · 0.85
DisablePrivilegeFunction · 0.85

Tested by

no test coverage detected