diff options
author | George Hazan <ghazan@miranda.im> | 2018-06-13 18:16:13 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-06-13 18:16:13 +0300 |
commit | 723bc42a5dfe925c655cced2c184ddfdfc144ada (patch) | |
tree | 0de1f13f2510af9761821d53039ba4684b37f218 /src/mir_app | |
parent | e71725076a18bf48579275e196886dc2edb9aee1 (diff) |
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;
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/idle.cpp | 87 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/miranda.h | 5 | ||||
-rw-r--r-- | src/mir_app/src/modules.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/newplugins.cpp | 8 | ||||
-rw-r--r-- | src/mir_app/src/stdafx.h | 1 |
7 files changed, 103 insertions, 4 deletions
diff --git a/src/mir_app/src/idle.cpp b/src/mir_app/src/idle.cpp new file mode 100644 index 0000000000..bc58e6b587 --- /dev/null +++ b/src/mir_app/src/idle.cpp @@ -0,0 +1,87 @@ +/* + +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" + +#define MODULENAME "Idle" + +static bool bModuleInitialized = false; + +static int g_idleType; +static int g_bIsIdle; + +static HANDLE hIdleEvent; + +MIR_APP_DLL(void) Idle_Enter(int type) +{ + int flags = 0; + + if (db_get_b(0, MODULENAME, "IdlePrivate")) + flags |= IDF_PRIVACY; + + if (!g_bIsIdle && type != -1) { + g_bIsIdle = true; + g_idleType = type; + NotifyEventHooks(hIdleEvent, 0, IDF_ISIDLE | flags); + } + + if (g_bIsIdle && type == -1) { + g_bIsIdle = false; + g_idleType = 0; + NotifyEventHooks(hIdleEvent, 0, flags); + } +} + +MIR_APP_DLL(void) Idle_GetInfo(MIRANDA_IDLE_INFO &pInfo) +{ + pInfo.idleTime = db_get_dw(0, MODULENAME, "IdleTime1st"); + pInfo.privacy = db_get_b(0, MODULENAME, "IdlePrivate"); + pInfo.aaStatus = db_get_b(0, MODULENAME, "AAEnable", 1) ? db_get_w(0, MODULENAME, "AAStatus") : 0; + pInfo.aaLock = db_get_b(0, MODULENAME, "IdleStatusLock"); + pInfo.idlesoundsoff = db_get_b(0, MODULENAME, "IdleSoundsOff"); + pInfo.idleType = g_idleType; +} + +int LoadIdleModule(void) +{ + bModuleInitialized = true; + + hIdleEvent = CreateHookableEvent(ME_IDLE_CHANGED); + + g_idleType = g_bIsIdle = 0; + return 0; +} + +void UnloadIdleModule() +{ + if (!bModuleInitialized) return; + + if (g_bIsIdle) { + NotifyEventHooks(hIdleEvent, 0, 0); + g_bIsIdle = false; + } + + DestroyHookableEvent(hIdleEvent); + hIdleEvent = nullptr; +} diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index cde723cefb..eb583a156b 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -622,3 +622,5 @@ Srmm_ClickStatusIcon @649 ?LockName@MDatabaseCommon@@IAE_NPB_W@Z @651 NONAME
?UnlockName@MDatabaseCommon@@IAEXXZ @652 NONAME
Profile_CheckOpened @653
+Idle_Enter @654 NONAME
+Idle_GetInfo @655 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 44634d5ce9..111d7ba071 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -622,3 +622,5 @@ Srmm_ClickStatusIcon @649 ?LockName@MDatabaseCommon@@IEAA_NPEB_W@Z @651 NONAME
?UnlockName@MDatabaseCommon@@IEAAXXZ @652 NONAME
Profile_CheckOpened @653
+Idle_Enter @654 NONAME
+Idle_GetInfo @655 NONAME
diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index a381d71f3d..eeee17772d 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -57,6 +57,11 @@ extern LIST<DATABASELINK> arDbPlugins; int InitIni(void);
void UninitIni(void);
+/**** idle.cpp *************************************************************************/
+
+int LoadIdleModule(void);
+void UnloadIdleModule(void);
+
/**** miranda.cpp **********************************************************************/
extern DWORD hMainThreadId;
diff --git a/src/mir_app/src/modules.cpp b/src/mir_app/src/modules.cpp index 600683eaa4..20ee0ef05a 100644 --- a/src/mir_app/src/modules.cpp +++ b/src/mir_app/src/modules.cpp @@ -155,12 +155,14 @@ int LoadDefaultModules(void) if (LoadFindAddModule()) return 1;
if (LoadIgnoreModule()) return 1;
if (LoadVisibilityModule()) return 1;
+ if (LoadIdleModule()) return 1;
if (LoadStdPlugins()) return 1;
return 0;
}
void UnloadDefaultModules(void)
{
+ UnloadIdleModule();
UnloadChatModule();
UnloadAccountsModule();
UnloadMetacontacts();
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index 2be85d985e..be9af32af5 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -109,6 +109,7 @@ static const MUUID pluginBannedList[] = { 0x3750a5a3, 0xbf0d, 0x490e, { 0xb6, 0x5d, 0x41, 0xac, 0x4d, 0x29, 0xae, 0xb3 } }, // aim
{ 0x7c070f7c, 0x459e, 0x46b7, { 0x8e, 0x6d, 0xbc, 0x6e, 0xfa, 0xa2, 0x2f, 0x78 } }, // advaimg
{ 0xa0138fc6, 0x4c52, 0x4501, { 0xaf, 0x93, 0x7d, 0x3e, 0x20, 0xbc, 0xae, 0x5b } }, // dbchecker
+ { 0x53ac190b, 0xe223, 0x4341, { 0x82, 0x5f, 0x70, 0x9d, 0x85, 0x20, 0x21, 0x5b } }, // stdidle
};
static bool isPluginBanned(const MUUID &u1)
@@ -131,10 +132,9 @@ static MuuidReplacement pluginDefault[] = { MIID_SREMAIL, L"stdemail", nullptr }, // 3
{ MIID_SRFILE, L"stdfile", nullptr }, // 4
{ MIID_UIHISTORY, L"stduihist", nullptr }, // 5
- { MIID_IDLE, L"stdidle", nullptr }, // 6
- { MIID_AUTOAWAY, L"stdautoaway", nullptr }, // 7
- { MIID_USERONLINE, L"stduseronline", nullptr }, // 8
- { MIID_SRAWAY, L"stdaway", nullptr }, // 9
+ { MIID_AUTOAWAY, L"stdautoaway", nullptr }, // 6
+ { MIID_USERONLINE, L"stduseronline", nullptr }, // 7
+ { MIID_SRAWAY, L"stdaway", nullptr }, // 8
};
int getDefaultPluginIdx(const MUUID &muuid)
diff --git a/src/mir_app/src/stdafx.h b/src/mir_app/src/stdafx.h index c9b5e8fa10..1158f779fa 100644 --- a/src/mir_app/src/stdafx.h +++ b/src/mir_app/src/stdafx.h @@ -71,6 +71,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_clistint.h>
#include <m_avatars.h>
#include <m_button.h>
+#include <m_idle.h>
#include <m_protosvc.h>
#include <m_protocols.h>
#include <m_protoint.h>
|