From 723bc42a5dfe925c655cced2c184ddfdfc144ada Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 13 Jun 2018 18:16:13 +0300 Subject: System idle: - plugin StdIdle that had been acting as an options dialog for StdAutoAway removed; - service MS_IDLE_GETIDLEINFO moved into the core and replaced with Idle_GetInfo(); - new function Idle_Enter() is available to tell the core that Miranda is idle; - StdAutoAway & StatusManager adapted for these changes; --- src/core/stdidle/CMakeLists.txt | 2 - src/core/stdidle/res/resource.rc | 90 ------------------- src/core/stdidle/res/version.rc | 9 -- src/core/stdidle/src/idle.cpp | 146 ------------------------------- src/core/stdidle/src/main.cpp | 66 -------------- src/core/stdidle/src/options.cpp | 134 ---------------------------- src/core/stdidle/src/stdafx.cxx | 2 - src/core/stdidle/src/stdafx.h | 105 ---------------------- src/core/stdidle/src/version.h | 11 --- src/core/stdidle/stdidle.vcxproj | 28 ------ src/core/stdidle/stdidle.vcxproj.filters | 4 - 11 files changed, 597 deletions(-) delete mode 100644 src/core/stdidle/CMakeLists.txt delete mode 100644 src/core/stdidle/res/resource.rc delete mode 100644 src/core/stdidle/res/version.rc delete mode 100644 src/core/stdidle/src/idle.cpp delete mode 100644 src/core/stdidle/src/main.cpp delete mode 100644 src/core/stdidle/src/options.cpp delete mode 100644 src/core/stdidle/src/stdafx.cxx delete mode 100644 src/core/stdidle/src/stdafx.h delete mode 100644 src/core/stdidle/src/version.h delete mode 100644 src/core/stdidle/stdidle.vcxproj delete mode 100644 src/core/stdidle/stdidle.vcxproj.filters (limited to 'src/core/stdidle') diff --git a/src/core/stdidle/CMakeLists.txt b/src/core/stdidle/CMakeLists.txt deleted file mode 100644 index 67735cfc07..0000000000 --- a/src/core/stdidle/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -set(TARGET StdIdle) -include(${CMAKE_SOURCE_DIR}/cmake/core.cmake) \ No newline at end of file diff --git a/src/core/stdidle/res/resource.rc b/src/core/stdidle/res/resource.rc deleted file mode 100644 index 1b926065de..0000000000 --- a/src/core/stdidle/res/resource.rc +++ /dev/null @@ -1,90 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "..\..\mir_app\src\resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include -#include - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_OPT_IDLE DIALOGEX 0, 0, 312, 193 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - CONTROL "Become idle if the following is left unattended:",IDC_IDLESHORT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,18,259,9 - CONTROL "Windows",IDC_IDLEONWINDOWS,"Button",BS_AUTORADIOBUTTON,45,31,104,9 - CONTROL "Miranda",IDC_IDLEONMIRANDA,"Button",BS_AUTORADIOBUTTON,45,43,103,9 - EDITTEXT IDC_IDLE1STTIME,59,59,27,14,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "Spin2",IDC_IDLESPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,86,59,11,14 - CONTROL "Become idle if the screen saver is active",IDC_SCREENSAVER, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,83,265,9 - CONTROL "Become idle if the computer is locked",IDC_LOCKED, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,105,265,9 - CONTROL "Become idle if a terminal session is disconnected",IDC_IDLETERMINAL, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,116,265,10 - CONTROL "Do not let protocols report any idle information",IDC_IDLEPRIVATE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,131,251,9 - LTEXT "minute(s)",IDC_STATIC,99,61,76,9 - RTEXT "for",IDC_STATIC,12,62,41,8 - COMBOBOX IDC_AASTATUS,161,146,64,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Change my status mode to:",IDC_AASHORTIDLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,147,132,11 - CONTROL "Do not set status back to online when returning from idle",IDC_IDLESTATUSLOCK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,164,254,10 - GROUPBOX "Idle options",IDC_STATIC,3,1,304,192 - CONTROL "Become idle if application full screen",IDC_FULLSCREEN, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,94,265,9 - CONTROL "Disable sounds on idle",IDC_IDLESOUNDSOFF,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,177,265,9 -END - -#endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "..\..\mir_app\src\resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include \r\n" - "#include \r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED diff --git a/src/core/stdidle/res/version.rc b/src/core/stdidle/res/version.rc deleted file mode 100644 index 5a5ddd63ed..0000000000 --- a/src/core/stdidle/res/version.rc +++ /dev/null @@ -1,9 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#include "..\src\version.h" - -#include "..\..\build\Version.rc" diff --git a/src/core/stdidle/src/idle.cpp b/src/core/stdidle/src/idle.cpp deleted file mode 100644 index 309375ed67..0000000000 --- a/src/core/stdidle/src/idle.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (c) 2012-18 Miranda NG team (https://miranda-ng.org), -Copyright (c) 2000-12 Miranda IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -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 2 -of the License, 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "stdafx.h" - -Settings S; - -static bool bModuleInitialized = false; - -static UINT_PTR g_hTimer; -static int g_idleType; -static int g_bIsIdle; - -static HANDLE hIdleEvent; - -void CALLBACK IdleTimer(HWND hwnd, UINT umsg, UINT_PTR idEvent, DWORD dwTime); -int IdleOptInit(WPARAM wParam, LPARAM); - -void IdleObject_Create() -{ - g_idleType = g_bIsIdle = 0; - g_hTimer = SetTimer(nullptr, 0, 2000, IdleTimer); -} - -void IdleObject_Destroy() -{ - if (g_bIsIdle) { - NotifyEventHooks(hIdleEvent, 0, 0); - g_bIsIdle = false; - } - KillTimer(nullptr, g_hTimer); -} - -static int IdleObject_IsUserIdle() -{ - if (S.bIdleMethod) { - DWORD dwTick; - CallService(MS_SYSTEM_GETIDLE, 0, (LPARAM)&dwTick); - return GetTickCount() - dwTick > (S.iIdleTime1st * 60 * 1000); - } - - LASTINPUTINFO ii = { sizeof(ii) }; - if (GetLastInputInfo(&ii)) - return GetTickCount() - ii.dwTime > (S.iIdleTime1st * 60 * 1000); - - return FALSE; -} - -static void IdleObject_Tick() -{ - bool idle = false; - int idleType = 0, flags = 0; - - if (S.bIdleCheck && IdleObject_IsUserIdle()) { - idleType = 1; idle = true; - } - else if (S.bIdleOnSaver && IsScreenSaverRunning()) { - idleType = 2; idle = true; - } - else if (S.bIdleOnFullScr && IsFullScreen()) { - idleType = 5; idle = true; - } - else if (S.bIdleOnLock && IsWorkstationLocked()) { - idleType = 3; idle = true; - } - else if (S.bIdleOnTerminal && IsTerminalDisconnected()) { - idleType = 4; idle = true; - } - - if (S.bIdlePrivate) - flags |= IDF_PRIVACY; - - if (!g_bIsIdle && idle) { - g_bIsIdle = true; - g_idleType = idleType; - NotifyEventHooks(hIdleEvent, 0, IDF_ISIDLE | flags); - } - - if (g_bIsIdle && !idle) { - g_bIsIdle = false; - g_idleType = 0; - NotifyEventHooks(hIdleEvent, 0, flags); - } -} - -void CALLBACK IdleTimer(HWND, UINT, UINT_PTR idEvent, DWORD) -{ - if (g_hTimer == idEvent) - IdleObject_Tick(); -} - -static INT_PTR IdleGetInfo(WPARAM, LPARAM lParam) -{ - MIRANDA_IDLE_INFO *mii = (MIRANDA_IDLE_INFO*)lParam; - if (!mii) - return 1; - - mii->idleTime = S.iIdleTime1st; - mii->privacy = S.bIdlePrivate; - mii->aaStatus = (S.bAAEnable) ? S.bAAStatus : 0; - mii->aaLock = S.bIdleStatusLock; - mii->idlesoundsoff = S.bIdleSoundsOff; - mii->idleType = g_idleType; - return 0; -} - -int LoadIdleModule(void) -{ - bModuleInitialized = TRUE; - - hIdleEvent = CreateHookableEvent(ME_IDLE_CHANGED); - IdleObject_Create(); - CreateServiceFunction(MS_IDLE_GETIDLEINFO, IdleGetInfo); - HookEvent(ME_OPT_INITIALISE, IdleOptInit); - return 0; -} - -void UnloadIdleModule() -{ - if (!bModuleInitialized) return; - - IdleObject_Destroy(); - DestroyHookableEvent(hIdleEvent); - hIdleEvent = nullptr; -} diff --git a/src/core/stdidle/src/main.cpp b/src/core/stdidle/src/main.cpp deleted file mode 100644 index a77bcba4d3..0000000000 --- a/src/core/stdidle/src/main.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - -Standard idle state module for Miranda NG - -Copyright (c) 2012-18 Miranda NG team (https://miranda-ng.org) - -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 2 of the License, 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, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "stdafx.h" - -int LoadIdleModule(void); -void UnloadIdleModule(void); - -CMPlugin g_plugin; - -///////////////////////////////////////////////////////////////////////////////////////// - -PLUGININFOEX pluginInfoEx = { - sizeof(PLUGININFOEX), - __PLUGIN_NAME, - MIRANDA_VERSION_DWORD, - __DESCRIPTION, - __AUTHOR, - __COPYRIGHT, - __AUTHORWEB, - UNICODE_AWARE, - // 53ac190b-e223-4341-825f-709d8520215b - { 0x53ac190b, 0xe223, 0x4341, {0x82, 0x5f, 0x70, 0x9d, 0x85, 0x20, 0x21, 0x5b}} -}; - -CMPlugin::CMPlugin() : - PLUGIN(MODULENAME, pluginInfoEx) -{} - -///////////////////////////////////////////////////////////////////////////////////////// - -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_IDLE, MIID_LAST }; - -///////////////////////////////////////////////////////////////////////////////////////// - -int CMPlugin::Load() -{ - LoadIdleModule(); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -int CMPlugin::Unload() -{ - UnloadIdleModule(); - return 0; -} diff --git a/src/core/stdidle/src/options.cpp b/src/core/stdidle/src/options.cpp deleted file mode 100644 index 71b8c14f27..0000000000 --- a/src/core/stdidle/src/options.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (c) 2012-18 Miranda NG team (https://miranda-ng.org), -Copyright (c) 2000-12 Miranda IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -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 2 -of the License, 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "stdafx.h" - -static const WORD aa_Status[] = { ID_STATUS_AWAY, ID_STATUS_NA, ID_STATUS_OCCUPIED, ID_STATUS_DND, ID_STATUS_ONTHEPHONE, ID_STATUS_OUTTOLUNCH }; - -int IdleGetStatusIndex(WORD status) -{ - for (int j = 0; j < _countof(aa_Status); j++) - if (aa_Status[j] == status) - return j; - - return 0; -} - -class COptionsDlg : public CDlgBase -{ - CCtrlEdit edt1sttime; - CCtrlSpin spinIdle; - CCtrlCombo cmbAAStatus; - CCtrlCheck chkShort, chkOnWindows, chkOnMiranda, chkScreenSaver, chkFullScreen, chkLocked; - CCtrlCheck chkPrivate, chkStatusLock, chkTerminal, chkSoundsOff, chkShortIdle; - - void ShowHide() - { - BOOL bChecked = chkShort.GetState(); - chkOnWindows.Enable(bChecked); - chkOnMiranda.Enable(bChecked); - edt1sttime.Enable(bChecked); - - bChecked = chkShortIdle.GetState(); - cmbAAStatus.Enable(bChecked); - chkStatusLock.Enable(bChecked); - } - -public: - COptionsDlg() : - CDlgBase(g_plugin, IDD_OPT_IDLE), - edt1sttime(this, IDC_IDLE1STTIME), - spinIdle(this, IDC_IDLESPIN), - cmbAAStatus(this, IDC_AASTATUS), - chkShort(this, IDC_IDLESHORT), - chkLocked(this, IDC_LOCKED), - chkPrivate(this, IDC_IDLEPRIVATE), - chkTerminal(this, IDC_IDLETERMINAL), - chkOnWindows(this, IDC_IDLEONWINDOWS), - chkSoundsOff(this, IDC_IDLESOUNDSOFF), - chkOnMiranda(this, IDC_IDLEONMIRANDA), - chkShortIdle(this, IDC_AASHORTIDLE), - chkStatusLock(this, IDC_IDLESTATUSLOCK), - chkFullScreen(this, IDC_FULLSCREEN), - chkScreenSaver(this, IDC_SCREENSAVER) - { - CreateLink(chkShort, S.bIdleCheck); - CreateLink(chkLocked, S.bIdleOnLock); - CreateLink(chkPrivate, S.bIdlePrivate); - CreateLink(chkTerminal, S.bIdleOnTerminal); - CreateLink(chkShortIdle, S.bAAEnable); - CreateLink(chkOnMiranda, S.bIdleMethod); - CreateLink(chkSoundsOff, S.bIdleSoundsOff); - CreateLink(chkStatusLock, S.bIdleStatusLock); - CreateLink(chkFullScreen, S.bIdleOnFullScr); - CreateLink(chkScreenSaver, S.bIdleOnSaver); - - chkShortIdle.OnChange = chkShort.OnChange = Callback(this, &COptionsDlg::onChange); - } - - virtual void OnInitDialog() override - { - chkOnWindows.SetState(!S.bIdleMethod); - - spinIdle.SetRange(60, 1); - spinIdle.SetPosition(S.iIdleTime1st); - - for (auto &it : aa_Status) - cmbAAStatus.AddString(Clist_GetStatusModeDescription(it, 0)); - cmbAAStatus.SetCurSel(IdleGetStatusIndex(S.bAAStatus)); - - ShowHide(); - } - - virtual void OnApply() override - { - S.iIdleTime1st = spinIdle.GetPosition(); - - int curSel = cmbAAStatus.GetCurSel(); - if (curSel != CB_ERR) - S.bAAStatus = aa_Status[curSel]; - - // destroy any current idle and reset settings. - IdleObject_Destroy(); - IdleObject_Create(); - } - - void onChange(CCtrlCheck*) - { - ShowHide(); - } -}; - -int IdleOptInit(WPARAM wParam, LPARAM) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - odp.position = 100000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_IDLE); - odp.szGroup.a = LPGEN("Status"); - odp.szTitle.a = LPGEN("Idle"); - odp.flags = ODPF_BOLDGROUPS; - odp.pDialog = new COptionsDlg(); - g_plugin.addOptions(wParam, &odp); - return 0; -} diff --git a/src/core/stdidle/src/stdafx.cxx b/src/core/stdidle/src/stdafx.cxx deleted file mode 100644 index 716dda68f1..0000000000 --- a/src/core/stdidle/src/stdafx.cxx +++ /dev/null @@ -1,2 +0,0 @@ -#include "stdafx.h" - diff --git a/src/core/stdidle/src/stdafx.h b/src/core/stdidle/src/stdafx.h deleted file mode 100644 index 1efc351565..0000000000 --- a/src/core/stdidle/src/stdafx.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (c) 2012-18 Miranda NG team (https://miranda-ng.org), -Copyright (c) 2000-12 Miranda IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -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 2 -of the License, 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#pragma once - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "version.h" - -#include "../../mir_app/src/resource.h" - -#define MODULENAME "Idle" - -struct CMPlugin : public PLUGIN -{ - CMPlugin(); - - int Load() override; - int Unload() override; -}; - -struct Settings -{ - Settings() : - bIdleCheck(MODULENAME, "UserIdleCheck", 0), - bIdleMethod(MODULENAME, "IdleMethod", 0), - bIdleOnSaver(MODULENAME, "IdleOnSaver", 0), - bIdleOnFullScr(MODULENAME, "IdleOnFullScr", 0), - bIdleOnLock(MODULENAME, "IdleOnLock", 0), - bIdlePrivate(MODULENAME, "IdlePrivate", 0), - bIdleSoundsOff(MODULENAME, "IdleSoundsOff", 1), - bIdleOnTerminal(MODULENAME, "IdleOnTerminalDisconnect", 0), - bIdleStatusLock(MODULENAME, "IdleStatusLock", 0), - bAAEnable(MODULENAME, "AAEnable", 0), - bAAStatus(MODULENAME, "AAStatus", 0), - iIdleTime1st(MODULENAME, "IdleTime1st", 10) - {} - - CMOption bIdleCheck, bIdleMethod, bIdleOnSaver, bIdleOnFullScr, bIdleOnLock; - CMOption bIdlePrivate, bIdleSoundsOff, bIdleOnTerminal, bIdleStatusLock; - CMOption bAAEnable; - CMOption bAAStatus; - CMOption iIdleTime1st; -}; - -extern Settings S; - -void IdleObject_Destroy(); -void IdleObject_Create(); diff --git a/src/core/stdidle/src/version.h b/src/core/stdidle/src/version.h deleted file mode 100644 index 0c72bc1c1e..0000000000 --- a/src/core/stdidle/src/version.h +++ /dev/null @@ -1,11 +0,0 @@ -#include - -#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION -#define __VERSION_STRING MIRANDA_VERSION_STRING - -#define __PLUGIN_NAME "Standard Idle module" -#define __FILENAME "stdidle.dll" -#define __DESCRIPTION "Core module for idle state processing." -#define __AUTHOR "Miranda NG team" -#define __AUTHORWEB "https://miranda-ng.org/p/StdIdle/" -#define __COPYRIGHT "© 2012-18 Miranda NG team" diff --git a/src/core/stdidle/stdidle.vcxproj b/src/core/stdidle/stdidle.vcxproj deleted file mode 100644 index 28b53db407..0000000000 --- a/src/core/stdidle/stdidle.vcxproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - StdIdle - {36c40ba6-e0b5-438a-919c-6a991933b313} - - - - - \ No newline at end of file diff --git a/src/core/stdidle/stdidle.vcxproj.filters b/src/core/stdidle/stdidle.vcxproj.filters deleted file mode 100644 index e39f86d5d6..0000000000 --- a/src/core/stdidle/stdidle.vcxproj.filters +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file -- cgit v1.2.3