From cae63f959eeacca02bf3504e77e8a6e4a1aa8499 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 6 Jul 2012 16:58:48 +0000 Subject: + stdautoaway + stdhelp + stduihist + stdidle + stduseronline git-svn-id: http://svn.miranda-ng.org/main/trunk@795 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/modules.cpp | 19 +- src/core/stdauth/main.cpp | 4 +- src/core/stdauth/resource.rc | 3 + src/core/stdauth/stdauth_10.vcxproj | 1 + src/core/stdautoaway/autoaway.cpp | 117 ++++ src/core/stdautoaway/commonheaders.cpp | 2 + src/core/stdautoaway/commonheaders.h | 93 +++ src/core/stdautoaway/main.cpp | 72 +++ src/core/stdautoaway/resource.rc | 66 +++ src/core/stdautoaway/stdautoaway_10.vcxproj | 217 +++++++ .../stdautoaway/stdautoaway_10.vcxproj.filters | 44 ++ src/core/stdautoaway/version.h | 14 + src/core/stdautoaway/version.rc | 38 ++ src/core/stdemail/main.cpp | 2 +- src/core/stdemail/resource.rc | 60 +- src/core/stdemail/stdemail_10.vcxproj | 1 + src/core/stdemail/version.h | 2 +- src/core/stdfile/main.cpp | 6 +- src/core/stdfile/resource.rc | 4 +- src/core/stdfile/stdfile_10.vcxproj | 1 + src/core/stdfile/version.h | 2 +- src/core/stdhelp/about.cpp | 144 +++++ src/core/stdhelp/commonheaders.cpp | 2 + src/core/stdhelp/commonheaders.h | 95 +++ src/core/stdhelp/help.cpp | 116 ++++ src/core/stdhelp/main.cpp | 77 +++ src/core/stdhelp/resource.rc | 90 +++ src/core/stdhelp/stdhelp_10.vcxproj | 218 +++++++ src/core/stdhelp/stdhelp_10.vcxproj.filters | 47 ++ src/core/stdhelp/version.h | 14 + src/core/stdhelp/version.rc | 38 ++ src/core/stdidle/commonheaders.cpp | 2 + src/core/stdidle/commonheaders.h | 105 ++++ src/core/stdidle/idle.cpp | 523 ++++++++++++++++ src/core/stdidle/main.cpp | 91 +++ src/core/stdidle/resource.rc | 134 +++++ src/core/stdidle/stdidle_10.vcxproj | 217 +++++++ src/core/stdidle/stdidle_10.vcxproj.filters | 44 ++ src/core/stdidle/version.h | 14 + src/core/stdidle/version.rc | 38 ++ src/core/stduihist/commonheaders.cpp | 2 + src/core/stduihist/commonheaders.h | 95 +++ src/core/stduihist/history.cpp | 430 ++++++++++++++ src/core/stduihist/main.cpp | 77 +++ src/core/stduihist/resource.rc | 107 ++++ src/core/stduihist/stduihist_10.vcxproj | 217 +++++++ src/core/stduihist/stduihist_10.vcxproj.filters | 44 ++ src/core/stduihist/version.h | 14 + src/core/stduihist/version.rc | 38 ++ src/core/stdurl/main.cpp | 4 +- src/core/stdurl/resource.rc | 60 +- src/core/stdurl/stdurl_10.vcxproj | 1 + src/core/stduserinfo/stduserinfo_10.vcxproj | 1 + src/core/stduseronline/commonheaders.cpp | 2 + src/core/stduseronline/commonheaders.h | 93 +++ src/core/stduseronline/main.cpp | 75 +++ src/core/stduseronline/resource.rc | 66 +++ src/core/stduseronline/stduseronline_10.vcxproj | 217 +++++++ .../stduseronline/stduseronline_10.vcxproj.filters | 44 ++ src/core/stduseronline/useronline.cpp | 127 ++++ src/core/stduseronline/version.h | 14 + src/core/stduseronline/version.rc | 38 ++ src/miranda32_10.vcxproj | 21 - src/miranda32_10.vcxproj.filters | 39 -- src/modules/autoaway/autoaway.cpp | 84 --- src/modules/help/about.cpp | 144 ----- src/modules/help/help.cpp | 116 ---- src/modules/history/history.cpp | 428 -------------- src/modules/idle/idle.cpp | 524 ---------------- src/modules/plugins/newplugins.cpp | 9 +- src/modules/updatenotify/updatenotify.cpp | 656 --------------------- src/modules/useronline/useronline.cpp | 117 ---- src/resource.rc | 169 ------ 73 files changed, 4404 insertions(+), 2446 deletions(-) create mode 100644 src/core/stdautoaway/autoaway.cpp create mode 100644 src/core/stdautoaway/commonheaders.cpp create mode 100644 src/core/stdautoaway/commonheaders.h create mode 100644 src/core/stdautoaway/main.cpp create mode 100644 src/core/stdautoaway/resource.rc create mode 100644 src/core/stdautoaway/stdautoaway_10.vcxproj create mode 100644 src/core/stdautoaway/stdautoaway_10.vcxproj.filters create mode 100644 src/core/stdautoaway/version.h create mode 100644 src/core/stdautoaway/version.rc create mode 100644 src/core/stdhelp/about.cpp create mode 100644 src/core/stdhelp/commonheaders.cpp create mode 100644 src/core/stdhelp/commonheaders.h create mode 100644 src/core/stdhelp/help.cpp create mode 100644 src/core/stdhelp/main.cpp create mode 100644 src/core/stdhelp/resource.rc create mode 100644 src/core/stdhelp/stdhelp_10.vcxproj create mode 100644 src/core/stdhelp/stdhelp_10.vcxproj.filters create mode 100644 src/core/stdhelp/version.h create mode 100644 src/core/stdhelp/version.rc create mode 100644 src/core/stdidle/commonheaders.cpp create mode 100644 src/core/stdidle/commonheaders.h create mode 100644 src/core/stdidle/idle.cpp create mode 100644 src/core/stdidle/main.cpp create mode 100644 src/core/stdidle/resource.rc create mode 100644 src/core/stdidle/stdidle_10.vcxproj create mode 100644 src/core/stdidle/stdidle_10.vcxproj.filters create mode 100644 src/core/stdidle/version.h create mode 100644 src/core/stdidle/version.rc create mode 100644 src/core/stduihist/commonheaders.cpp create mode 100644 src/core/stduihist/commonheaders.h create mode 100644 src/core/stduihist/history.cpp create mode 100644 src/core/stduihist/main.cpp create mode 100644 src/core/stduihist/resource.rc create mode 100644 src/core/stduihist/stduihist_10.vcxproj create mode 100644 src/core/stduihist/stduihist_10.vcxproj.filters create mode 100644 src/core/stduihist/version.h create mode 100644 src/core/stduihist/version.rc create mode 100644 src/core/stduseronline/commonheaders.cpp create mode 100644 src/core/stduseronline/commonheaders.h create mode 100644 src/core/stduseronline/main.cpp create mode 100644 src/core/stduseronline/resource.rc create mode 100644 src/core/stduseronline/stduseronline_10.vcxproj create mode 100644 src/core/stduseronline/stduseronline_10.vcxproj.filters create mode 100644 src/core/stduseronline/useronline.cpp create mode 100644 src/core/stduseronline/version.h create mode 100644 src/core/stduseronline/version.rc delete mode 100644 src/modules/autoaway/autoaway.cpp delete mode 100644 src/modules/help/about.cpp delete mode 100644 src/modules/help/help.cpp delete mode 100644 src/modules/history/history.cpp delete mode 100644 src/modules/idle/idle.cpp delete mode 100644 src/modules/updatenotify/updatenotify.cpp delete mode 100644 src/modules/useronline/useronline.cpp (limited to 'src') diff --git a/src/core/modules.cpp b/src/core/modules.cpp index 2077e9ab36..2a02103a10 100644 --- a/src/core/modules.cpp +++ b/src/core/modules.cpp @@ -48,24 +48,18 @@ int LoadFindAddModule(void); // ui: search/add users int LoadSkinIcons(void); int LoadSkinSounds(void); int LoadSkinHotkeys(void); -int LoadHelpModule(void); // ui: help stuff int LoadUserInfoModule(void); // ui: user info -int LoadHistoryModule(void); // ui: history viewer int LoadAwayMsgModule(void); // ui: setting away messages int LoadVisibilityModule(void); // ui: visibility control int LoadCLUIModule(void); // ui: CList UI int LoadPluginOptionsModule(void); // ui: plugin viewer int LoadAddContactModule(void); // ui: authcontrol contacts -int LoadIdleModule(void); // rnd: report idle information -int LoadAutoAwayModule(void); // ui: away -int LoadUserOnlineModule(void); // ui: online alert int LoadUtilsModule(void); // ui: utils (has a few window classes, like HyperLink) int LoadCLCModule(void); // window class: CLC control int LoadButtonModule(void); // window class: button class int LoadContactsModule(void); // random: contact int LoadFontserviceModule(void); // ui: font manager int LoadIcoLibModule(void); // ui: icons manager -int LoadUpdateNotifyModule(void); // random: update notification int LoadServiceModePlugin(void); int LoadErrorsModule(); @@ -74,11 +68,9 @@ void UnloadButtonModule(void); void UnloadClcModule(void); void UnloadContactListModule(void); void UnloadEventsModule(void); -void UnloadIdleModule(void); void UnloadSslModule(void); void UnloadNetlibModule(void); void UnloadNewPlugins(void); -void UnloadUpdateNotifyModule(void); void UnloadIcoLibModule(void); void UnloadSkinSounds(void); void UnloadSkinHotkeys(void); @@ -141,7 +133,7 @@ int LoadDefaultModules(void) if ( LoadIgnoreModule()) return 1; if ( LoadVisibilityModule()) return 1; - for (int i=0; i < 5; i++) { + for (int i=0; i < 10; i++) { if ( pluginDefault[i].pImpl ) continue; @@ -149,13 +141,6 @@ int LoadDefaultModules(void) return 1; } - if ( !pluginDefault[ 5].pImpl) if ( LoadHelpModule()) return 1; - if ( !pluginDefault[ 6].pImpl) if ( LoadHistoryModule()) return 1; - if ( !pluginDefault[ 7].pImpl) if ( LoadIdleModule()) return 1; - if ( !pluginDefault[ 8].pImpl) if ( LoadAutoAwayModule()) return 1; - if ( !pluginDefault[ 9].pImpl) if ( LoadUserOnlineModule()) return 1; - if ( !pluginDefault[10].pImpl) if ( LoadUpdateNotifyModule()) return 1; - return 0; } @@ -173,8 +158,6 @@ void UnloadDefaultModules(void) UnloadClcModule(); UnloadContactListModule(); UnloadEventsModule(); - UnloadIdleModule(); - UnloadUpdateNotifyModule(); UnloadNetlibModule(); UnloadSslModule(); } diff --git a/src/core/stdauth/main.cpp b/src/core/stdauth/main.cpp index cdb8d8e17b..ae1c5de1d0 100644 --- a/src/core/stdauth/main.cpp +++ b/src/core/stdauth/main.cpp @@ -1,6 +1,6 @@ /* -Standard URL plugin for Myranda IM +Standard Send/Recv Auth plugin for Myranda IM Copyright (C) 2012 George Hazan @@ -40,7 +40,7 @@ PLUGININFOEX pluginInfo = { { 0x8d0a046d, 0x8ea9, 0x4c55, {0xb5, 0x68, 0x38, 0xda, 0x52, 0x05, 0x64, 0xfd}} }; -static const MUUID interfaces[] = { MIID_SRURL, MIID_LAST }; +static const MUUID interfaces[] = { MIID_SRAUTH, MIID_LAST }; BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { diff --git a/src/core/stdauth/resource.rc b/src/core/stdauth/resource.rc index 3f7ef0c552..4d8b98858c 100644 --- a/src/core/stdauth/resource.rc +++ b/src/core/stdauth/resource.rc @@ -63,6 +63,8 @@ END // #ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN IDD_AUTHREQ, DIALOG BEGIN LEFTMARGIN, 7 @@ -77,6 +79,7 @@ END TOPMARGIN, 3 BOTTOMMARGIN, 65 END +END #endif // APSTUDIO_INVOKED diff --git a/src/core/stdauth/stdauth_10.vcxproj b/src/core/stdauth/stdauth_10.vcxproj index 1e21ce83a0..f6c97b9352 100644 --- a/src/core/stdauth/stdauth_10.vcxproj +++ b/src/core/stdauth/stdauth_10.vcxproj @@ -116,6 +116,7 @@ 4996;%(DisableSpecificWarnings) Use commonheaders.h + false _DEBUG;%(PreprocessorDefinitions) diff --git a/src/core/stdautoaway/autoaway.cpp b/src/core/stdautoaway/autoaway.cpp new file mode 100644 index 0000000000..a0906e22ec --- /dev/null +++ b/src/core/stdautoaway/autoaway.cpp @@ -0,0 +1,117 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/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 "commonheaders.h" + +#define AA_MODULE "AutoAway" + +static int iBreakSounds = 0; + +static int AutoAwaySound(WPARAM, LPARAM lParam) +{ + return iBreakSounds; +} + +/////////////////////////////////////////////////////////////////////////////// + +static bool Proto_IsAccountEnabled(PROTOACCOUNT* pa) +{ + return pa && ((pa->bIsEnabled && !pa->bDynDisabled) || pa->bOldProto); +} + +static bool Proto_IsAccountLocked(PROTOACCOUNT* pa) +{ + return pa && DBGetContactSettingByte(NULL, pa->szModuleName, "LockMainStatus", 0) != 0; +} + +static void Proto_SetStatus(const char* szProto, unsigned status) +{ + if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) { + TCHAR* awayMsg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGW, (WPARAM) status, (LPARAM) szProto); + if ((INT_PTR)awayMsg == CALLSERVICE_NOTFOUND) { + char* awayMsgA = (char*)CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM) status, (LPARAM) szProto); + if ((INT_PTR)awayMsgA != CALLSERVICE_NOTFOUND) { + awayMsg = mir_a2t(awayMsgA); + mir_free(awayMsgA); + } + } + if ((INT_PTR)awayMsg != CALLSERVICE_NOTFOUND) { + CallProtoService(szProto, PS_SETAWAYMSGT, status, (LPARAM) awayMsg); + mir_free(awayMsg); + } + } + + CallProtoService(szProto, PS_SETSTATUS, status, 0); +} + +static int AutoAwayEvent(WPARAM, LPARAM lParam) +{ + MIRANDA_IDLE_INFO mii; + mii.cbSize = sizeof(mii); + CallService(MS_IDLE_GETIDLEINFO, 0, (LPARAM)&mii); + if (mii.aaStatus == 0) + return 0; + + int numAccounts; + PROTOACCOUNT** accounts; + ProtoEnumAccounts(&numAccounts, &accounts); + + for (int i=0; i < numAccounts; i++) { + PROTOACCOUNT* pa = accounts[i]; + + if ( !Proto_IsAccountEnabled(pa) || Proto_IsAccountLocked(pa)) continue; + + int statusbits = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0); + int currentstatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); + int status = mii.aaStatus; + if ( !(statusbits & Proto_Status2Flag(status))) { + // the protocol doesnt support the given status + if (statusbits & Proto_Status2Flag(ID_STATUS_AWAY)) + status = ID_STATUS_AWAY; + // the proto doesnt support user mode or even away, bail. + else + continue; + } + if (currentstatus >= ID_STATUS_ONLINE && currentstatus != ID_STATUS_INVISIBLE) { + if ((lParam&IDF_ISIDLE) && (currentstatus == ID_STATUS_ONLINE || currentstatus == ID_STATUS_FREECHAT)) { + DBWriteContactSettingByte(NULL, AA_MODULE, pa->szModuleName, 1); + Proto_SetStatus(pa->szModuleName, status); + } + else if ( !(lParam & IDF_ISIDLE) && DBGetContactSettingByte(NULL, AA_MODULE, pa->szModuleName, 0)) { + // returning from idle and this proto was set away, set it back + DBWriteContactSettingByte(NULL, AA_MODULE, pa->szModuleName, 0); + if ( !mii.aaLock) + Proto_SetStatus(pa->szModuleName, ID_STATUS_ONLINE); + } } } + + if (mii.idlesoundsoff) + iBreakSounds = (lParam&IDF_ISIDLE) != 0; + + return 0; +} + +int LoadAutoAwayModule(void) +{ + HookEvent(ME_SKIN_PLAYINGSOUND, AutoAwaySound); + HookEvent(ME_IDLE_CHANGED, AutoAwayEvent); + return 0; +} diff --git a/src/core/stdautoaway/commonheaders.cpp b/src/core/stdautoaway/commonheaders.cpp new file mode 100644 index 0000000000..95b2201163 --- /dev/null +++ b/src/core/stdautoaway/commonheaders.cpp @@ -0,0 +1,2 @@ +#include "commonheaders.h" + diff --git a/src/core/stdautoaway/commonheaders.h b/src/core/stdautoaway/commonheaders.h new file mode 100644 index 0000000000..c9ed5a65d2 --- /dev/null +++ b/src/core/stdautoaway/commonheaders.h @@ -0,0 +1,93 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/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. +*/ + +// to enable all 0.9.0 core functions +#define MIRANDA_VER 0x0A00 + +#define WINVER 0x0700 +#define _WIN32_WINNT 0x0700 +#define _WIN32_IE 0x0601 + +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "version.h" + +#include "../../resource.h" +#include "../stdplug.h" + +extern HINSTANCE hInst; diff --git a/src/core/stdautoaway/main.cpp b/src/core/stdautoaway/main.cpp new file mode 100644 index 0000000000..ed5cea618c --- /dev/null +++ b/src/core/stdautoaway/main.cpp @@ -0,0 +1,72 @@ +/* + +Standard auto away module for Myranda IM + +Copyright (C) 2012 George Hazan + +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 "commonheaders.h" + +int LoadAutoAwayModule(void); + +HINSTANCE hInst; +int hLangpack; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + MIRANDA_VERSION_DWORD, + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // 9f5ca736-1108-4872-bec3-19c84bc2143b + { 0x9f5ca736, 0x1108, 0x4872, {0xbe, 0xc3, 0x19, 0xc8, 0x4b, 0xc2, 0x14, 0x3b}} +}; + +static const MUUID interfaces[] = { MIID_AUTOAWAY, MIID_LAST }; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + + LoadAutoAwayModule(); + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + return 0; +} diff --git a/src/core/stdautoaway/resource.rc b/src/core/stdautoaway/resource.rc new file mode 100644 index 0000000000..5bb57eb276 --- /dev/null +++ b/src/core/stdautoaway/resource.rc @@ -0,0 +1,66 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\..\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 +// + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN +END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\..\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/stdautoaway/stdautoaway_10.vcxproj b/src/core/stdautoaway/stdautoaway_10.vcxproj new file mode 100644 index 0000000000..9e974720b3 --- /dev/null +++ b/src/core/stdautoaway/stdautoaway_10.vcxproj @@ -0,0 +1,217 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + stdautoaway + {a8f23706-e590-4a87-96cc-5f8e5082503f} + + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + EditAndContinue + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + false + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/core/stdautoaway/stdautoaway_10.vcxproj.filters b/src/core/stdautoaway/stdautoaway_10.vcxproj.filters new file mode 100644 index 0000000000..70d31c369a --- /dev/null +++ b/src/core/stdautoaway/stdautoaway_10.vcxproj.filters @@ -0,0 +1,44 @@ + + + + + {5c074c9e-6c66-4233-bbd3-a50170fccf47} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {e30af2c4-42d4-4342-8eb9-2dbca157c6bb} + h;hpp;hxx;hm;inl + + + {9208a050-ffae-47fa-bc98-4ca4f79d37d7} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/src/core/stdautoaway/version.h b/src/core/stdautoaway/version.h new file mode 100644 index 0000000000..b60dd84efd --- /dev/null +++ b/src/core/stdautoaway/version.h @@ -0,0 +1,14 @@ + +#include + +#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION +#define __VERSION_STRING MIRANDA_VERSION_STRING + +#define __PLUGIN_NAME "stdautoaway" +#define __INTERNAL_NAME "stdautoaway" +#define __FILENAME "stdautoaway.dll" +#define __DESCRIPTION "Core module for away state processing." +#define __AUTHOR "Myranda team" +#define __AUTHOREMAIL "" +#define __AUTHORWEB "http://nightly.miranda.im" +#define __COPYRIGHT "© 2012 Myranda team" diff --git a/src/core/stdautoaway/version.rc b/src/core/stdautoaway/version.rc new file mode 100644 index 0000000000..e637f0cb33 --- /dev/null +++ b/src/core/stdautoaway/version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#include "afxres.h" +#include "version.h" + +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#endif //_WIN32 + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/src/core/stdemail/main.cpp b/src/core/stdemail/main.cpp index 87ac53085c..62deebb5b7 100644 --- a/src/core/stdemail/main.cpp +++ b/src/core/stdemail/main.cpp @@ -1,6 +1,6 @@ /* -Standard URL plugin for Myranda IM +Standard e-mail urls launcher for Myranda IM Copyright (C) 2012 George Hazan diff --git a/src/core/stdemail/resource.rc b/src/core/stdemail/resource.rc index 16f290a120..5bb57eb276 100644 --- a/src/core/stdemail/resource.rc +++ b/src/core/stdemail/resource.rc @@ -25,48 +25,6 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // Dialog // -IDD_URLRECV DIALOGEX 0, 0, 215, 140 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "URL Received" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - CONTROL "&Open URL",IDOK,"MButtonClass",WS_TABSTOP,11,120,57,14,WS_EX_NOACTIVATE | 0x10000000L - PUSHBUTTON "&Reply",IDC_REPLY,82,120,50,14 - PUSHBUTTON "&Close",IDCANCEL,148,120,50,14 - CONTROL "",IDC_PROTOCOL,"Button",BS_OWNERDRAW | WS_TABSTOP,5,7,12,12 - LTEXT "",IDC_NAME,19,7,118,9,SS_NOPREFIX | SS_CENTERIMAGE - CONTROL "&A",IDC_ADD,"MButtonClass",WS_TABSTOP,140,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "6",IDC_USERMENU,"MButtonClass",WS_TABSTOP,158,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "&D",IDC_DETAILS,"MButtonClass",WS_TABSTOP,176,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "&H",IDC_HISTORY,"MButtonClass",WS_TABSTOP,194,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - LTEXT "Date:",IDC_STATIC,5,21,29,8 - EDITTEXT IDC_DATE,34,21,176,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "URL:",IDC_STATIC,5,33,205,8 - EDITTEXT IDC_URL,5,43,205,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Description:",IDC_ST_ENTERMSG,5,60,205,8 - EDITTEXT IDC_MSG,5,70,205,44,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL -END - -IDD_URLSEND DIALOGEX 0, 0, 215, 126 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - COMBOBOX IDC_URLS,5,30,205,92,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_MESSAGE,5,57,205,44,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL - DEFPUSHBUTTON "&Send",IDOK,54,107,50,14 - PUSHBUTTON "&Cancel",IDCANCEL,113,107,50,14 - CONTROL "",IDC_PROTOCOL,"Button",BS_OWNERDRAW | WS_TABSTOP,5,7,12,12 - LTEXT "",IDC_NAME,19,7,118,9,SS_NOPREFIX | SS_CENTERIMAGE - CONTROL "&A",IDC_ADD,"MButtonClass",WS_TABSTOP,140,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "6",IDC_USERMENU,"MButtonClass",WS_TABSTOP,158,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "&D",IDC_DETAILS,"MButtonClass",WS_TABSTOP,176,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "&H",IDC_HISTORY,"MButtonClass",WS_TABSTOP,194,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - LTEXT "Enter URL:",IDC_ST_ENTERURL,5,20,205,8 - LTEXT "Enter description:",IDC_ST_ENTERMSG,5,47,205,8 -END - #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// @@ -75,21 +33,9 @@ END // #ifdef APSTUDIO_INVOKED - IDD_URLRECV, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 210 - TOPMARGIN, 5 - BOTTOMMARGIN, 135 - END - - IDD_URLSEND, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 210 - TOPMARGIN, 5 - BOTTOMMARGIN, 121 - END +GUIDELINES DESIGNINFO +BEGIN +END #endif // APSTUDIO_INVOKED diff --git a/src/core/stdemail/stdemail_10.vcxproj b/src/core/stdemail/stdemail_10.vcxproj index 029c0bef3f..1a0ecfb0f7 100644 --- a/src/core/stdemail/stdemail_10.vcxproj +++ b/src/core/stdemail/stdemail_10.vcxproj @@ -116,6 +116,7 @@ 4996;%(DisableSpecificWarnings) Use commonheaders.h + false _DEBUG;%(PreprocessorDefinitions) diff --git a/src/core/stdemail/version.h b/src/core/stdemail/version.h index 546634f19d..9e35b309b7 100644 --- a/src/core/stdemail/version.h +++ b/src/core/stdemail/version.h @@ -7,7 +7,7 @@ #define __PLUGIN_NAME "stdemail" #define __INTERNAL_NAME "stdemail" #define __FILENAME "stdemail.dll" -#define __DESCRIPTION "Core module for e-mail handling." +#define __DESCRIPTION "Core module for e-mail urls handling." #define __AUTHOR "Myranda team" #define __AUTHOREMAIL "" #define __AUTHORWEB "http://nightly.miranda.im" diff --git a/src/core/stdfile/main.cpp b/src/core/stdfile/main.cpp index ff38be0e8b..9a7330b7db 100644 --- a/src/core/stdfile/main.cpp +++ b/src/core/stdfile/main.cpp @@ -1,6 +1,6 @@ /* -Standard URL plugin for Myranda IM +Standard file transfers' plugin for Myranda IM Copyright (C) 2012 George Hazan @@ -41,8 +41,8 @@ PLUGININFOEX pluginInfo = { __COPYRIGHT, __AUTHORWEB, UNICODE_AWARE, - /* 8d0a046d-8ea9-4c55-b568-38da520564fd */ - { 0x8d0a046d, 0x8ea9, 0x4c55, {0xb5, 0x68, 0x38, 0xda, 0x52, 0x05, 0x64, 0xfd}} + // 39698dce-7ed4-4334-ac4c-ba8b37a86f13 + { 0x39698dce, 0x7ed4, 0x4334, {0xac, 0x4c, 0xba, 0x8b, 0x37, 0xa8, 0x6f, 0x13}} }; static const MUUID interfaces[] = { MIID_SRFILE, MIID_LAST }; diff --git a/src/core/stdfile/resource.rc b/src/core/stdfile/resource.rc index 10272edbbb..2d910b632b 100644 --- a/src/core/stdfile/resource.rc +++ b/src/core/stdfile/resource.rc @@ -197,6 +197,8 @@ END // #ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN IDD_FILESEND, DIALOG BEGIN LEFTMARGIN, 5 @@ -263,7 +265,7 @@ END VERTGUIDE, 8 VERTGUIDE, 302 END - +END #endif // APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED diff --git a/src/core/stdfile/stdfile_10.vcxproj b/src/core/stdfile/stdfile_10.vcxproj index 30433fab97..fe811b7524 100644 --- a/src/core/stdfile/stdfile_10.vcxproj +++ b/src/core/stdfile/stdfile_10.vcxproj @@ -116,6 +116,7 @@ 4996;%(DisableSpecificWarnings) Use commonheaders.h + false _DEBUG;%(PreprocessorDefinitions) diff --git a/src/core/stdfile/version.h b/src/core/stdfile/version.h index 244194696b..20dfde8e19 100644 --- a/src/core/stdfile/version.h +++ b/src/core/stdfile/version.h @@ -7,7 +7,7 @@ #define __PLUGIN_NAME "stdfile" #define __INTERNAL_NAME "stdfile" #define __FILENAME "stdfile.dll" -#define __DESCRIPTION "Core module for sending/receiving file transfer requests." +#define __DESCRIPTION "Core module for sending/receiving files." #define __AUTHOR "Myranda team" #define __AUTHOREMAIL "" #define __AUTHORWEB "http://nightly.miranda.im" diff --git a/src/core/stdhelp/about.cpp b/src/core/stdhelp/about.cpp new file mode 100644 index 0000000000..e1a2e24b4d --- /dev/null +++ b/src/core/stdhelp/about.cpp @@ -0,0 +1,144 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/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 "commonheaders.h" + +#define STR_VERSION_FORMAT "%s%S%S" + +INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static int iState = 0; + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + { TCHAR filename[MAX_PATH], *productCopyright; + DWORD unused; + DWORD verInfoSize; + UINT blockSize; + PVOID pVerInfo; + + GetModuleFileName(NULL, filename, SIZEOF(filename)); + verInfoSize = GetFileVersionInfoSize(filename, &unused); + pVerInfo = mir_alloc(verInfoSize); + GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo); + VerQueryValue(pVerInfo, _T("\\StringFileInfo\\000004b0\\LegalCopyright"), (LPVOID*)&productCopyright, &blockSize); + SetDlgItemText(hwndDlg, IDC_DEVS, productCopyright); + mir_free(pVerInfo); + } + { char productVersion[56], *p; + int isAnsi = 0; + TCHAR str[64]; + CallService(MS_SYSTEM_GETVERSIONTEXT, SIZEOF(productVersion), (LPARAM)productVersion); + // Hide Unicode from version text as it is assumed at this point + p = strstr(productVersion, " Unicode"); + if (p) + *p = '\0'; + else + isAnsi = 1; + mir_sntprintf(str, SIZEOF(str), _T(STR_VERSION_FORMAT), TranslateT("v"), productVersion, isAnsi?" ANSI":""); + { + TCHAR oldTitle[256], newTitle[256]; + GetDlgItemText(hwndDlg, IDC_HEADERBAR, oldTitle, SIZEOF(oldTitle)); + mir_sntprintf(newTitle, SIZEOF(newTitle), oldTitle, str); + SetDlgItemText(hwndDlg, IDC_HEADERBAR, newTitle); + } + + mir_sntprintf(str, SIZEOF(str), TranslateT("Built %s %s"), _T(__DATE__), _T(__TIME__)); + SetDlgItemText(hwndDlg, IDC_BUILDTIME, str); + } + ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_HIDE); + { + HRSRC hResInfo = FindResource(hInst, MAKEINTRESOURCE(IDR_CREDITS), _T("TEXT")); + DWORD ResSize = SizeofResource(hInst, hResInfo); + HGLOBAL hRes = LoadResource(hInst, hResInfo); + char* pszMsg = (char*)LockResource(hRes); + if (pszMsg) + { + char* pszMsgt = (char*)alloca(ResSize + 1); + memcpy(pszMsgt, pszMsg, ResSize); pszMsgt[ResSize] = 0; + + TCHAR *ptszMsg; + if (ResSize >=3 && pszMsgt[0] == '\xef' && pszMsgt[1] == '\xbb' && pszMsgt[2] == '\xbf') + ptszMsg = Utf8DecodeT(pszMsgt + 3); + else + ptszMsg = mir_a2t_cp(pszMsgt, 1252); + + SetDlgItemText(hwndDlg, IDC_CREDITSFILE, ptszMsg); + UnlockResource(pszMsg); + mir_free(ptszMsg); + } + FreeResource(hRes); + } + Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_MIRANDA); + return TRUE; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDOK: + case IDCANCEL: + DestroyWindow(hwndDlg); + return TRUE; + case IDC_CONTRIBLINK: + if (iState) { + iState = 0; + SetDlgItemText(hwndDlg, IDC_CONTRIBLINK, TranslateT("Credits >")); + ShowWindow(GetDlgItem(hwndDlg, IDC_DEVS), SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg, IDC_BUILDTIME), SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_HIDE); + } + else { + iState = 1; + SetDlgItemText(hwndDlg, IDC_CONTRIBLINK, TranslateT("< Copyright")); + ShowWindow(GetDlgItem(hwndDlg, IDC_DEVS), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_BUILDTIME), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_SHOW); + } + break; + } + break; + + case WM_CTLCOLOREDIT: + case WM_CTLCOLORSTATIC: + switch (GetWindowLongPtr((HWND)lParam, GWL_ID)) { + case IDC_WHITERECT: + case IDC_BUILDTIME: + case IDC_CREDITSFILE: + case IDC_DEVS: + SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); + break; + default: + return FALSE; + } + SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); + return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); + + case WM_DESTROY: + Window_FreeIcon_IcoLib(hwndDlg); + { + HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_VERSION, WM_GETFONT, 0, 0); + SendDlgItemMessage(hwndDlg, IDC_VERSION, WM_SETFONT, SendDlgItemMessage(hwndDlg, IDOK, WM_GETFONT, 0, 0), 0); + DeleteObject(hFont); + } + break; + } + return FALSE; +} diff --git a/src/core/stdhelp/commonheaders.cpp b/src/core/stdhelp/commonheaders.cpp new file mode 100644 index 0000000000..95b2201163 --- /dev/null +++ b/src/core/stdhelp/commonheaders.cpp @@ -0,0 +1,2 @@ +#include "commonheaders.h" + diff --git a/src/core/stdhelp/commonheaders.h b/src/core/stdhelp/commonheaders.h new file mode 100644 index 0000000000..af1784080f --- /dev/null +++ b/src/core/stdhelp/commonheaders.h @@ -0,0 +1,95 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/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. +*/ + +// to enable all 0.9.0 core functions +#define MIRANDA_VER 0x0A00 + +#define WINVER 0x0700 +#define _WIN32_WINNT 0x0700 +#define _WIN32_IE 0x0601 + +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "version.h" + +#include "../../resource.h" +#include "../stdplug.h" + +extern HINSTANCE hInst; + +#pragma comment(lib, "version.lib") diff --git a/src/core/stdhelp/help.cpp b/src/core/stdhelp/help.cpp new file mode 100644 index 0000000000..6bf91950ae --- /dev/null +++ b/src/core/stdhelp/help.cpp @@ -0,0 +1,116 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/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 "commonheaders.h" + +INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + +HWND hAboutDlg = NULL; +static HANDLE hBugEvent = NULL; + +static INT_PTR AboutCommand(WPARAM wParam, LPARAM) +{ + if (IsWindow(hAboutDlg)) { + SetForegroundWindow(hAboutDlg); + SetFocus(hAboutDlg); + return 0; + } + hAboutDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)wParam, DlgProcAbout); + return 0; +} + +static INT_PTR IndexCommand(WPARAM, LPARAM) +{ + CallService(MS_UTILS_OPENURL, 1, (LPARAM)Translate("http://wiki.miranda-im.org/")); + return 0; +} + +static INT_PTR WebsiteCommand(WPARAM, LPARAM) +{ + CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://www.miranda-im.org"); + return 0; +} + +static int BugCommandEvent(WPARAM wParam, LPARAM lParam) +{ + char *szUrl = (char*)lParam; + if (szUrl) + CallService(MS_UTILS_OPENURL, 1, (LPARAM)szUrl); + + return 0; +} + +static INT_PTR BugCommand(WPARAM, LPARAM) +{ + NotifyEventHooks(hBugEvent, 0, (LPARAM)"http://code.google.com/p/miranda/issues/list"); + return 0; +} + +int ShutdownHelpModule(WPARAM, LPARAM) +{ + if (IsWindow(hAboutDlg)) DestroyWindow(hAboutDlg); + hAboutDlg = NULL; + return 0; +} + +int LoadHelpModule(void) +{ + HookEvent(ME_SYSTEM_PRESHUTDOWN, ShutdownHelpModule); + + CreateServiceFunction("Help/AboutCommand", AboutCommand); + CreateServiceFunction("Help/IndexCommand", IndexCommand); + CreateServiceFunction("Help/WebsiteCommand", WebsiteCommand); + CreateServiceFunction("Help/BugCommand", BugCommand); + + hBugEvent = CreateHookableEvent(ME_HELP_BUGREPORT); + SetHookDefaultForHookableEvent(hBugEvent, BugCommandEvent); + + CLISTMENUITEM mi = { 0 }; + mi.cbSize = sizeof(mi); + mi.flags = CMIF_ICONFROMICOLIB; + mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_MIRANDA); + mi.pszPopupName = LPGEN("&Help"); + mi.popupPosition = 2000090000; + mi.position = 2000090000; + mi.pszName = LPGEN("&About..."); + mi.pszService = "Help/AboutCommand"; + Menu_AddMainMenuItem(&mi); + + mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_HELP); + mi.position = -500050000; + mi.pszName = LPGEN("&Support"); + mi.pszService = "Help/IndexCommand"; + Menu_AddMainMenuItem(&mi); + + mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_MIRANDAWEB); + mi.position = 2000050000; + mi.pszName = LPGEN("&Miranda IM Homepage"); + mi.pszService = "Help/WebsiteCommand"; + Menu_AddMainMenuItem(&mi); + + mi.icolibItem = GetSkinIconHandle(SKINICON_EVENT_URL); + mi.position = 2000040000; + mi.pszName = LPGEN("&Report Bug"); + mi.pszService = "Help/BugCommand"; + Menu_AddMainMenuItem(&mi); + return 0; +} diff --git a/src/core/stdhelp/main.cpp b/src/core/stdhelp/main.cpp new file mode 100644 index 0000000000..9760bac441 --- /dev/null +++ b/src/core/stdhelp/main.cpp @@ -0,0 +1,77 @@ +/* + +Standard Help/About plugin for Myranda IM + +Copyright (C) 2012 George Hazan + +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 "commonheaders.h" + +int LoadHelpModule(void); + +CLIST_INTERFACE* pcli; +TIME_API tmi; +HINSTANCE hInst; +int hLangpack; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + MIRANDA_VERSION_DWORD, + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // 1e64fd80-299e-48a0-9441-de2868563b6f + { 0x1e64fd80, 0x299e, 0x48a0, {0x94, 0x41, 0xde, 0x28, 0x68, 0x56, 0x3b, 0x6f}} +}; + +static const MUUID interfaces[] = { MIID_UIHELP, MIID_LAST }; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + mir_getTMI(&tmi); + + pcli = ( CLIST_INTERFACE* )CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, (LPARAM)hInst); + + LoadHelpModule(); + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + return 0; +} diff --git a/src/core/stdhelp/resource.rc b/src/core/stdhelp/resource.rc new file mode 100644 index 0000000000..eb5554a81c --- /dev/null +++ b/src/core/stdhelp/resource.rc @@ -0,0 +1,90 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\..\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_ABOUT DIALOGEX 0, 0, 212, 131 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "About Miranda IM" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + CONTROL "Miranda IM\n%s",IDC_HEADERBAR,"MHeaderbarCtrl",WS_TABSTOP,0,0,212,25 + LTEXT "",IDC_WHITERECT,0,25,213,81 + DEFPUSHBUTTON "OK",IDOK,152,112,55,14 + CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,106,213,1 + LTEXT "",IDC_DEVS,5,32,202,42 + EDITTEXT IDC_BUILDTIME,4,91,146,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + PUSHBUTTON "Credits >",IDC_CONTRIBLINK,5,112,55,14 + EDITTEXT IDC_CREDITSFILE,4,32,202,67,ES_CENTER | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL +END + + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ABOUT, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 207 + TOPMARGIN, 7 + BOTTOMMARGIN, 126 + END +END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\..\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/stdhelp/stdhelp_10.vcxproj b/src/core/stdhelp/stdhelp_10.vcxproj new file mode 100644 index 0000000000..8c87c825b5 --- /dev/null +++ b/src/core/stdhelp/stdhelp_10.vcxproj @@ -0,0 +1,218 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + stdhelp + {1c092ec9-0bcc-4c75-aae9-fcce9b3e9b3d} + + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + EditAndContinue + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + false + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/core/stdhelp/stdhelp_10.vcxproj.filters b/src/core/stdhelp/stdhelp_10.vcxproj.filters new file mode 100644 index 0000000000..476d1343f6 --- /dev/null +++ b/src/core/stdhelp/stdhelp_10.vcxproj.filters @@ -0,0 +1,47 @@ + + + + + {5c074c9e-6c66-4233-bbd3-a50170fccf47} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {e30af2c4-42d4-4342-8eb9-2dbca157c6bb} + h;hpp;hxx;hm;inl + + + {9208a050-ffae-47fa-bc98-4ca4f79d37d7} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/src/core/stdhelp/version.h b/src/core/stdhelp/version.h new file mode 100644 index 0000000000..3fd72e2d94 --- /dev/null +++ b/src/core/stdhelp/version.h @@ -0,0 +1,14 @@ + +#include + +#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION +#define __VERSION_STRING MIRANDA_VERSION_STRING + +#define __PLUGIN_NAME "stdhelp" +#define __INTERNAL_NAME "stdhelp" +#define __FILENAME "stdhelp.dll" +#define __DESCRIPTION "Core module for the Help/About dialog." +#define __AUTHOR "Myranda team" +#define __AUTHOREMAIL "" +#define __AUTHORWEB "http://nightly.miranda.im" +#define __COPYRIGHT "© 2012 Myranda team" diff --git a/src/core/stdhelp/version.rc b/src/core/stdhelp/version.rc new file mode 100644 index 0000000000..e637f0cb33 --- /dev/null +++ b/src/core/stdhelp/version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#include "afxres.h" +#include "version.h" + +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#endif //_WIN32 + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/src/core/stdidle/commonheaders.cpp b/src/core/stdidle/commonheaders.cpp new file mode 100644 index 0000000000..95b2201163 --- /dev/null +++ b/src/core/stdidle/commonheaders.cpp @@ -0,0 +1,2 @@ +#include "commonheaders.h" + diff --git a/src/core/stdidle/commonheaders.h b/src/core/stdidle/commonheaders.h new file mode 100644 index 0000000000..e63c553522 --- /dev/null +++ b/src/core/stdidle/commonheaders.h @@ -0,0 +1,105 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/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. +*/ + +// to enable all 0.9.0 core functions +#define MIRANDA_VER 0x0A00 + +#define WINVER 0x0700 +#define _WIN32_WINNT 0x0700 +#define _WIN32_IE 0x0601 + +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "version.h" + +#include "../../resource.h" +#include "../stdplug.h" + +extern HINSTANCE hInst; + +typedef HDESK (WINAPI* pfnOpenInputDesktop)(DWORD, BOOL, DWORD); +extern pfnOpenInputDesktop openInputDesktop; + +typedef HDESK (WINAPI* pfnCloseDesktop)(HDESK); +extern pfnCloseDesktop closeDesktop; + +typedef HMONITOR(WINAPI *pfnMyMonitorFromWindow) (HWND, DWORD); +extern pfnMyMonitorFromWindow MyMonitorFromWindow; + +typedef BOOL(WINAPI *pfnMyGetMonitorInfo) (HMONITOR, LPMONITORINFO); +extern pfnMyGetMonitorInfo MyGetMonitorInfo; diff --git a/src/core/stdidle/idle.cpp b/src/core/stdidle/idle.cpp new file mode 100644 index 0000000000..f725d5ecea --- /dev/null +++ b/src/core/stdidle/idle.cpp @@ -0,0 +1,523 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2005 Miranda ICQ/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 "commonheaders.h" + +#define IDLEMOD "Idle" +#define IDL_USERIDLECHECK "UserIdleCheck" +#define IDL_IDLEMETHOD "IdleMethod" +#define IDL_IDLETIME1ST "IdleTime1st" +#define IDL_IDLEONSAVER "IdleOnSaver" // IDC_SCREENSAVER +#define IDL_IDLEONFULLSCR "IdleOnFullScr" // IDC_FULLSCREEN +#define IDL_IDLEONLOCK "IdleOnLock" // IDC_LOCKED +#define IDL_IDLEONTSDC "IdleOnTerminalDisconnect" // +#define IDL_IDLEPRIVATE "IdlePrivate" // IDC_IDLEPRIVATE +#define IDL_IDLESTATUSLOCK "IdleStatusLock" // IDC_IDLESTATUSLOCK +#define IDL_AAENABLE "AAEnable" +#define IDL_AASTATUS "AAStatus" +#define IDL_IDLESOUNDSOFF "IdleSoundsOff" + +#define IdleObject_IsIdle(obj) (obj->state&0x1) +#define IdleObject_SetIdle(obj) (obj->state|=0x1) +#define IdleObject_ClearIdle(obj) (obj->state&=~0x1) + +// either use meth 0, 1 or figure out which one +#define IdleObject_UseMethod0(obj) (obj->state&=~0x2) +#define IdleObject_UseMethod1(obj) (obj->state|=0x2) +#define IdleObject_GetMethod(obj) (obj->state&0x2) + +#define IdleObject_IdleCheckSaver(obj) (obj->state&0x4) +#define IdleObject_SetSaverCheck(obj) (obj->state|=0x4) + +#define IdleObject_IdleCheckWorkstation(obj) (obj->state&0x8) +#define IdleObject_SetWorkstationCheck(obj) (obj->state|=0x8) + +#define IdleObject_IsPrivacy(obj) (obj->state&0x10) +#define IdleObject_SetPrivacy(obj) (obj->state|=0x10) + +#define IdleObject_SetStatusLock(obj) (obj->state|=0x20) + +#define IdleObject_IdleCheckTerminal(obj) (obj->state&0x40) +#define IdleObject_SetTerminalCheck(obj) (obj->state|=0x40) + +#define IdleObject_IdleCheckFullScr(obj) (obj->state&0x80) +#define IdleObject_SetFullScrCheck(obj) (obj->state|=0x80) + +//#include + +#ifndef _INC_WTSAPI + +#define WTS_CURRENT_SERVER_HANDLE ((HANDLE)NULL) +#define WTS_CURRENT_SESSION ((DWORD)-1) + +typedef enum _WTS_CONNECTSTATE_CLASS { + WTSActive, // User logged on to WinStation + WTSConnected, // WinStation connected to client + WTSConnectQuery, // In the process of connecting to client + WTSShadow, // Shadowing another WinStation + WTSDisconnected, // WinStation logged on without client + WTSIdle, // Waiting for client to connect + WTSListen, // WinStation is listening for connection + WTSReset, // WinStation is being reset + WTSDown, // WinStation is down due to error + WTSInit, // WinStation in initialization +} WTS_CONNECTSTATE_CLASS; + +typedef enum _WTS_INFO_CLASS { + WTSInitialProgram, + WTSApplicationName, + WTSWorkingDirectory, + WTSOEMId, + WTSSessionId, + WTSUserName, + WTSWinStationName, + WTSDomainName, + WTSConnectState, + WTSClientBuildNumber, + WTSClientName, + WTSClientDirectory, + WTSClientProductId, + WTSClientHardwareId, + WTSClientAddress, + WTSClientDisplay, + WTSClientProtocolType, +} WTS_INFO_CLASS; + +#endif + +VOID (WINAPI *_WTSFreeMemory)(PVOID); +BOOL (WINAPI *_WTSQuerySessionInformation)(HANDLE, DWORD, WTS_INFO_CLASS, PVOID, DWORD*); + +BOOL bIsWTSApiPresent = FALSE; + +static BOOL bModuleInitialized = FALSE; + +BOOL InitWTSAPI() +{ + HMODULE hDll = LoadLibraryA("wtsapi32.dll"); + if (hDll) { + _WTSFreeMemory = (VOID (WINAPI *)(PVOID))GetProcAddress(hDll, "WTSFreeMemory"); + _WTSQuerySessionInformation = (BOOL (WINAPI *)(HANDLE, DWORD, WTS_INFO_CLASS, PVOID, DWORD*))GetProcAddress(hDll, "WTSQuerySessionInformationW"); + + if (_WTSFreeMemory && _WTSQuerySessionInformation) return 1; + } + return 0; +} + +BOOL IsTerminalDisconnected() +{ + PVOID pBuffer = NULL; + DWORD pBytesReturned = 0; + BOOL result = FALSE; + + if ( !bIsWTSApiPresent) + return FALSE; + + if (_WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSConnectState, &pBuffer, &pBytesReturned)) { + if (*(PDWORD)pBuffer == WTSDisconnected) + result = TRUE; + } + else bIsWTSApiPresent = FALSE; + + if (pBuffer) + _WTSFreeMemory(pBuffer); + return result; +} + +typedef struct { + UINT_PTR hTimer; + unsigned int useridlecheck; + unsigned int state; + unsigned int minutes; // user setting, number of minutes of inactivity to wait for + POINT mousepos; + unsigned int mouseidle; + int aastatus; + int idleType; + int aasoundsoff; +} + IdleObject; + +static const WORD aa_Status[] = {ID_STATUS_AWAY, ID_STATUS_NA, ID_STATUS_OCCUPIED, ID_STATUS_DND, ID_STATUS_ONTHEPHONE, ID_STATUS_OUTTOLUNCH}; + +static IdleObject gIdleObject; +static HANDLE hIdleEvent; +static BOOL (WINAPI * MyGetLastInputInfo)(PLASTINPUTINFO); + +void CALLBACK IdleTimer(HWND hwnd, UINT umsg, UINT_PTR idEvent, DWORD dwTime); + +static void IdleObject_ReadSettings(IdleObject * obj) +{ + obj->useridlecheck = DBGetContactSettingByte(NULL, IDLEMOD, IDL_USERIDLECHECK, 0); + obj->minutes = DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLETIME1ST, 10); + obj->aastatus = !DBGetContactSettingByte(NULL, IDLEMOD, IDL_AAENABLE, 0) ? 0 : DBGetContactSettingWord(NULL, IDLEMOD, IDL_AASTATUS, 0); + if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLESOUNDSOFF, 1)) + obj->aasoundsoff = 1; + else + obj->aasoundsoff = 0; + if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEMETHOD, 0)) IdleObject_UseMethod1(obj); + else IdleObject_UseMethod0(obj); + if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONSAVER, 0)) IdleObject_SetSaverCheck(obj); + if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONFULLSCR, 0)) IdleObject_SetFullScrCheck(obj); + if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONLOCK, 0)) IdleObject_SetWorkstationCheck(obj); + if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEPRIVATE, 0)) IdleObject_SetPrivacy(obj); + if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLESTATUSLOCK, 0)) IdleObject_SetStatusLock(obj); + if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONTSDC, 0)) IdleObject_SetTerminalCheck(obj); +} + +static void IdleObject_Create(IdleObject * obj) +{ + ZeroMemory(obj, sizeof(IdleObject)); + obj->hTimer = SetTimer(NULL, 0, 2000, IdleTimer); + IdleObject_ReadSettings(obj); +} + +static void IdleObject_Destroy(IdleObject * obj) +{ + if (IdleObject_IsIdle(obj)) + NotifyEventHooks(hIdleEvent, 0, 0); + IdleObject_ClearIdle(obj); + KillTimer(NULL, obj->hTimer); +} + +static int IdleObject_IsUserIdle(IdleObject * obj) +{ + DWORD dwTick; + if (IdleObject_GetMethod(obj)) { + CallService(MS_SYSTEM_GETIDLE, 0, (LPARAM)&dwTick); + return GetTickCount() - dwTick > (obj->minutes * 60 * 1000); + } + + if (MyGetLastInputInfo != NULL) { + LASTINPUTINFO ii; + ZeroMemory(&ii, sizeof(ii)); + ii.cbSize = sizeof(ii); + if (MyGetLastInputInfo(&ii)) + return GetTickCount() - ii.dwTime > (obj->minutes * 60 * 1000); + } + else { + POINT pt; + GetCursorPos(&pt); + if (pt.x != obj->mousepos.x || pt.y != obj->mousepos.y) { + obj->mousepos = pt; + obj->mouseidle = 0; + } + else obj->mouseidle += 2; + + if (obj->mouseidle) + return obj->mouseidle * 1000 >= (obj->minutes * 60 * 1000); + } + return FALSE; +} + +static bool IsWorkstationLocked (void) +{ + bool rc = false; + + if (openInputDesktop != NULL) { + HDESK hDesk = openInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP); + if (hDesk == NULL) + rc = true; + else if (closeDesktop != NULL) + closeDesktop(hDesk); + } + return rc; +} + +static bool IsScreenSaverRunning(void) +{ + BOOL rc = FALSE; + SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &rc, FALSE); + return rc != 0; +} + +bool IsFullScreen(void) +{ + RECT rcScreen = {0}; + + rcScreen.right = GetSystemMetrics(SM_CXSCREEN); + rcScreen.bottom = GetSystemMetrics(SM_CYSCREEN); + + if (MyMonitorFromWindow) { + HMONITOR hMon = MyMonitorFromWindow(pcli->hwndContactList, MONITOR_DEFAULTTONEAREST); + MONITORINFO mi; + mi.cbSize = sizeof(mi); + if (MyGetMonitorInfo(hMon, &mi)) + rcScreen = mi.rcMonitor; + } + + HWND hWndDesktop = GetDesktopWindow(); + HWND hWndShell = GetShellWindow(); + + // check foregroundwindow + HWND hWnd = GetForegroundWindow(); + if (hWnd && hWnd != hWndDesktop && hWnd != hWndShell) + { + TCHAR tszClassName[128] = _T(""); + GetClassName(hWnd, tszClassName, SIZEOF(tszClassName)); + if (_tcscmp(tszClassName, _T("WorkerW"))) + { + RECT rect, rectw, recti; + GetWindowRect(hWnd, &rectw); + + GetClientRect(hWnd, &rect); + ClientToScreen(hWnd, (LPPOINT)&rect); + ClientToScreen(hWnd, (LPPOINT)&rect.right); + + if (EqualRect(&rect, &rectw) && IntersectRect(&recti, &rect, &rcScreen) && + EqualRect(&recti, &rcScreen)) + return true; + } + } + + return false; +} + +static void IdleObject_Tick(IdleObject * obj) +{ + bool idle = false; + int idleType = 0, flags = 0; + + if (obj->useridlecheck && IdleObject_IsUserIdle(obj)) { + idleType = 1; idle = true; + } + else if (IdleObject_IdleCheckSaver(obj) && IsScreenSaverRunning()) { + idleType = 2; idle = true; + } + else if (IdleObject_IdleCheckFullScr(obj) && IsFullScreen()) { + idleType = 5; idle = true; + } + else if (IdleObject_IdleCheckWorkstation(obj) && IsWorkstationLocked()) { + idleType = 3; idle = true; + } + else if (IdleObject_IdleCheckTerminal(obj) && IsTerminalDisconnected()) { + idleType = 4; idle = true; + } + + if (IdleObject_IsPrivacy(obj)) + flags |= IDF_PRIVACY; + + if ( !IdleObject_IsIdle(obj) && idle) { + IdleObject_SetIdle(obj); + obj->idleType = idleType; + NotifyEventHooks(hIdleEvent, 0, IDF_ISIDLE | flags); + } + if (IdleObject_IsIdle(obj) && !idle) { + IdleObject_ClearIdle(obj); + obj->idleType = 0; + NotifyEventHooks(hIdleEvent, 0, flags); +} } + +void CALLBACK IdleTimer(HWND, UINT, UINT_PTR idEvent, DWORD) +{ + if (gIdleObject.hTimer == idEvent) + IdleObject_Tick(&gIdleObject); +} + +int IdleGetStatusIndex(WORD status) +{ + int j; + for (j = 0; j < SIZEOF(aa_Status); j++) + if (aa_Status[j] == status) + return j; + + return 0; +} + +static INT_PTR CALLBACK IdleOptsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) { + case WM_INITDIALOG: + { + int j; + int method = DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEMETHOD, 0); + TranslateDialogDefault(hwndDlg); + CheckDlgButton(hwndDlg, IDC_IDLESHORT, DBGetContactSettingByte(NULL, IDLEMOD, IDL_USERIDLECHECK, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_IDLEONWINDOWS, method == 0 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_IDLEONMIRANDA, method ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_SCREENSAVER, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONSAVER, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_FULLSCREEN, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONFULLSCR, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_LOCKED, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONLOCK, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_IDLEPRIVATE, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEPRIVATE, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_IDLESTATUSLOCK, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLESTATUSLOCK, 0) ? BST_CHECKED : BST_UNCHECKED); + if ( !bIsWTSApiPresent) + EnableWindow(GetDlgItem(hwndDlg, IDC_IDLETERMINAL), FALSE); + else + CheckDlgButton(hwndDlg, IDC_IDLETERMINAL, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONTSDC, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_IDLESOUNDSOFF, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLESOUNDSOFF, 1) ? BST_CHECKED : BST_UNCHECKED); + SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_IDLE1STTIME), 0); + SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETRANGE32, 1, 60); + SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETPOS, 0, MAKELONG((short) DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLETIME1ST, 10), 0)); + SendDlgItemMessage(hwndDlg, IDC_IDLE1STTIME, EM_LIMITTEXT, (WPARAM)2, 0); + + CheckDlgButton(hwndDlg, IDC_AASHORTIDLE, DBGetContactSettingByte(NULL, IDLEMOD, IDL_AAENABLE, 0) ? BST_CHECKED:BST_UNCHECKED); + for (j = 0; j < SIZEOF(aa_Status); j++) + SendDlgItemMessage(hwndDlg, IDC_AASTATUS, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(aa_Status[j], 0)); + + j = IdleGetStatusIndex((WORD)(DBGetContactSettingWord(NULL, IDLEMOD, IDL_AASTATUS, 0))); + SendDlgItemMessage(hwndDlg, IDC_AASTATUS, CB_SETCURSEL, j, 0); + SendMessage(hwndDlg, WM_USER+2, 0, 0); + return TRUE; + } + case WM_USER+2: + { + BOOL checked = IsDlgButtonChecked(hwndDlg, IDC_IDLESHORT) == BST_CHECKED; + EnableWindow(GetDlgItem(hwndDlg, IDC_IDLEONWINDOWS), checked); + EnableWindow(GetDlgItem(hwndDlg, IDC_IDLEONMIRANDA), checked); + EnableWindow(GetDlgItem(hwndDlg, IDC_IDLE1STTIME), checked); + EnableWindow(GetDlgItem(hwndDlg, IDC_AASTATUS), IsDlgButtonChecked(hwndDlg, IDC_AASHORTIDLE) == BST_CHECKED?1:0); + EnableWindow(GetDlgItem(hwndDlg, IDC_IDLESTATUSLOCK), IsDlgButtonChecked(hwndDlg, IDC_AASHORTIDLE) == BST_CHECKED?1:0); + break; + } + case WM_NOTIFY: + { + NMHDR * hdr = (NMHDR *)lParam; + if (hdr && hdr->code == PSN_APPLY) { + int method = IsDlgButtonChecked(hwndDlg, IDC_IDLEONWINDOWS) == BST_CHECKED; + int mins = SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_GETPOS, 0, 0); + DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLETIME1ST, (BYTE)(HIWORD(mins) == 0 ? LOWORD(mins) : 10)); + DBWriteContactSettingByte(NULL, IDLEMOD, IDL_USERIDLECHECK, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLESHORT) == BST_CHECKED)); + DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEMETHOD, (BYTE)(method ? 0 : 1)); + DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEONSAVER, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_SCREENSAVER) == BST_CHECKED)); + DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEONFULLSCR, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_FULLSCREEN) == BST_CHECKED)); + DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEONLOCK, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_LOCKED) == BST_CHECKED)); + DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEONTSDC, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLETERMINAL) == BST_CHECKED)); + DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEPRIVATE, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLEPRIVATE) == BST_CHECKED)); + DBWriteContactSettingByte(NULL, IDLEMOD, IDL_AAENABLE, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_AASHORTIDLE) == BST_CHECKED?1:0)); + DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLESTATUSLOCK, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLESTATUSLOCK) == BST_CHECKED?1:0)); + { + int curSel = SendDlgItemMessage(hwndDlg, IDC_AASTATUS, CB_GETCURSEL, 0, 0); + if (curSel != CB_ERR) { + DBWriteContactSettingWord(NULL, IDLEMOD, IDL_AASTATUS, (WORD)(aa_Status[curSel])); + } + } + DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLESOUNDSOFF, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLESOUNDSOFF) == BST_CHECKED)); + // destroy any current idle and reset settings. + IdleObject_Destroy(&gIdleObject); + IdleObject_Create(&gIdleObject); + } + break; + } + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDC_IDLE1STTIME: + { + int min; + if ((HWND)lParam != GetFocus() || HIWORD(wParam) != EN_CHANGE) return FALSE; + min = GetDlgItemInt(hwndDlg, IDC_IDLE1STTIME, NULL, FALSE); + if (min == 0 && GetWindowTextLength(GetDlgItem(hwndDlg, IDC_IDLE1STTIME))) + SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETPOS, 0, MAKELONG((short) 1, 0)); + break; + } + case IDC_IDLESHORT: + case IDC_AASHORTIDLE: + SendMessage(hwndDlg, WM_USER+2, 0, 0); + break; + + case IDC_AASTATUS: + if (HIWORD(wParam) != CBN_SELCHANGE) + return TRUE; + } + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + return FALSE; +} + +static int IdleOptInit(WPARAM wParam, LPARAM) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); + odp.position = 100000000; + odp.hInstance = hInst; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_IDLE); + odp.pszGroup = LPGEN("Status"); + odp.pszTitle = LPGEN("Idle"); + odp.pfnDlgProc = IdleOptsDlgProc; + odp.flags = ODPF_BOLDGROUPS; + Options_AddPage(wParam, &odp); + return 0; +} + +static INT_PTR IdleGetInfo(WPARAM, LPARAM lParam) +{ + MIRANDA_IDLE_INFO *mii = (MIRANDA_IDLE_INFO*)lParam; + if ( !mii || (mii->cbSize != sizeof(MIRANDA_IDLE_INFO) && mii->cbSize != MIRANDA_IDLE_INFO_SIZE_1)) + return 1; + + mii->idleTime = gIdleObject.minutes; + mii->privacy = gIdleObject.state&0x10; + mii->aaStatus = gIdleObject.aastatus; + mii->aaLock = gIdleObject.state&0x20; + mii->idlesoundsoff = gIdleObject.aasoundsoff; + + if (mii->cbSize == sizeof(MIRANDA_IDLE_INFO)) + mii->idleType = gIdleObject.idleType; + return 0; +} + +static int IdleModernOptInit(WPARAM wParam, LPARAM) +{ + static const int iBoldControls[] = + { + IDC_TXT_TITLE1, IDC_TXT_TITLE2, IDC_TXT_TITLE3, + MODERNOPT_CTRL_LAST + }; + + MODERNOPTOBJECT obj = {0}; + obj.cbSize = sizeof(obj); + obj.hInstance = hInst; + obj.dwFlags = MODEROPT_FLG_TCHAR | MODEROPT_FLG_NORESIZE; + obj.iSection = MODERNOPT_PAGE_STATUS; + obj.iType = MODERNOPT_TYPE_SECTIONPAGE; + obj.iBoldControls = (int*)iBoldControls; + obj.lpzTemplate = MAKEINTRESOURCEA(IDD_MODERNOPT_IDLE); + obj.pfnDlgProc = IdleOptsDlgProc; +// obj.lpzClassicGroup = "Status"; +// obj.lpzClassicPage = "Messages"; + obj.lpzHelpUrl = "http://wiki.miranda-im.org/"; + CallService(MS_MODERNOPT_ADDOBJECT, wParam, (LPARAM)&obj); + return 0; +} + +int LoadIdleModule(void) +{ + bModuleInitialized = TRUE; + + bIsWTSApiPresent = InitWTSAPI(); + MyGetLastInputInfo = (BOOL (WINAPI *)(LASTINPUTINFO*))GetProcAddress(GetModuleHandleA("user32"), "GetLastInputInfo"); + hIdleEvent = CreateHookableEvent(ME_IDLE_CHANGED); + IdleObject_Create(&gIdleObject); + CreateServiceFunction(MS_IDLE_GETIDLEINFO, IdleGetInfo); + HookEvent(ME_OPT_INITIALISE, IdleOptInit); + HookEvent(ME_MODERNOPT_INITIALIZE, IdleModernOptInit); + return 0; +} + +void UnloadIdleModule() +{ + if ( !bModuleInitialized) return; + + IdleObject_Destroy(&gIdleObject); + DestroyHookableEvent(hIdleEvent); + hIdleEvent = NULL; +} diff --git a/src/core/stdidle/main.cpp b/src/core/stdidle/main.cpp new file mode 100644 index 0000000000..6845f61813 --- /dev/null +++ b/src/core/stdidle/main.cpp @@ -0,0 +1,91 @@ +/* + +Standard idle state module for Myranda IM + +Copyright (C) 2012 George Hazan + +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 "commonheaders.h" + +int LoadIdleModule(void); +void UnloadIdleModule(void); + +CLIST_INTERFACE* pcli; +TIME_API tmi; +HINSTANCE hInst; +int hLangpack; + +pfnMyMonitorFromWindow MyMonitorFromWindow; +pfnMyGetMonitorInfo MyGetMonitorInfo; +pfnOpenInputDesktop openInputDesktop; +pfnCloseDesktop closeDesktop; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + MIRANDA_VERSION_DWORD, + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // 53ac190b-e223-4341-825f-709d8520215b + { 0x53ac190b, 0xe223, 0x4341, {0x82, 0x5f, 0x70, 0x9d, 0x85, 0x20, 0x21, 0x5b}} +}; + +static const MUUID interfaces[] = { MIID_IDLE, MIID_LAST }; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + mir_getTMI(&tmi); + + HINSTANCE hUser32 = GetModuleHandleA("user32"); + openInputDesktop = (pfnOpenInputDesktop)GetProcAddress (hUser32, "OpenInputDesktop"); + closeDesktop = (pfnCloseDesktop)GetProcAddress (hUser32, "CloseDesktop"); + + MyMonitorFromWindow = (pfnMyMonitorFromWindow)GetProcAddress(hUser32, "MonitorFromWindow"); + MyGetMonitorInfo = (pfnMyGetMonitorInfo)GetProcAddress(hUser32, "GetMonitorInfoW"); + + pcli = ( CLIST_INTERFACE* )CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, (LPARAM)hInst); + + LoadIdleModule(); + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + UnloadIdleModule(); + return 0; +} diff --git a/src/core/stdidle/resource.rc b/src/core/stdidle/resource.rc new file mode 100644 index 0000000000..eac9ca8f20 --- /dev/null +++ b/src/core/stdidle/resource.rc @@ -0,0 +1,134 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\..\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 | WS_BORDER +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_WRAP | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,71,55,12,23 + 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 (2000/XP+ only)",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,91,61,76,9 + RTEXT "for",IDC_STATIC,12,59,41,9 + 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 + +IDD_MODERNOPT_IDLE DIALOGEX 0, 0, 369, 64 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + CONTROL "Become idle if computer is left unattended for:",IDC_IDLESHORT, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,13,171,9 + CONTROL "Windows",IDC_IDLEONWINDOWS,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE,325,25,26,9 + CONTROL "Miranda",IDC_IDLEONMIRANDA,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE,287,37,15,9 + EDITTEXT IDC_IDLE1STTIME,181,11,27,12,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_IDLESPIN,"msctls_updown32",UDS_WRAP | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,193,7,11,23 + CONTROL "Become idle if the screen saver is active",IDC_SCREENSAVER, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,25,268,9 + CONTROL "Become idle if the computer is locked (2000/XP+ only)",IDC_LOCKED, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,37,249,9 + CONTROL "Become idle if a terminal session is disconnected",IDC_IDLETERMINAL, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,49,265,10 + CONTROL "Do not let protocols report any idle information",IDC_IDLEPRIVATE, + "Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,303,13,22,9 + LTEXT "minute(s)",IDC_STATIC,213,13,76,9,SS_CENTERIMAGE + COMBOBOX IDC_AASTATUS,325,46,23,50,CBS_DROPDOWNLIST | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP + CONTROL "Change my status mode to:",IDC_AASHORTIDLE,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,334,11,23,11 + CONTROL "Do not set status back to online when returning from idle",IDC_IDLESTATUSLOCK, + "Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,299,24,16,10 + LTEXT "Idle (auto-away):",IDC_TXT_TITLE1,0,0,246,8 +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_MODERNOPT_IDLE, DIALOG + BEGIN + VERTGUIDE, 10 + VERTGUIDE, 181 + HORZGUIDE, 8 + HORZGUIDE, 22 + HORZGUIDE, 34 + HORZGUIDE, 46 + END +END + +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\..\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/stdidle_10.vcxproj b/src/core/stdidle/stdidle_10.vcxproj new file mode 100644 index 0000000000..91c3f48b7a --- /dev/null +++ b/src/core/stdidle/stdidle_10.vcxproj @@ -0,0 +1,217 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + stdidle + {36c40ba6-e0b5-438a-919c-6a991933b313} + + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + EditAndContinue + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + false + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/core/stdidle/stdidle_10.vcxproj.filters b/src/core/stdidle/stdidle_10.vcxproj.filters new file mode 100644 index 0000000000..c77e259559 --- /dev/null +++ b/src/core/stdidle/stdidle_10.vcxproj.filters @@ -0,0 +1,44 @@ + + + + + {5c074c9e-6c66-4233-bbd3-a50170fccf47} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {e30af2c4-42d4-4342-8eb9-2dbca157c6bb} + h;hpp;hxx;hm;inl + + + {9208a050-ffae-47fa-bc98-4ca4f79d37d7} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/src/core/stdidle/version.h b/src/core/stdidle/version.h new file mode 100644 index 0000000000..420cdcafc3 --- /dev/null +++ b/src/core/stdidle/version.h @@ -0,0 +1,14 @@ + +#include + +#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION +#define __VERSION_STRING MIRANDA_VERSION_STRING + +#define __PLUGIN_NAME "stdidle" +#define __INTERNAL_NAME "stdidle" +#define __FILENAME "stdidle.dll" +#define __DESCRIPTION "Core module for idle state processing." +#define __AUTHOR "Myranda team" +#define __AUTHOREMAIL "" +#define __AUTHORWEB "http://nightly.miranda.im" +#define __COPYRIGHT "© 2012 Myranda team" diff --git a/src/core/stdidle/version.rc b/src/core/stdidle/version.rc new file mode 100644 index 0000000000..e637f0cb33 --- /dev/null +++ b/src/core/stdidle/version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#include "afxres.h" +#include "version.h" + +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#endif //_WIN32 + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/src/core/stduihist/commonheaders.cpp b/src/core/stduihist/commonheaders.cpp new file mode 100644 index 0000000000..95b2201163 --- /dev/null +++ b/src/core/stduihist/commonheaders.cpp @@ -0,0 +1,2 @@ +#include "commonheaders.h" + diff --git a/src/core/stduihist/commonheaders.h b/src/core/stduihist/commonheaders.h new file mode 100644 index 0000000000..af1784080f --- /dev/null +++ b/src/core/stduihist/commonheaders.h @@ -0,0 +1,95 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/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. +*/ + +// to enable all 0.9.0 core functions +#define MIRANDA_VER 0x0A00 + +#define WINVER 0x0700 +#define _WIN32_WINNT 0x0700 +#define _WIN32_IE 0x0601 + +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "version.h" + +#include "../../resource.h" +#include "../stdplug.h" + +extern HINSTANCE hInst; + +#pragma comment(lib, "version.lib") diff --git a/src/core/stduihist/history.cpp b/src/core/stduihist/history.cpp new file mode 100644 index 0000000000..9fb174d5c3 --- /dev/null +++ b/src/core/stduihist/history.cpp @@ -0,0 +1,430 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/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 "commonheaders.h" + +#define SUMMARY 0 +#define DETAIL 1 +#define DM_FINDNEXT (WM_USER+10) +#define DM_HREBUILD (WM_USER+11) + +static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +static INT_PTR CALLBACK DlgProcHistoryFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +static HANDLE hWindowList = 0; + +///////////////////////////////////////////////////////////////////////////////////////// +// Fills the events list + +static void GetMessageDescription(DBEVENTINFO *dbei, TCHAR* buf, int cbBuf) +{ + TCHAR* msg = DbGetEventTextT(dbei, CP_ACP); + _tcsncpy(buf, msg ? msg : TranslateT("Invalid Message"), cbBuf); + buf[ cbBuf-1 ] = 0; + mir_free(msg); +} + +static void GetUrlDescription(DBEVENTINFO *dbei, TCHAR* buf, int cbBuf) +{ + int len = dbei->cbBlob; + if (len >= cbBuf) + len = cbBuf-1; + + MultiByteToWideChar(CP_ACP, 0, (LPCSTR)dbei->pBlob, len, buf, cbBuf); + buf[ len ] = 0; + + if (len < cbBuf-3) + _tcscat(buf, _T("\r\n")); +} + +static void GetFileDescription(DBEVENTINFO *dbei, TCHAR* buf, int cbBuf) +{ + int len = dbei->cbBlob - sizeof(DWORD); + if (len >= cbBuf) + len = cbBuf-1; + + MultiByteToWideChar(CP_ACP, 0, (LPCSTR)dbei->pBlob + sizeof(DWORD), len, buf, cbBuf); + buf[ len ] = 0; + + if (len < cbBuf-3) + _tcscat(buf, _T("\r\n")); +} + +static void GetObjectDescription(DBEVENTINFO *dbei, TCHAR* str, int cbStr) +{ + switch(dbei->eventType) { + case EVENTTYPE_MESSAGE: + GetMessageDescription(dbei, str, cbStr); + break; + + case EVENTTYPE_URL: + GetUrlDescription(dbei, str, cbStr); + break; + + case EVENTTYPE_FILE: + GetFileDescription(dbei, str, cbStr); + break; + + default: + { + DBEVENTTYPEDESCR* et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); + if (et && (et->flags & DETF_HISTORY)) { + GetMessageDescription(dbei, str, cbStr); + } + else + str[ 0 ] = 0; +} } } + +static void GetObjectSummary(DBEVENTINFO *dbei, TCHAR* str, int cbStr) +{ + TCHAR* pszSrc, *pszTmp = NULL; + + switch(dbei->eventType) { + case EVENTTYPE_MESSAGE: + if (dbei->flags & DBEF_SENT) pszSrc = TranslateT("Outgoing Message"); + else pszSrc = TranslateT("Incoming Message"); + break; + + case EVENTTYPE_URL: + if (dbei->flags & DBEF_SENT) pszSrc = TranslateT("Outgoing URL"); + else pszSrc = TranslateT("Incoming URL"); + break; + + case EVENTTYPE_FILE: + if (dbei->flags & DBEF_SENT) pszSrc = TranslateT("Outgoing File"); + else pszSrc = TranslateT("Incoming File"); + break; + + default: + { + DBEVENTTYPEDESCR* et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); + if (et && (et->flags & DETF_HISTORY)) { + pszTmp = mir_a2t(et->descr); + pszSrc = TranslateTS(pszTmp); + break; + } + else { + str[ 0 ] = 0; + return; + } } } + + _tcsncpy(str, (const TCHAR*)pszSrc, cbStr); + str[ cbStr-1 ] = 0; + + mir_free(pszTmp); +} + +typedef struct { + HANDLE hContact; + HWND hwnd; +} THistoryThread; + +static void FillHistoryThread(void* param) +{ + Thread_SetName("HistoryWindow::FillHistoryThread"); + + TCHAR str[200], eventText[256], strdatetime[64]; + HANDLE hDbEvent; + DBEVENTINFO dbei; + int newBlobSize, oldBlobSize, i; + HWND hwndList; + THistoryThread *hInfo = (THistoryThread*)param; + + SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_RESETCONTENT, 0, 0); + i = CallService(MS_DB_EVENT_GETCOUNT, (WPARAM)hInfo->hContact, 0); + SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_INITSTORAGE, i, i*40); + + ZeroMemory(&dbei, sizeof(dbei)); + dbei.cbSize = sizeof(dbei); + oldBlobSize = 0; + hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hInfo->hContact, 0); + hwndList = GetDlgItem(hInfo->hwnd, IDC_LIST); + while (hDbEvent != NULL) { + if ( !IsWindow(hInfo->hwnd)) + break; + newBlobSize = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); + if (newBlobSize>oldBlobSize) { + dbei.pBlob = (PBYTE)mir_realloc(dbei.pBlob, newBlobSize); + oldBlobSize = newBlobSize; + } + dbei.cbBlob = oldBlobSize; + CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); + GetObjectSummary(&dbei, str, SIZEOF(str)); + if (str[0]) { + tmi.printTimeStamp(NULL, dbei.timestamp, _T("d t"), strdatetime, SIZEOF(strdatetime), 0); + mir_sntprintf(eventText, SIZEOF(eventText), _T("%s: %s"), strdatetime, str); + i = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)eventText); + SendMessage(hwndList, LB_SETITEMDATA, i, (LPARAM)hDbEvent); + } + hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0); + } + mir_free(dbei.pBlob); + + SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_SETCURSEL, 0, 0); + SendMessage(hInfo->hwnd, WM_COMMAND, MAKEWPARAM(IDC_LIST, LBN_SELCHANGE), 0); + EnableWindow(GetDlgItem(hInfo->hwnd, IDC_LIST), TRUE); + mir_free(hInfo); +} + +static int HistoryDlgResizer(HWND, LPARAM, UTILRESIZECONTROL *urc) +{ + switch(urc->wId) { + case IDC_LIST: + return RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT; + case IDC_EDIT: + return RD_ANCHORX_WIDTH|RD_ANCHORY_BOTTOM; + case IDC_FIND: + case IDC_DELETEHISTORY: + return RD_ANCHORX_LEFT|RD_ANCHORY_BOTTOM; + case IDOK: + return RD_ANCHORX_RIGHT|RD_ANCHORY_BOTTOM; + } + return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; +} + +static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + HANDLE hContact; + + hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); + hContact = (HANDLE)lParam; + WindowList_Add(hWindowList, hwndDlg, hContact); + Utils_RestoreWindowPosition(hwndDlg, hContact, "History", ""); + { + TCHAR* contactName, str[200]; + contactName = pcli->pfnGetContactDisplayName(hContact, 0); + mir_sntprintf(str, SIZEOF(str), TranslateT("History for %s"), contactName); + SetWindowText(hwndDlg, str); + } + Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_HISTORY); + SendMessage(hwndDlg, DM_HREBUILD, 0, 0); + return TRUE; + + case DM_HREBUILD: + { + THistoryThread* hInfo = (THistoryThread*)mir_alloc(sizeof(THistoryThread)); + EnableWindow(GetDlgItem(hwndDlg, IDC_LIST), FALSE); + hInfo->hContact = hContact; + hInfo->hwnd = hwndDlg; + forkthread(FillHistoryThread, 0, hInfo); + } + return TRUE; + + case WM_DESTROY: + Window_FreeIcon_IcoLib(hwndDlg); + Utils_SaveWindowPosition(hwndDlg, hContact, "History", ""); + WindowList_Remove(hWindowList, hwndDlg); + return TRUE; + + case WM_GETMINMAXINFO: + ((MINMAXINFO*)lParam)->ptMinTrackSize.x = 300; + ((MINMAXINFO*)lParam)->ptMinTrackSize.y = 230; + + case WM_SIZE: + { + UTILRESIZEDIALOG urd = {0}; + urd.cbSize = sizeof(urd); + urd.hwndDlg = hwndDlg; + urd.hInstance = hInst; + urd.lpTemplate = MAKEINTRESOURCEA(IDD_HISTORY); + urd.lParam = (LPARAM)NULL; + urd.pfnResizer = HistoryDlgResizer; + CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); + return TRUE; + } + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDOK: + case IDCANCEL: + DestroyWindow(hwndDlg); + return TRUE; + + case IDC_FIND: + ShowWindow(CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_HISTORY_FIND), hwndDlg, DlgProcHistoryFind, (LPARAM)hwndDlg), SW_SHOW); + return TRUE; + + case IDC_DELETEHISTORY: + { + HANDLE hDbevent; + int index = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0); + if (index == LB_ERR) + break; + + if (MessageBox(hwndDlg, TranslateT("Are you sure you want to delete this history item?"), TranslateT("Delete History"), MB_YESNO|MB_ICONQUESTION) == IDYES) { + hDbevent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, index, 0); + CallService(MS_DB_EVENT_DELETE, (WPARAM)hContact, (LPARAM)hDbevent); + SendMessage(hwndDlg, DM_HREBUILD, 0, 0); + } + return TRUE; + } + case IDC_LIST: + if (HIWORD(wParam) == LBN_SELCHANGE) { + TCHAR str[8192], *contactName; + HANDLE hDbEvent; + DBEVENTINFO dbei; + int sel; + sel = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0); + if (sel == LB_ERR) { EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), FALSE); break; } + EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), TRUE); + contactName = pcli->pfnGetContactDisplayName(hContact, 0); + hDbEvent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, sel, 0); + ZeroMemory(&dbei, sizeof(dbei)); + dbei.cbSize = sizeof(dbei); + dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); + if ((int)dbei.cbBlob != -1) + { + dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); + if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei) == 0) + { + GetObjectDescription(&dbei, str, SIZEOF(str)); + if (str[0]) + SetDlgItemText(hwndDlg, IDC_EDIT, str); + } + mir_free(dbei.pBlob); + } + } + return TRUE; + } + break; + case DM_FINDNEXT: + { + TCHAR str[1024]; + HANDLE hDbEvent, hDbEventStart; + DBEVENTINFO dbei; + int newBlobSize, oldBlobSize; + + int index = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0); + if (index == LB_ERR) + break; + + hDbEventStart = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, index, 0); + ZeroMemory(&dbei, sizeof(dbei)); + dbei.cbSize = sizeof(dbei); + dbei.pBlob = NULL; + oldBlobSize = 0; + for (;;) { + hDbEvent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, ++index, 0); + if (hDbEvent == (HANDLE)LB_ERR) { + index = -1; + continue; + } + if (hDbEvent == hDbEventStart) break; + newBlobSize = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); + if (newBlobSize>oldBlobSize) { + dbei.pBlob = (PBYTE)mir_realloc(dbei.pBlob, newBlobSize); + oldBlobSize = newBlobSize; + } + dbei.cbBlob = oldBlobSize; + CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); + GetObjectDescription(&dbei, str, SIZEOF(str)); + if (str[0]) { + CharUpperBuff(str, lstrlen(str)); + if (_tcsstr(str, (const TCHAR*)lParam) != NULL) { + SendDlgItemMessage(hwndDlg, IDC_LIST, LB_SETCURSEL, index, 0); + SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_LIST, LBN_SELCHANGE), 0); + break; + } } } + + mir_free(dbei.pBlob); + break; + } + } + return FALSE; +} + +static INT_PTR CALLBACK DlgProcHistoryFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDOK://find Next + { + TCHAR str[128]; + HWND hwndParent = (HWND)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + GetDlgItemText(hwndDlg, IDC_FINDWHAT, str, SIZEOF(str)); + CharUpperBuff(str, lstrlen(str)); + SendMessage(hwndParent, DM_FINDNEXT, 0, (LPARAM)str); + return TRUE; + } + case IDCANCEL: + DestroyWindow(hwndDlg); + return TRUE; + } + break; + } + return FALSE; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +static INT_PTR UserHistoryCommand(WPARAM wParam, LPARAM) +{ + HWND hwnd = WindowList_Find(hWindowList, (HANDLE)wParam); + if (hwnd) { + SetForegroundWindow(hwnd); + SetFocus(hwnd); + return 0; + } + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_HISTORY), NULL, DlgProcHistory, wParam); + return 0; +} + +static int HistoryContactDelete(WPARAM wParam, LPARAM) +{ + HWND hwnd = WindowList_Find(hWindowList, (HANDLE)wParam); + if (hwnd != NULL) + DestroyWindow(hwnd); + return 0; +} + +int PreShutdownHistoryModule(WPARAM, LPARAM) +{ + if (hWindowList) + WindowList_BroadcastAsync(hWindowList, WM_DESTROY, 0, 0); + return 0; +} + +int LoadHistoryModule(void) +{ + CLISTMENUITEM mi = { 0 }; + mi.cbSize = sizeof(mi); + mi.position = 1000090000; + mi.flags = CMIF_ICONFROMICOLIB; + mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_HISTORY); + mi.pszName = LPGEN("View &History"); + mi.pszService = MS_HISTORY_SHOWCONTACTHISTORY; + Menu_AddContactMenuItem(&mi); + + CreateServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY, UserHistoryCommand); + hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); + HookEvent(ME_DB_CONTACT_DELETED, HistoryContactDelete); + HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdownHistoryModule); + return 0; +} diff --git a/src/core/stduihist/main.cpp b/src/core/stduihist/main.cpp new file mode 100644 index 0000000000..1bb467ada7 --- /dev/null +++ b/src/core/stduihist/main.cpp @@ -0,0 +1,77 @@ +/* + +Standard ugly history viewer for Myranda IM + +Copyright (C) 2012 George Hazan + +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 "commonheaders.h" + +int LoadHistoryModule(void); + +CLIST_INTERFACE* pcli; +TIME_API tmi; +HINSTANCE hInst; +int hLangpack; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + MIRANDA_VERSION_DWORD, + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + /* 5eedf3c5-3071-4234-a627-efd062a4d694 */ + { 0x5eedf3c5, 0x3071, 0x4234, {0xa6, 0x27, 0xef, 0xd0, 0x62, 0xa4, 0xd6, 0x94}} +}; + +static const MUUID interfaces[] = { MIID_UIHISTORY, MIID_LAST }; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + mir_getTMI(&tmi); + + pcli = ( CLIST_INTERFACE* )CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, (LPARAM)hInst); + + LoadHistoryModule(); + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + return 0; +} diff --git a/src/core/stduihist/resource.rc b/src/core/stduihist/resource.rc new file mode 100644 index 0000000000..abee09f9fe --- /dev/null +++ b/src/core/stduihist/resource.rc @@ -0,0 +1,107 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\..\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_HISTORY_FIND DIALOGEX 0, 0, 230, 46 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Find" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + EDITTEXT IDC_FINDWHAT,48,11,115,12,ES_AUTOHSCROLL + DEFPUSHBUTTON "&Find Next",IDOK,173,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,173,24,50,14 + LTEXT "Find What:",IDC_STATIC,7,13,39,9 +END + +IDD_HISTORY DIALOGEX 0, 0, 296, 166 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Message History" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + DEFPUSHBUTTON "Close",IDOK,239,144,50,14 + EDITTEXT IDC_EDIT,7,83,282,52,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL + LISTBOX IDC_LIST,7,7,282,72,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "&Find...",IDC_FIND,7,144,50,14 + PUSHBUTTON "Delete",IDC_DELETEHISTORY,66,144,50,14 +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_HISTORY_FIND, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 223 + TOPMARGIN, 7 + BOTTOMMARGIN, 39 + HORZGUIDE, 17 + END + + IDD_HISTORY, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 289 + TOPMARGIN, 7 + BOTTOMMARGIN, 158 + END +END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\..\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/stduihist/stduihist_10.vcxproj b/src/core/stduihist/stduihist_10.vcxproj new file mode 100644 index 0000000000..ca97144233 --- /dev/null +++ b/src/core/stduihist/stduihist_10.vcxproj @@ -0,0 +1,217 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + stduihist + {DADAC956-3A54-440A-8B56-A07234DEE861} + + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + EditAndContinue + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + false + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/core/stduihist/stduihist_10.vcxproj.filters b/src/core/stduihist/stduihist_10.vcxproj.filters new file mode 100644 index 0000000000..4b215c60e3 --- /dev/null +++ b/src/core/stduihist/stduihist_10.vcxproj.filters @@ -0,0 +1,44 @@ + + + + + {5c074c9e-6c66-4233-bbd3-a50170fccf47} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {e30af2c4-42d4-4342-8eb9-2dbca157c6bb} + h;hpp;hxx;hm;inl + + + {9208a050-ffae-47fa-bc98-4ca4f79d37d7} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/src/core/stduihist/version.h b/src/core/stduihist/version.h new file mode 100644 index 0000000000..49dc77b639 --- /dev/null +++ b/src/core/stduihist/version.h @@ -0,0 +1,14 @@ + +#include + +#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION +#define __VERSION_STRING MIRANDA_VERSION_STRING + +#define __PLUGIN_NAME "stduihist" +#define __INTERNAL_NAME "stduihist" +#define __FILENAME "stduihist.dll" +#define __DESCRIPTION "Core module for built-in history viewer." +#define __AUTHOR "Myranda team" +#define __AUTHOREMAIL "" +#define __AUTHORWEB "http://nightly.miranda.im" +#define __COPYRIGHT "© 2012 Myranda team" diff --git a/src/core/stduihist/version.rc b/src/core/stduihist/version.rc new file mode 100644 index 0000000000..e637f0cb33 --- /dev/null +++ b/src/core/stduihist/version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#include "afxres.h" +#include "version.h" + +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#endif //_WIN32 + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/src/core/stdurl/main.cpp b/src/core/stdurl/main.cpp index dbcaa34ec0..183ba8f3ff 100644 --- a/src/core/stdurl/main.cpp +++ b/src/core/stdurl/main.cpp @@ -38,8 +38,8 @@ PLUGININFOEX pluginInfo = { __COPYRIGHT, __AUTHORWEB, UNICODE_AWARE, - // {b774d10a-c761-11e1-8405-27e76188709b} - {0xb774d10a, 0xc761, 0x11e1, {0x84, 0x05, 0x27, 0xe7, 0x61, 0x88, 0x70, 0x9b }} + // 0ca63eee-eb2c-4aed-b3d0-bc8e6eb3bfb8 + { 0x0ca63eee, 0xeb2c, 0x4aed, {0xb3, 0xd0, 0xbc, 0x8e, 0x6e, 0xb3, 0xbf, 0xb8}} }; static const MUUID interfaces[] = { MIID_SRURL, MIID_LAST }; diff --git a/src/core/stdurl/resource.rc b/src/core/stdurl/resource.rc index 16f290a120..5bb57eb276 100644 --- a/src/core/stdurl/resource.rc +++ b/src/core/stdurl/resource.rc @@ -25,48 +25,6 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // Dialog // -IDD_URLRECV DIALOGEX 0, 0, 215, 140 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "URL Received" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - CONTROL "&Open URL",IDOK,"MButtonClass",WS_TABSTOP,11,120,57,14,WS_EX_NOACTIVATE | 0x10000000L - PUSHBUTTON "&Reply",IDC_REPLY,82,120,50,14 - PUSHBUTTON "&Close",IDCANCEL,148,120,50,14 - CONTROL "",IDC_PROTOCOL,"Button",BS_OWNERDRAW | WS_TABSTOP,5,7,12,12 - LTEXT "",IDC_NAME,19,7,118,9,SS_NOPREFIX | SS_CENTERIMAGE - CONTROL "&A",IDC_ADD,"MButtonClass",WS_TABSTOP,140,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "6",IDC_USERMENU,"MButtonClass",WS_TABSTOP,158,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "&D",IDC_DETAILS,"MButtonClass",WS_TABSTOP,176,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "&H",IDC_HISTORY,"MButtonClass",WS_TABSTOP,194,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - LTEXT "Date:",IDC_STATIC,5,21,29,8 - EDITTEXT IDC_DATE,34,21,176,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "URL:",IDC_STATIC,5,33,205,8 - EDITTEXT IDC_URL,5,43,205,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Description:",IDC_ST_ENTERMSG,5,60,205,8 - EDITTEXT IDC_MSG,5,70,205,44,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL -END - -IDD_URLSEND DIALOGEX 0, 0, 215, 126 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - COMBOBOX IDC_URLS,5,30,205,92,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_MESSAGE,5,57,205,44,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL - DEFPUSHBUTTON "&Send",IDOK,54,107,50,14 - PUSHBUTTON "&Cancel",IDCANCEL,113,107,50,14 - CONTROL "",IDC_PROTOCOL,"Button",BS_OWNERDRAW | WS_TABSTOP,5,7,12,12 - LTEXT "",IDC_NAME,19,7,118,9,SS_NOPREFIX | SS_CENTERIMAGE - CONTROL "&A",IDC_ADD,"MButtonClass",WS_TABSTOP,140,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "6",IDC_USERMENU,"MButtonClass",WS_TABSTOP,158,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "&D",IDC_DETAILS,"MButtonClass",WS_TABSTOP,176,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - CONTROL "&H",IDC_HISTORY,"MButtonClass",WS_TABSTOP,194,5,16,14,WS_EX_NOACTIVATE | 0x10000000L - LTEXT "Enter URL:",IDC_ST_ENTERURL,5,20,205,8 - LTEXT "Enter description:",IDC_ST_ENTERMSG,5,47,205,8 -END - #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// @@ -75,21 +33,9 @@ END // #ifdef APSTUDIO_INVOKED - IDD_URLRECV, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 210 - TOPMARGIN, 5 - BOTTOMMARGIN, 135 - END - - IDD_URLSEND, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 210 - TOPMARGIN, 5 - BOTTOMMARGIN, 121 - END +GUIDELINES DESIGNINFO +BEGIN +END #endif // APSTUDIO_INVOKED diff --git a/src/core/stdurl/stdurl_10.vcxproj b/src/core/stdurl/stdurl_10.vcxproj index ebc2b835ad..3abd37ba1c 100644 --- a/src/core/stdurl/stdurl_10.vcxproj +++ b/src/core/stdurl/stdurl_10.vcxproj @@ -116,6 +116,7 @@ 4996;%(DisableSpecificWarnings) Use commonheaders.h + false _DEBUG;%(PreprocessorDefinitions) diff --git a/src/core/stduserinfo/stduserinfo_10.vcxproj b/src/core/stduserinfo/stduserinfo_10.vcxproj index af6d086e6d..7f0d57e336 100644 --- a/src/core/stduserinfo/stduserinfo_10.vcxproj +++ b/src/core/stduserinfo/stduserinfo_10.vcxproj @@ -116,6 +116,7 @@ 4996;%(DisableSpecificWarnings) Use commonheaders.h + false _DEBUG;%(PreprocessorDefinitions) diff --git a/src/core/stduseronline/commonheaders.cpp b/src/core/stduseronline/commonheaders.cpp new file mode 100644 index 0000000000..95b2201163 --- /dev/null +++ b/src/core/stduseronline/commonheaders.cpp @@ -0,0 +1,2 @@ +#include "commonheaders.h" + diff --git a/src/core/stduseronline/commonheaders.h b/src/core/stduseronline/commonheaders.h new file mode 100644 index 0000000000..c9ed5a65d2 --- /dev/null +++ b/src/core/stduseronline/commonheaders.h @@ -0,0 +1,93 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/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. +*/ + +// to enable all 0.9.0 core functions +#define MIRANDA_VER 0x0A00 + +#define WINVER 0x0700 +#define _WIN32_WINNT 0x0700 +#define _WIN32_IE 0x0601 + +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "version.h" + +#include "../../resource.h" +#include "../stdplug.h" + +extern HINSTANCE hInst; diff --git a/src/core/stduseronline/main.cpp b/src/core/stduseronline/main.cpp new file mode 100644 index 0000000000..a69942c6c0 --- /dev/null +++ b/src/core/stduseronline/main.cpp @@ -0,0 +1,75 @@ +/* + +Standard user online monitor for Myranda IM + +Copyright (C) 2012 George Hazan + +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 "commonheaders.h" + +int LoadUserOnlineModule(void); + +CLIST_INTERFACE* pcli; +HINSTANCE hInst; +int hLangpack; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + MIRANDA_VERSION_DWORD, + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // 251c78d7-f6e0-4083-92dc-252dcb3be724 + { 0x251c78d7, 0xf6e0, 0x4083, {0x92, 0xdc, 0x25, 0x2d, 0xcb, 0x3b, 0xe7, 0x24}} +}; + +static const MUUID interfaces[] = { MIID_USERONLINE, MIID_LAST }; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + + pcli = ( CLIST_INTERFACE* )CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, (LPARAM)hInst); + + LoadUserOnlineModule(); + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + return 0; +} diff --git a/src/core/stduseronline/resource.rc b/src/core/stduseronline/resource.rc new file mode 100644 index 0000000000..5bb57eb276 --- /dev/null +++ b/src/core/stduseronline/resource.rc @@ -0,0 +1,66 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\..\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 +// + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN +END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\..\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/stduseronline/stduseronline_10.vcxproj b/src/core/stduseronline/stduseronline_10.vcxproj new file mode 100644 index 0000000000..f8283a7638 --- /dev/null +++ b/src/core/stduseronline/stduseronline_10.vcxproj @@ -0,0 +1,217 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + stduseronline + {d22c1bbb-e06a-4a28-8f33-17d1ea3e8563} + + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + EditAndContinue + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + false + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/core/stduseronline/stduseronline_10.vcxproj.filters b/src/core/stduseronline/stduseronline_10.vcxproj.filters new file mode 100644 index 0000000000..33d6b5e67e --- /dev/null +++ b/src/core/stduseronline/stduseronline_10.vcxproj.filters @@ -0,0 +1,44 @@ + + + + + {5c074c9e-6c66-4233-bbd3-a50170fccf47} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {e30af2c4-42d4-4342-8eb9-2dbca157c6bb} + h;hpp;hxx;hm;inl + + + {9208a050-ffae-47fa-bc98-4ca4f79d37d7} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/src/core/stduseronline/useronline.cpp b/src/core/stduseronline/useronline.cpp new file mode 100644 index 0000000000..e4c2b9b258 --- /dev/null +++ b/src/core/stduseronline/useronline.cpp @@ -0,0 +1,127 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/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 "commonheaders.h" + +static int uniqueEventId = 0; + +static bool Proto_IsAccountEnabled(PROTOACCOUNT* pa) +{ + return pa && ((pa->bIsEnabled && !pa->bDynDisabled) || pa->bOldProto); +} + +static int UserOnlineSettingChanged(WPARAM wParam, LPARAM lParam) +{ + DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; + if ((HANDLE)wParam == NULL || strcmp(cws->szSetting, "Status")) + return 0; + + int newStatus = cws->value.wVal; + int oldStatus = DBGetContactSettingWord((HANDLE)wParam, "UserOnline", "OldStatus", ID_STATUS_OFFLINE); + DBWriteContactSettingWord((HANDLE)wParam, "UserOnline", "OldStatus", (WORD)newStatus); + if (CallService(MS_IGNORE_ISIGNORED, wParam, IGNOREEVENT_USERONLINE)) return 0; + if (DBGetContactSettingByte((HANDLE)wParam, "CList", "Hidden", 0)) return 0; + if (newStatus == ID_STATUS_OFFLINE && oldStatus != ID_STATUS_OFFLINE) { + // Remove the event from the queue if it exists since they are now offline + int lastEvent = (int)DBGetContactSettingDword((HANDLE)wParam, "UserOnline", "LastEvent", 0); + + if (lastEvent) { + CallService(MS_CLIST_REMOVEEVENT, wParam, (LPARAM)lastEvent); + DBWriteContactSettingDword((HANDLE)wParam, "UserOnline", "LastEvent", 0); + } + } + if ((newStatus == ID_STATUS_ONLINE || newStatus == ID_STATUS_FREECHAT) && + oldStatus != ID_STATUS_ONLINE && oldStatus != ID_STATUS_FREECHAT) { + { + DWORD ticked = db_dword_get(NULL, "UserOnline", cws->szModule, GetTickCount()); + // only play the sound (or show event) if this event happens at least 10 secs after the proto went from offline + if (GetTickCount() - ticked > (1000*10)) { + CLISTEVENT cle; + TCHAR tooltip[256]; + + ZeroMemory(&cle, sizeof(cle)); + cle.cbSize = sizeof(cle); + cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR; + cle.hContact = (HANDLE)wParam; + cle.hDbEvent = (HANDLE)(uniqueEventId++); + cle.hIcon = LoadSkinIcon(SKINICON_OTHER_USERONLINE, false); + cle.pszService = "UserOnline/Description"; + mir_sntprintf(tooltip, SIZEOF(tooltip), TranslateT("%s is Online"), pcli->pfnGetContactDisplayName((HANDLE)wParam, 0)); + cle.ptszTooltip = tooltip; + CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); + IcoLib_ReleaseIcon(cle.hIcon, 0); + DBWriteContactSettingDword(cle.hContact, "UserOnline", "LastEvent", (DWORD)cle.hDbEvent); + SkinPlaySound("UserOnline"); + } + } + } + return 0; +} + +static int UserOnlineAck(WPARAM, LPARAM lParam) +{ + ACKDATA * ack = (ACKDATA*) lParam; + if (ack != 0 && ack->szModule && ack->type == ACKTYPE_STATUS && ack->result == ACKRESULT_SUCCESS && ack->hProcess == (HANDLE)ID_STATUS_OFFLINE) { + // if going from offline to any other mode, remember when it happened. + db_dword_set(NULL, "UserOnline", ack->szModule, GetTickCount()); + } + return 0; +} + +static int UserOnlineModulesLoaded(WPARAM, LPARAM) +{ + int numAccounts; + PROTOACCOUNT** accounts; + ProtoEnumAccounts(&numAccounts, &accounts); + + // reset the counter + for (int i = 0; i < numAccounts; i++) + if (Proto_IsAccountEnabled(accounts[i])) + db_dword_set(NULL, "UserOnline", accounts[i]->szModuleName, GetTickCount()); + + return 0; +} + +static int UserOnlineAccountsChanged(WPARAM eventCode, LPARAM lParam) +{ + PROTOACCOUNT* pa = (PROTOACCOUNT*)lParam; + + switch(eventCode) { + case PRAC_ADDED: + case PRAC_CHECKED: + // reset the counter + if (Proto_IsAccountEnabled(pa)) + db_dword_set(NULL, "UserOnline", pa->szModuleName, GetTickCount()); + break; + } + return 0; +} + +int LoadUserOnlineModule(void) +{ + HookEvent(ME_DB_CONTACT_SETTINGCHANGED, UserOnlineSettingChanged); + HookEvent(ME_PROTO_ACK, UserOnlineAck); + HookEvent(ME_SYSTEM_MODULESLOADED, UserOnlineModulesLoaded); + HookEvent(ME_PROTO_ACCLISTCHANGED, UserOnlineAccountsChanged); + SkinAddNewSoundEx("UserOnline", LPGEN("Alerts"), LPGEN("Online")); + return 0; +} diff --git a/src/core/stduseronline/version.h b/src/core/stduseronline/version.h new file mode 100644 index 0000000000..47d98e526b --- /dev/null +++ b/src/core/stduseronline/version.h @@ -0,0 +1,14 @@ + +#include + +#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION +#define __VERSION_STRING MIRANDA_VERSION_STRING + +#define __PLUGIN_NAME "stduseronline" +#define __INTERNAL_NAME "stduseronline" +#define __FILENAME "stduseronline.dll" +#define __DESCRIPTION "Core module for user-is-online event processing." +#define __AUTHOR "Myranda team" +#define __AUTHOREMAIL "" +#define __AUTHORWEB "http://nightly.miranda.im" +#define __COPYRIGHT "© 2012 Myranda team" diff --git a/src/core/stduseronline/version.rc b/src/core/stduseronline/version.rc new file mode 100644 index 0000000000..e637f0cb33 --- /dev/null +++ b/src/core/stduseronline/version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#include "afxres.h" +#include "version.h" + +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#endif //_WIN32 + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/src/miranda32_10.vcxproj b/src/miranda32_10.vcxproj index 4f6985d55d..36b42b7b1f 100644 --- a/src/miranda32_10.vcxproj +++ b/src/miranda32_10.vcxproj @@ -286,9 +286,6 @@ ..\..\core\commonheaders.h - - ..\..\core\commonheaders.h - ..\..\core\commonheaders.h @@ -313,21 +310,9 @@ ..\..\core\commonheaders.h - - ..\..\core\commonheaders.h - - - ..\..\core\commonheaders.h - - - ..\..\core\commonheaders.h - ..\..\core\commonheaders.h - - ..\..\core\commonheaders.h - ..\..\core\commonheaders.h @@ -463,12 +448,6 @@ ..\..\core\commonheaders.h - - ..\..\core\commonheaders.h - - - ..\..\core\commonheaders.h - ..\..\core\commonheaders.h diff --git a/src/miranda32_10.vcxproj.filters b/src/miranda32_10.vcxproj.filters index 2cd789a1ad..3f127520ac 100644 --- a/src/miranda32_10.vcxproj.filters +++ b/src/miranda32_10.vcxproj.filters @@ -13,9 +13,6 @@ {edb05be9-a16a-4f37-8035-711e5286311f} - - {3e3f52bd-7183-4064-8803-93a7d3c57925} - {880105c7-0ef2-41ee-9541-fe2c9e5a7679} @@ -28,15 +25,6 @@ {ada379e5-5553-4316-b4f0-62f2f60e8540} - - {51edc105-758f-4472-bf65-59e307fd25e1} - - - {0dba3b26-757e-488d-bcb2-8b63ab5fe948} - - - {8409f336-1269-46d8-878c-a93588927a66} - {4f9373ec-57ce-4c35-9217-9ffc5aefa841} @@ -61,12 +49,6 @@ {ede3d43b-a5cf-462a-90df-4ddd7a091234} - - {9074e889-f17c-4c90-a3cf-1cfb2e513491} - - - {daa4af16-7ada-4bd5-92bb-59f5ab815e9c} - {4549cb1a-17d4-49a2-82e9-3acd7e17f5bc} @@ -305,9 +287,6 @@ Modules\addcontact - - Modules\autoaway - Modules\button @@ -332,18 +311,6 @@ Modules\findadd - - Modules\help - - - Modules\help - - - Modules\history - - - Modules\idle - Modules\ignore @@ -437,12 +404,6 @@ Modules\srawaymsg - - Modules\updater - - - Modules\useronline - Modules\utils diff --git a/src/modules/autoaway/autoaway.cpp b/src/modules/autoaway/autoaway.cpp deleted file mode 100644 index 278fff1af4..0000000000 --- a/src/modules/autoaway/autoaway.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/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 "..\..\core\commonheaders.h" - -#define AA_MODULE "AutoAway" - -void Proto_SetStatus(const char* szProto, unsigned status); - -static int iBreakSounds = 0; - -static int AutoAwaySound(WPARAM, LPARAM lParam) -{ - return iBreakSounds; -} - -static int AutoAwayEvent(WPARAM, LPARAM lParam) -{ - int i; - - MIRANDA_IDLE_INFO mii; - mii.cbSize = sizeof(mii); - CallService(MS_IDLE_GETIDLEINFO, 0, (LPARAM)&mii); - if (mii.aaStatus == 0) - return 0; - - for (i=0; i < accounts.getCount(); i++) { - PROTOACCOUNT* pa = accounts[i]; - - if ( !Proto_IsAccountEnabled(pa) || Proto_IsAccountLocked(pa)) continue; - - int statusbits = CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0); - int currentstatus = CallProtoServiceInt(NULL,pa->szModuleName, PS_GETSTATUS, 0, 0); - int status = mii.aaStatus; - if ( !(statusbits & Proto_Status2Flag(status))) { - // the protocol doesnt support the given status - if (statusbits & Proto_Status2Flag(ID_STATUS_AWAY)) - status = ID_STATUS_AWAY; - // the proto doesnt support user mode or even away, bail. - else - continue; - } - if (currentstatus >= ID_STATUS_ONLINE && currentstatus != ID_STATUS_INVISIBLE) { - if ((lParam&IDF_ISIDLE) && (currentstatus == ID_STATUS_ONLINE || currentstatus == ID_STATUS_FREECHAT)) { - DBWriteContactSettingByte(NULL, AA_MODULE, pa->szModuleName, 1); - Proto_SetStatus(pa->szModuleName, status); - } - else if ( !(lParam & IDF_ISIDLE) && DBGetContactSettingByte(NULL, AA_MODULE, pa->szModuleName, 0)) { - // returning from idle and this proto was set away, set it back - DBWriteContactSettingByte(NULL, AA_MODULE, pa->szModuleName, 0); - if ( !mii.aaLock) - Proto_SetStatus(pa->szModuleName, ID_STATUS_ONLINE); - } } } - if (mii.idlesoundsoff) - iBreakSounds = (lParam&IDF_ISIDLE) != 0; - - return 0; -} - -int LoadAutoAwayModule(void) -{ - HookEvent(ME_SKIN_PLAYINGSOUND, AutoAwaySound); - HookEvent(ME_IDLE_CHANGED, AutoAwayEvent); - return 0; -} diff --git a/src/modules/help/about.cpp b/src/modules/help/about.cpp deleted file mode 100644 index b01e139a01..0000000000 --- a/src/modules/help/about.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/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 "..\..\core\commonheaders.h" - -#define STR_VERSION_FORMAT "%s%S%S" - -INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static int iState = 0; - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - { TCHAR filename[MAX_PATH], *productCopyright; - DWORD unused; - DWORD verInfoSize; - UINT blockSize; - PVOID pVerInfo; - - GetModuleFileName(NULL, filename, SIZEOF(filename)); - verInfoSize = GetFileVersionInfoSize(filename, &unused); - pVerInfo = mir_alloc(verInfoSize); - GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo); - VerQueryValue(pVerInfo, _T("\\StringFileInfo\\000004b0\\LegalCopyright"), (LPVOID*)&productCopyright, &blockSize); - SetDlgItemText(hwndDlg, IDC_DEVS, productCopyright); - mir_free(pVerInfo); - } - { char productVersion[56], *p; - int isAnsi = 0; - TCHAR str[64]; - CallService(MS_SYSTEM_GETVERSIONTEXT, SIZEOF(productVersion), (LPARAM)productVersion); - // Hide Unicode from version text as it is assumed at this point - p = strstr(productVersion, " Unicode"); - if (p) - *p = '\0'; - else - isAnsi = 1; - mir_sntprintf(str, SIZEOF(str), _T(STR_VERSION_FORMAT), TranslateT("v"), productVersion, isAnsi?" ANSI":""); - { - TCHAR oldTitle[256], newTitle[256]; - GetDlgItemText(hwndDlg, IDC_HEADERBAR, oldTitle, SIZEOF(oldTitle)); - mir_sntprintf(newTitle, SIZEOF(newTitle), oldTitle, str); - SetDlgItemText(hwndDlg, IDC_HEADERBAR, newTitle); - } - - mir_sntprintf(str, SIZEOF(str), TranslateT("Built %s %s"), _T(__DATE__), _T(__TIME__)); - SetDlgItemText(hwndDlg, IDC_BUILDTIME, str); - } - ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_HIDE); - { - HRSRC hResInfo = FindResource(hInst, MAKEINTRESOURCE(IDR_CREDITS), _T("TEXT")); - DWORD ResSize = SizeofResource(hInst, hResInfo); - HGLOBAL hRes = LoadResource(hInst, hResInfo); - char* pszMsg = (char*)LockResource(hRes); - if (pszMsg) - { - char* pszMsgt = (char*)alloca(ResSize + 1); - memcpy(pszMsgt, pszMsg, ResSize); pszMsgt[ResSize] = 0; - - TCHAR *ptszMsg; - if (ResSize >=3 && pszMsgt[0] == '\xef' && pszMsgt[1] == '\xbb' && pszMsgt[2] == '\xbf') - ptszMsg = Utf8DecodeT(pszMsgt + 3); - else - ptszMsg = mir_a2t_cp(pszMsgt, 1252); - - SetDlgItemText(hwndDlg, IDC_CREDITSFILE, ptszMsg); - UnlockResource(pszMsg); - mir_free(ptszMsg); - } - FreeResource(hRes); - } - Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_MIRANDA); - return TRUE; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDOK: - case IDCANCEL: - DestroyWindow(hwndDlg); - return TRUE; - case IDC_CONTRIBLINK: - if (iState) { - iState = 0; - SetDlgItemText(hwndDlg, IDC_CONTRIBLINK, TranslateT("Credits >")); - ShowWindow(GetDlgItem(hwndDlg, IDC_DEVS), SW_SHOW); - ShowWindow(GetDlgItem(hwndDlg, IDC_BUILDTIME), SW_SHOW); - ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_HIDE); - } - else { - iState = 1; - SetDlgItemText(hwndDlg, IDC_CONTRIBLINK, TranslateT("< Copyright")); - ShowWindow(GetDlgItem(hwndDlg, IDC_DEVS), SW_HIDE); - ShowWindow(GetDlgItem(hwndDlg, IDC_BUILDTIME), SW_HIDE); - ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_SHOW); - } - break; - } - break; - - case WM_CTLCOLOREDIT: - case WM_CTLCOLORSTATIC: - switch (GetWindowLongPtr((HWND)lParam, GWL_ID)) { - case IDC_WHITERECT: - case IDC_BUILDTIME: - case IDC_CREDITSFILE: - case IDC_DEVS: - SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); - break; - default: - return FALSE; - } - SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); - return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); - - case WM_DESTROY: - Window_FreeIcon_IcoLib(hwndDlg); - { - HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_VERSION, WM_GETFONT, 0, 0); - SendDlgItemMessage(hwndDlg, IDC_VERSION, WM_SETFONT, SendDlgItemMessage(hwndDlg, IDOK, WM_GETFONT, 0, 0), 0); - DeleteObject(hFont); - } - break; - } - return FALSE; -} diff --git a/src/modules/help/help.cpp b/src/modules/help/help.cpp deleted file mode 100644 index 30c25ff87c..0000000000 --- a/src/modules/help/help.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/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 "..\..\core\commonheaders.h" - -INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); - -HWND hAboutDlg = NULL; -static HANDLE hBugEvent = NULL; - -static INT_PTR AboutCommand(WPARAM wParam, LPARAM) -{ - if (IsWindow(hAboutDlg)) { - SetForegroundWindow(hAboutDlg); - SetFocus(hAboutDlg); - return 0; - } - hAboutDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)wParam, DlgProcAbout); - return 0; -} - -static INT_PTR IndexCommand(WPARAM, LPARAM) -{ - CallService(MS_UTILS_OPENURL, 1, (LPARAM)Translate("http://wiki.miranda-im.org/")); - return 0; -} - -static INT_PTR WebsiteCommand(WPARAM, LPARAM) -{ - CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://www.miranda-im.org"); - return 0; -} - -static int BugCommandEvent(WPARAM wParam, LPARAM lParam) -{ - char *szUrl = (char*)lParam; - if (szUrl) - CallService(MS_UTILS_OPENURL, 1, (LPARAM)szUrl); - - return 0; -} - -static INT_PTR BugCommand(WPARAM, LPARAM) -{ - NotifyEventHooks(hBugEvent, 0, (LPARAM)"http://code.google.com/p/miranda/issues/list"); - return 0; -} - -int ShutdownHelpModule(WPARAM, LPARAM) -{ - if (IsWindow(hAboutDlg)) DestroyWindow(hAboutDlg); - hAboutDlg = NULL; - return 0; -} - -int LoadHelpModule(void) -{ - HookEvent(ME_SYSTEM_PRESHUTDOWN, ShutdownHelpModule); - - CreateServiceFunction("Help/AboutCommand", AboutCommand); - CreateServiceFunction("Help/IndexCommand", IndexCommand); - CreateServiceFunction("Help/WebsiteCommand", WebsiteCommand); - CreateServiceFunction("Help/BugCommand", BugCommand); - - hBugEvent = CreateHookableEvent(ME_HELP_BUGREPORT); - SetHookDefaultForHookableEvent(hBugEvent, BugCommandEvent); - - CLISTMENUITEM mi = { 0 }; - mi.cbSize = sizeof(mi); - mi.flags = CMIF_ICONFROMICOLIB; - mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_MIRANDA); - mi.pszPopupName = LPGEN("&Help"); - mi.popupPosition = 2000090000; - mi.position = 2000090000; - mi.pszName = LPGEN("&About..."); - mi.pszService = "Help/AboutCommand"; - Menu_AddMainMenuItem(&mi); - - mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_HELP); - mi.position = -500050000; - mi.pszName = LPGEN("&Support"); - mi.pszService = "Help/IndexCommand"; - Menu_AddMainMenuItem(&mi); - - mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_MIRANDAWEB); - mi.position = 2000050000; - mi.pszName = LPGEN("&Miranda IM Homepage"); - mi.pszService = "Help/WebsiteCommand"; - Menu_AddMainMenuItem(&mi); - - mi.icolibItem = GetSkinIconHandle(SKINICON_EVENT_URL); - mi.position = 2000040000; - mi.pszName = LPGEN("&Report Bug"); - mi.pszService = "Help/BugCommand"; - Menu_AddMainMenuItem(&mi); - return 0; -} diff --git a/src/modules/history/history.cpp b/src/modules/history/history.cpp deleted file mode 100644 index c4d56a858a..0000000000 --- a/src/modules/history/history.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/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 "..\..\core\commonheaders.h" - -#define SUMMARY 0 -#define DETAIL 1 -#define DM_FINDNEXT (WM_USER+10) -#define DM_HREBUILD (WM_USER+11) - -static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -static INT_PTR CALLBACK DlgProcHistoryFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -static HANDLE hWindowList = 0; - -static INT_PTR UserHistoryCommand(WPARAM wParam, LPARAM) -{ - HWND hwnd = WindowList_Find(hWindowList, (HANDLE)wParam); - if (hwnd) { - SetForegroundWindow(hwnd); - SetFocus(hwnd); - return 0; - } - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_HISTORY), NULL, DlgProcHistory, wParam); - return 0; -} - -static int HistoryContactDelete(WPARAM wParam, LPARAM) -{ - HWND hwnd = WindowList_Find(hWindowList, (HANDLE)wParam); - if (hwnd != NULL) - DestroyWindow(hwnd); - return 0; -} - -int PreShutdownHistoryModule(WPARAM, LPARAM) -{ - if (hWindowList) - WindowList_BroadcastAsync(hWindowList, WM_DESTROY, 0, 0); - return 0; -} - -int LoadHistoryModule(void) -{ - CLISTMENUITEM mi = { 0 }; - mi.cbSize = sizeof(mi); - mi.position = 1000090000; - mi.flags = CMIF_ICONFROMICOLIB; - mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_HISTORY); - mi.pszName = LPGEN("View &History"); - mi.pszService = MS_HISTORY_SHOWCONTACTHISTORY; - Menu_AddContactMenuItem(&mi); - - CreateServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY, UserHistoryCommand); - hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); - HookEvent(ME_DB_CONTACT_DELETED, HistoryContactDelete); - HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdownHistoryModule); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// -// Fills the events list - -static void GetMessageDescription(DBEVENTINFO *dbei, TCHAR* buf, int cbBuf) -{ - TCHAR* msg = DbGetEventTextT(dbei, CP_ACP); - _tcsncpy(buf, msg ? msg : TranslateT("Invalid Message"), cbBuf); - buf[ cbBuf-1 ] = 0; - mir_free(msg); -} - -static void GetUrlDescription(DBEVENTINFO *dbei, TCHAR* buf, int cbBuf) -{ - int len = dbei->cbBlob; - if (len >= cbBuf) - len = cbBuf-1; - - MultiByteToWideChar(CP_ACP, 0, (LPCSTR)dbei->pBlob, len, buf, cbBuf); - buf[ len ] = 0; - - if (len < cbBuf-3) - _tcscat(buf, _T("\r\n")); -} - -static void GetFileDescription(DBEVENTINFO *dbei, TCHAR* buf, int cbBuf) -{ - int len = dbei->cbBlob - sizeof(DWORD); - if (len >= cbBuf) - len = cbBuf-1; - - MultiByteToWideChar(CP_ACP, 0, (LPCSTR)dbei->pBlob + sizeof(DWORD), len, buf, cbBuf); - buf[ len ] = 0; - - if (len < cbBuf-3) - _tcscat(buf, _T("\r\n")); -} - -static void GetObjectDescription(DBEVENTINFO *dbei, TCHAR* str, int cbStr) -{ - switch(dbei->eventType) { - case EVENTTYPE_MESSAGE: - GetMessageDescription(dbei, str, cbStr); - break; - - case EVENTTYPE_URL: - GetUrlDescription(dbei, str, cbStr); - break; - - case EVENTTYPE_FILE: - GetFileDescription(dbei, str, cbStr); - break; - - default: - { - DBEVENTTYPEDESCR* et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); - if (et && (et->flags & DETF_HISTORY)) { - GetMessageDescription(dbei, str, cbStr); - } - else - str[ 0 ] = 0; -} } } - -static void GetObjectSummary(DBEVENTINFO *dbei, TCHAR* str, int cbStr) -{ - TCHAR* pszSrc, *pszTmp = NULL; - - switch(dbei->eventType) { - case EVENTTYPE_MESSAGE: - if (dbei->flags & DBEF_SENT) pszSrc = TranslateT("Outgoing Message"); - else pszSrc = TranslateT("Incoming Message"); - break; - - case EVENTTYPE_URL: - if (dbei->flags & DBEF_SENT) pszSrc = TranslateT("Outgoing URL"); - else pszSrc = TranslateT("Incoming URL"); - break; - - case EVENTTYPE_FILE: - if (dbei->flags & DBEF_SENT) pszSrc = TranslateT("Outgoing File"); - else pszSrc = TranslateT("Incoming File"); - break; - - default: - { - DBEVENTTYPEDESCR* et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); - if (et && (et->flags & DETF_HISTORY)) { - pszTmp = mir_a2t(et->descr); - pszSrc = TranslateTS(pszTmp); - break; - } - else { - str[ 0 ] = 0; - return; - } } } - - _tcsncpy(str, (const TCHAR*)pszSrc, cbStr); - str[ cbStr-1 ] = 0; - - mir_free(pszTmp); -} - -typedef struct { - HANDLE hContact; - HWND hwnd; -} THistoryThread; - -static void FillHistoryThread(void* param) -{ - Thread_SetName("HistoryWindow::FillHistoryThread"); - - TCHAR str[200], eventText[256], strdatetime[64]; - HANDLE hDbEvent; - DBEVENTINFO dbei; - int newBlobSize, oldBlobSize, i; - HWND hwndList; - THistoryThread *hInfo = (THistoryThread*)param; - - SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_RESETCONTENT, 0, 0); - i = CallService(MS_DB_EVENT_GETCOUNT, (WPARAM)hInfo->hContact, 0); - SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_INITSTORAGE, i, i*40); - - ZeroMemory(&dbei, sizeof(dbei)); - dbei.cbSize = sizeof(dbei); - oldBlobSize = 0; - hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hInfo->hContact, 0); - hwndList = GetDlgItem(hInfo->hwnd, IDC_LIST); - while (hDbEvent != NULL) { - if ( !IsWindow(hInfo->hwnd)) - break; - newBlobSize = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); - if (newBlobSize>oldBlobSize) { - dbei.pBlob = (PBYTE)mir_realloc(dbei.pBlob, newBlobSize); - oldBlobSize = newBlobSize; - } - dbei.cbBlob = oldBlobSize; - CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); - GetObjectSummary(&dbei, str, SIZEOF(str)); - if (str[0]) { - tmi.printTimeStamp(NULL, dbei.timestamp, _T("d t"), strdatetime, SIZEOF(strdatetime), 0); - mir_sntprintf(eventText, SIZEOF(eventText), _T("%s: %s"), strdatetime, str); - i = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)eventText); - SendMessage(hwndList, LB_SETITEMDATA, i, (LPARAM)hDbEvent); - } - hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0); - } - mir_free(dbei.pBlob); - - SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_SETCURSEL, 0, 0); - SendMessage(hInfo->hwnd, WM_COMMAND, MAKEWPARAM(IDC_LIST, LBN_SELCHANGE), 0); - EnableWindow(GetDlgItem(hInfo->hwnd, IDC_LIST), TRUE); - mir_free(hInfo); -} - -static int HistoryDlgResizer(HWND, LPARAM, UTILRESIZECONTROL *urc) -{ - switch(urc->wId) { - case IDC_LIST: - return RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT; - case IDC_EDIT: - return RD_ANCHORX_WIDTH|RD_ANCHORY_BOTTOM; - case IDC_FIND: - case IDC_DELETEHISTORY: - return RD_ANCHORX_LEFT|RD_ANCHORY_BOTTOM; - case IDOK: - return RD_ANCHORX_RIGHT|RD_ANCHORY_BOTTOM; - } - return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; -} - -static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - HANDLE hContact; - - hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); - hContact = (HANDLE)lParam; - WindowList_Add(hWindowList, hwndDlg, hContact); - Utils_RestoreWindowPosition(hwndDlg, hContact, "History", ""); - { - TCHAR* contactName, str[200]; - contactName = cli.pfnGetContactDisplayName(hContact, 0); - mir_sntprintf(str, SIZEOF(str), TranslateT("History for %s"), contactName); - SetWindowText(hwndDlg, str); - } - Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_HISTORY); - SendMessage(hwndDlg, DM_HREBUILD, 0, 0); - return TRUE; - - case DM_HREBUILD: - { - THistoryThread* hInfo = (THistoryThread*)mir_alloc(sizeof(THistoryThread)); - EnableWindow(GetDlgItem(hwndDlg, IDC_LIST), FALSE); - hInfo->hContact = hContact; - hInfo->hwnd = hwndDlg; - forkthread(FillHistoryThread, 0, hInfo); - } - return TRUE; - - case WM_DESTROY: - Window_FreeIcon_IcoLib(hwndDlg); - Utils_SaveWindowPosition(hwndDlg, hContact, "History", ""); - WindowList_Remove(hWindowList, hwndDlg); - return TRUE; - - case WM_GETMINMAXINFO: - ((MINMAXINFO*)lParam)->ptMinTrackSize.x = 300; - ((MINMAXINFO*)lParam)->ptMinTrackSize.y = 230; - - case WM_SIZE: - { - UTILRESIZEDIALOG urd = {0}; - urd.cbSize = sizeof(urd); - urd.hwndDlg = hwndDlg; - urd.hInstance = hInst; - urd.lpTemplate = MAKEINTRESOURCEA(IDD_HISTORY); - urd.lParam = (LPARAM)NULL; - urd.pfnResizer = HistoryDlgResizer; - CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); - return TRUE; - } - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDOK: - case IDCANCEL: - DestroyWindow(hwndDlg); - return TRUE; - - case IDC_FIND: - ShowWindow(CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_HISTORY_FIND), hwndDlg, DlgProcHistoryFind, (LPARAM)hwndDlg), SW_SHOW); - return TRUE; - - case IDC_DELETEHISTORY: - { - HANDLE hDbevent; - int index = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0); - if (index == LB_ERR) - break; - - if (MessageBox(hwndDlg, TranslateT("Are you sure you want to delete this history item?"), TranslateT("Delete History"), MB_YESNO|MB_ICONQUESTION) == IDYES) { - hDbevent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, index, 0); - CallService(MS_DB_EVENT_DELETE, (WPARAM)hContact, (LPARAM)hDbevent); - SendMessage(hwndDlg, DM_HREBUILD, 0, 0); - } - return TRUE; - } - case IDC_LIST: - if (HIWORD(wParam) == LBN_SELCHANGE) { - TCHAR str[8192], *contactName; - HANDLE hDbEvent; - DBEVENTINFO dbei; - int sel; - sel = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0); - if (sel == LB_ERR) { EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), FALSE); break; } - EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), TRUE); - contactName = cli.pfnGetContactDisplayName(hContact, 0); - hDbEvent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, sel, 0); - ZeroMemory(&dbei, sizeof(dbei)); - dbei.cbSize = sizeof(dbei); - dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); - if ((int)dbei.cbBlob != -1) - { - dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); - if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei) == 0) - { - GetObjectDescription(&dbei, str, SIZEOF(str)); - if (str[0]) - SetDlgItemText(hwndDlg, IDC_EDIT, str); - } - mir_free(dbei.pBlob); - } - } - return TRUE; - } - break; - case DM_FINDNEXT: - { - TCHAR str[1024]; - HANDLE hDbEvent, hDbEventStart; - DBEVENTINFO dbei; - int newBlobSize, oldBlobSize; - - int index = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0); - if (index == LB_ERR) - break; - - hDbEventStart = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, index, 0); - ZeroMemory(&dbei, sizeof(dbei)); - dbei.cbSize = sizeof(dbei); - dbei.pBlob = NULL; - oldBlobSize = 0; - for (;;) { - hDbEvent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, ++index, 0); - if (hDbEvent == (HANDLE)LB_ERR) { - index = -1; - continue; - } - if (hDbEvent == hDbEventStart) break; - newBlobSize = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); - if (newBlobSize>oldBlobSize) { - dbei.pBlob = (PBYTE)mir_realloc(dbei.pBlob, newBlobSize); - oldBlobSize = newBlobSize; - } - dbei.cbBlob = oldBlobSize; - CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); - GetObjectDescription(&dbei, str, SIZEOF(str)); - if (str[0]) { - CharUpperBuff(str, lstrlen(str)); - if (_tcsstr(str, (const TCHAR*)lParam) != NULL) { - SendDlgItemMessage(hwndDlg, IDC_LIST, LB_SETCURSEL, index, 0); - SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_LIST, LBN_SELCHANGE), 0); - break; - } } } - - mir_free(dbei.pBlob); - break; - } - } - return FALSE; -} - -static INT_PTR CALLBACK DlgProcHistoryFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); - return TRUE; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDOK://find Next - { - TCHAR str[128]; - HWND hwndParent = (HWND)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - GetDlgItemText(hwndDlg, IDC_FINDWHAT, str, SIZEOF(str)); - CharUpperBuff(str, lstrlen(str)); - SendMessage(hwndParent, DM_FINDNEXT, 0, (LPARAM)str); - return TRUE; - } - case IDCANCEL: - DestroyWindow(hwndDlg); - return TRUE; - } - break; - } - return FALSE; -} diff --git a/src/modules/idle/idle.cpp b/src/modules/idle/idle.cpp deleted file mode 100644 index fdd842ef79..0000000000 --- a/src/modules/idle/idle.cpp +++ /dev/null @@ -1,524 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2005 Miranda ICQ/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 "..\..\core\commonheaders.h" - -#define IDLEMOD "Idle" -#define IDL_USERIDLECHECK "UserIdleCheck" -#define IDL_IDLEMETHOD "IdleMethod" -#define IDL_IDLETIME1ST "IdleTime1st" -#define IDL_IDLEONSAVER "IdleOnSaver" // IDC_SCREENSAVER -#define IDL_IDLEONFULLSCR "IdleOnFullScr" // IDC_FULLSCREEN -#define IDL_IDLEONLOCK "IdleOnLock" // IDC_LOCKED -#define IDL_IDLEONTSDC "IdleOnTerminalDisconnect" // -#define IDL_IDLEPRIVATE "IdlePrivate" // IDC_IDLEPRIVATE -#define IDL_IDLESTATUSLOCK "IdleStatusLock" // IDC_IDLESTATUSLOCK -#define IDL_AAENABLE "AAEnable" -#define IDL_AASTATUS "AAStatus" -#define IDL_IDLESOUNDSOFF "IdleSoundsOff" - -#define IdleObject_IsIdle(obj) (obj->state&0x1) -#define IdleObject_SetIdle(obj) (obj->state|=0x1) -#define IdleObject_ClearIdle(obj) (obj->state&=~0x1) - -// either use meth 0, 1 or figure out which one -#define IdleObject_UseMethod0(obj) (obj->state&=~0x2) -#define IdleObject_UseMethod1(obj) (obj->state|=0x2) -#define IdleObject_GetMethod(obj) (obj->state&0x2) - -#define IdleObject_IdleCheckSaver(obj) (obj->state&0x4) -#define IdleObject_SetSaverCheck(obj) (obj->state|=0x4) - -#define IdleObject_IdleCheckWorkstation(obj) (obj->state&0x8) -#define IdleObject_SetWorkstationCheck(obj) (obj->state|=0x8) - -#define IdleObject_IsPrivacy(obj) (obj->state&0x10) -#define IdleObject_SetPrivacy(obj) (obj->state|=0x10) - -#define IdleObject_SetStatusLock(obj) (obj->state|=0x20) - -#define IdleObject_IdleCheckTerminal(obj) (obj->state&0x40) -#define IdleObject_SetTerminalCheck(obj) (obj->state|=0x40) - -#define IdleObject_IdleCheckFullScr(obj) (obj->state&0x80) -#define IdleObject_SetFullScrCheck(obj) (obj->state|=0x80) - -//#include - -#ifndef _INC_WTSAPI - -#define WTS_CURRENT_SERVER_HANDLE ((HANDLE)NULL) -#define WTS_CURRENT_SESSION ((DWORD)-1) - -typedef enum _WTS_CONNECTSTATE_CLASS { - WTSActive, // User logged on to WinStation - WTSConnected, // WinStation connected to client - WTSConnectQuery, // In the process of connecting to client - WTSShadow, // Shadowing another WinStation - WTSDisconnected, // WinStation logged on without client - WTSIdle, // Waiting for client to connect - WTSListen, // WinStation is listening for connection - WTSReset, // WinStation is being reset - WTSDown, // WinStation is down due to error - WTSInit, // WinStation in initialization -} WTS_CONNECTSTATE_CLASS; - -typedef enum _WTS_INFO_CLASS { - WTSInitialProgram, - WTSApplicationName, - WTSWorkingDirectory, - WTSOEMId, - WTSSessionId, - WTSUserName, - WTSWinStationName, - WTSDomainName, - WTSConnectState, - WTSClientBuildNumber, - WTSClientName, - WTSClientDirectory, - WTSClientProductId, - WTSClientHardwareId, - WTSClientAddress, - WTSClientDisplay, - WTSClientProtocolType, -} WTS_INFO_CLASS; - -#endif - -VOID (WINAPI *_WTSFreeMemory)(PVOID); -BOOL (WINAPI *_WTSQuerySessionInformation)(HANDLE, DWORD, WTS_INFO_CLASS, PVOID, DWORD*); - -BOOL bIsWTSApiPresent = FALSE; - -static BOOL bModuleInitialized = FALSE; - -BOOL InitWTSAPI() -{ - HMODULE hDll = LoadLibraryA("wtsapi32.dll"); - if (hDll) { - _WTSFreeMemory = (VOID (WINAPI *)(PVOID))GetProcAddress(hDll, "WTSFreeMemory"); - _WTSQuerySessionInformation = (BOOL (WINAPI *)(HANDLE, DWORD, WTS_INFO_CLASS, PVOID, DWORD*))GetProcAddress(hDll, "WTSQuerySessionInformationW"); - - if (_WTSFreeMemory && _WTSQuerySessionInformation) return 1; - } - return 0; -} - -BOOL IsTerminalDisconnected() -{ - PVOID pBuffer = NULL; - DWORD pBytesReturned = 0; - BOOL result = FALSE; - - if ( !bIsWTSApiPresent) - return FALSE; - - if (_WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSConnectState, &pBuffer, &pBytesReturned)) { - if (*(PDWORD)pBuffer == WTSDisconnected) - result = TRUE; - } - else bIsWTSApiPresent = FALSE; - - if (pBuffer) - _WTSFreeMemory(pBuffer); - return result; -} - -typedef struct { - UINT_PTR hTimer; - unsigned int useridlecheck; - unsigned int state; - unsigned int minutes; // user setting, number of minutes of inactivity to wait for - POINT mousepos; - unsigned int mouseidle; - int aastatus; - int idleType; - int aasoundsoff; -} - IdleObject; - -static const WORD aa_Status[] = {ID_STATUS_AWAY, ID_STATUS_NA, ID_STATUS_OCCUPIED, ID_STATUS_DND, ID_STATUS_ONTHEPHONE, ID_STATUS_OUTTOLUNCH}; - -static IdleObject gIdleObject; -static HANDLE hIdleEvent; -static BOOL (WINAPI * MyGetLastInputInfo)(PLASTINPUTINFO); - -void CALLBACK IdleTimer(HWND hwnd, UINT umsg, UINT_PTR idEvent, DWORD dwTime); - -static void IdleObject_ReadSettings(IdleObject * obj) -{ - obj->useridlecheck = DBGetContactSettingByte(NULL, IDLEMOD, IDL_USERIDLECHECK, 0); - obj->minutes = DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLETIME1ST, 10); - obj->aastatus = !DBGetContactSettingByte(NULL, IDLEMOD, IDL_AAENABLE, 0) ? 0 : DBGetContactSettingWord(NULL, IDLEMOD, IDL_AASTATUS, 0); - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLESOUNDSOFF, 1)) - obj->aasoundsoff = 1; - else - obj->aasoundsoff = 0; - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEMETHOD, 0)) IdleObject_UseMethod1(obj); - else IdleObject_UseMethod0(obj); - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONSAVER, 0)) IdleObject_SetSaverCheck(obj); - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONFULLSCR, 0)) IdleObject_SetFullScrCheck(obj); - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONLOCK, 0)) IdleObject_SetWorkstationCheck(obj); - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEPRIVATE, 0)) IdleObject_SetPrivacy(obj); - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLESTATUSLOCK, 0)) IdleObject_SetStatusLock(obj); - if (DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONTSDC, 0)) IdleObject_SetTerminalCheck(obj); -} - -static void IdleObject_Create(IdleObject * obj) -{ - ZeroMemory(obj, sizeof(IdleObject)); - obj->hTimer = SetTimer(NULL, 0, 2000, IdleTimer); - IdleObject_ReadSettings(obj); -} - -static void IdleObject_Destroy(IdleObject * obj) -{ - if (IdleObject_IsIdle(obj)) - NotifyEventHooks(hIdleEvent, 0, 0); - IdleObject_ClearIdle(obj); - KillTimer(NULL, obj->hTimer); -} - -static int IdleObject_IsUserIdle(IdleObject * obj) -{ - DWORD dwTick; - if (IdleObject_GetMethod(obj)) { - CallService(MS_SYSTEM_GETIDLE, 0, (LPARAM)&dwTick); - return GetTickCount() - dwTick > (obj->minutes * 60 * 1000); - } - - if (MyGetLastInputInfo != NULL) { - LASTINPUTINFO ii; - ZeroMemory(&ii, sizeof(ii)); - ii.cbSize = sizeof(ii); - if (MyGetLastInputInfo(&ii)) - return GetTickCount() - ii.dwTime > (obj->minutes * 60 * 1000); - } - else { - POINT pt; - GetCursorPos(&pt); - if (pt.x != obj->mousepos.x || pt.y != obj->mousepos.y) { - obj->mousepos = pt; - obj->mouseidle = 0; - } - else obj->mouseidle += 2; - - if (obj->mouseidle) - return obj->mouseidle * 1000 >= (obj->minutes * 60 * 1000); - } - return FALSE; -} - -static bool IsWorkstationLocked (void) -{ - bool rc = false; - - if (openInputDesktop != NULL) { - HDESK hDesk = openInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP); - if (hDesk == NULL) - rc = true; - else if (closeDesktop != NULL) - closeDesktop(hDesk); - } - return rc; -} - -static bool IsScreenSaverRunning(void) -{ - BOOL rc = FALSE; - SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &rc, FALSE); - return rc != 0; -} - -bool IsFullScreen(void) -{ - RECT rcScreen = {0}; - - rcScreen.right = GetSystemMetrics(SM_CXSCREEN); - rcScreen.bottom = GetSystemMetrics(SM_CYSCREEN); - - if (MyMonitorFromWindow) - { - HMONITOR hMon = MyMonitorFromWindow(cli.hwndContactList, MONITOR_DEFAULTTONEAREST); - MONITORINFO mi; - mi.cbSize = sizeof(mi); - if (MyGetMonitorInfo(hMon, &mi)) - rcScreen = mi.rcMonitor; - } - - HWND hWndDesktop = GetDesktopWindow(); - HWND hWndShell = GetShellWindow(); - - // check foregroundwindow - HWND hWnd = GetForegroundWindow(); - if (hWnd && hWnd != hWndDesktop && hWnd != hWndShell) - { - TCHAR tszClassName[128] = _T(""); - GetClassName(hWnd, tszClassName, SIZEOF(tszClassName)); - if (_tcscmp(tszClassName, _T("WorkerW"))) - { - RECT rect, rectw, recti; - GetWindowRect(hWnd, &rectw); - - GetClientRect(hWnd, &rect); - ClientToScreen(hWnd, (LPPOINT)&rect); - ClientToScreen(hWnd, (LPPOINT)&rect.right); - - if (EqualRect(&rect, &rectw) && IntersectRect(&recti, &rect, &rcScreen) && - EqualRect(&recti, &rcScreen)) - return true; - } - } - - return false; -} - -static void IdleObject_Tick(IdleObject * obj) -{ - bool idle = false; - int idleType = 0, flags = 0; - - if (obj->useridlecheck && IdleObject_IsUserIdle(obj)) { - idleType = 1; idle = true; - } - else if (IdleObject_IdleCheckSaver(obj) && IsScreenSaverRunning()) { - idleType = 2; idle = true; - } - else if (IdleObject_IdleCheckFullScr(obj) && IsFullScreen()) { - idleType = 5; idle = true; - } - else if (IdleObject_IdleCheckWorkstation(obj) && IsWorkstationLocked()) { - idleType = 3; idle = true; - } - else if (IdleObject_IdleCheckTerminal(obj) && IsTerminalDisconnected()) { - idleType = 4; idle = true; - } - - if (IdleObject_IsPrivacy(obj)) - flags |= IDF_PRIVACY; - - if ( !IdleObject_IsIdle(obj) && idle) { - IdleObject_SetIdle(obj); - obj->idleType = idleType; - NotifyEventHooks(hIdleEvent, 0, IDF_ISIDLE | flags); - } - if (IdleObject_IsIdle(obj) && !idle) { - IdleObject_ClearIdle(obj); - obj->idleType = 0; - NotifyEventHooks(hIdleEvent, 0, flags); -} } - -void CALLBACK IdleTimer(HWND, UINT, UINT_PTR idEvent, DWORD) -{ - if (gIdleObject.hTimer == idEvent) - IdleObject_Tick(&gIdleObject); -} - -int IdleGetStatusIndex(WORD status) -{ - int j; - for (j = 0; j < SIZEOF(aa_Status); j++) - if (aa_Status[j] == status) - return j; - - return 0; -} - -static INT_PTR CALLBACK IdleOptsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) { - case WM_INITDIALOG: - { - int j; - int method = DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEMETHOD, 0); - TranslateDialogDefault(hwndDlg); - CheckDlgButton(hwndDlg, IDC_IDLESHORT, DBGetContactSettingByte(NULL, IDLEMOD, IDL_USERIDLECHECK, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_IDLEONWINDOWS, method == 0 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_IDLEONMIRANDA, method ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SCREENSAVER, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONSAVER, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_FULLSCREEN, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONFULLSCR, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_LOCKED, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONLOCK, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_IDLEPRIVATE, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEPRIVATE, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_IDLESTATUSLOCK, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLESTATUSLOCK, 0) ? BST_CHECKED : BST_UNCHECKED); - if ( !bIsWTSApiPresent) - EnableWindow(GetDlgItem(hwndDlg, IDC_IDLETERMINAL), FALSE); - else - CheckDlgButton(hwndDlg, IDC_IDLETERMINAL, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLEONTSDC, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_IDLESOUNDSOFF, DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLESOUNDSOFF, 1) ? BST_CHECKED : BST_UNCHECKED); - SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_IDLE1STTIME), 0); - SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETRANGE32, 1, 60); - SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETPOS, 0, MAKELONG((short) DBGetContactSettingByte(NULL, IDLEMOD, IDL_IDLETIME1ST, 10), 0)); - SendDlgItemMessage(hwndDlg, IDC_IDLE1STTIME, EM_LIMITTEXT, (WPARAM)2, 0); - - CheckDlgButton(hwndDlg, IDC_AASHORTIDLE, DBGetContactSettingByte(NULL, IDLEMOD, IDL_AAENABLE, 0) ? BST_CHECKED:BST_UNCHECKED); - for (j = 0; j < SIZEOF(aa_Status); j++) - SendDlgItemMessage(hwndDlg, IDC_AASTATUS, CB_ADDSTRING, 0, (LPARAM)cli.pfnGetStatusModeDescription(aa_Status[j], 0)); - - j = IdleGetStatusIndex((WORD)(DBGetContactSettingWord(NULL, IDLEMOD, IDL_AASTATUS, 0))); - SendDlgItemMessage(hwndDlg, IDC_AASTATUS, CB_SETCURSEL, j, 0); - SendMessage(hwndDlg, WM_USER+2, 0, 0); - return TRUE; - } - case WM_USER+2: - { - BOOL checked = IsDlgButtonChecked(hwndDlg, IDC_IDLESHORT) == BST_CHECKED; - EnableWindow(GetDlgItem(hwndDlg, IDC_IDLEONWINDOWS), checked); - EnableWindow(GetDlgItem(hwndDlg, IDC_IDLEONMIRANDA), checked); - EnableWindow(GetDlgItem(hwndDlg, IDC_IDLE1STTIME), checked); - EnableWindow(GetDlgItem(hwndDlg, IDC_AASTATUS), IsDlgButtonChecked(hwndDlg, IDC_AASHORTIDLE) == BST_CHECKED?1:0); - EnableWindow(GetDlgItem(hwndDlg, IDC_IDLESTATUSLOCK), IsDlgButtonChecked(hwndDlg, IDC_AASHORTIDLE) == BST_CHECKED?1:0); - break; - } - case WM_NOTIFY: - { - NMHDR * hdr = (NMHDR *)lParam; - if (hdr && hdr->code == PSN_APPLY) { - int method = IsDlgButtonChecked(hwndDlg, IDC_IDLEONWINDOWS) == BST_CHECKED; - int mins = SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_GETPOS, 0, 0); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLETIME1ST, (BYTE)(HIWORD(mins) == 0 ? LOWORD(mins) : 10)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_USERIDLECHECK, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLESHORT) == BST_CHECKED)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEMETHOD, (BYTE)(method ? 0 : 1)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEONSAVER, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_SCREENSAVER) == BST_CHECKED)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEONFULLSCR, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_FULLSCREEN) == BST_CHECKED)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEONLOCK, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_LOCKED) == BST_CHECKED)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEONTSDC, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLETERMINAL) == BST_CHECKED)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLEPRIVATE, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLEPRIVATE) == BST_CHECKED)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_AAENABLE, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_AASHORTIDLE) == BST_CHECKED?1:0)); - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLESTATUSLOCK, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLESTATUSLOCK) == BST_CHECKED?1:0)); - { - int curSel = SendDlgItemMessage(hwndDlg, IDC_AASTATUS, CB_GETCURSEL, 0, 0); - if (curSel != CB_ERR) { - DBWriteContactSettingWord(NULL, IDLEMOD, IDL_AASTATUS, (WORD)(aa_Status[curSel])); - } - } - DBWriteContactSettingByte(NULL, IDLEMOD, IDL_IDLESOUNDSOFF, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_IDLESOUNDSOFF) == BST_CHECKED)); - // destroy any current idle and reset settings. - IdleObject_Destroy(&gIdleObject); - IdleObject_Create(&gIdleObject); - } - break; - } - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_IDLE1STTIME: - { - int min; - if ((HWND)lParam != GetFocus() || HIWORD(wParam) != EN_CHANGE) return FALSE; - min = GetDlgItemInt(hwndDlg, IDC_IDLE1STTIME, NULL, FALSE); - if (min == 0 && GetWindowTextLength(GetDlgItem(hwndDlg, IDC_IDLE1STTIME))) - SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETPOS, 0, MAKELONG((short) 1, 0)); - break; - } - case IDC_IDLESHORT: - case IDC_AASHORTIDLE: - SendMessage(hwndDlg, WM_USER+2, 0, 0); - break; - - case IDC_AASTATUS: - if (HIWORD(wParam) != CBN_SELCHANGE) - return TRUE; - } - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } - return FALSE; -} - -static int IdleOptInit(WPARAM wParam, LPARAM) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize = sizeof(odp); - odp.position = 100000000; - odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_IDLE); - odp.pszGroup = LPGEN("Status"); - odp.pszTitle = LPGEN("Idle"); - odp.pfnDlgProc = IdleOptsDlgProc; - odp.flags = ODPF_BOLDGROUPS; - Options_AddPage(wParam, &odp); - return 0; -} - -static INT_PTR IdleGetInfo(WPARAM, LPARAM lParam) -{ - MIRANDA_IDLE_INFO *mii = (MIRANDA_IDLE_INFO*)lParam; - if ( !mii || (mii->cbSize != sizeof(MIRANDA_IDLE_INFO) && mii->cbSize != MIRANDA_IDLE_INFO_SIZE_1)) - return 1; - - mii->idleTime = gIdleObject.minutes; - mii->privacy = gIdleObject.state&0x10; - mii->aaStatus = gIdleObject.aastatus; - mii->aaLock = gIdleObject.state&0x20; - mii->idlesoundsoff = gIdleObject.aasoundsoff; - - if (mii->cbSize == sizeof(MIRANDA_IDLE_INFO)) - mii->idleType = gIdleObject.idleType; - return 0; -} - -static int IdleModernOptInit(WPARAM wParam, LPARAM) -{ - static const int iBoldControls[] = - { - IDC_TXT_TITLE1, IDC_TXT_TITLE2, IDC_TXT_TITLE3, - MODERNOPT_CTRL_LAST - }; - - MODERNOPTOBJECT obj = {0}; - obj.cbSize = sizeof(obj); - obj.hInstance = hInst; - obj.dwFlags = MODEROPT_FLG_TCHAR | MODEROPT_FLG_NORESIZE; - obj.iSection = MODERNOPT_PAGE_STATUS; - obj.iType = MODERNOPT_TYPE_SECTIONPAGE; - obj.iBoldControls = (int*)iBoldControls; - obj.lpzTemplate = MAKEINTRESOURCEA(IDD_MODERNOPT_IDLE); - obj.pfnDlgProc = IdleOptsDlgProc; -// obj.lpzClassicGroup = "Status"; -// obj.lpzClassicPage = "Messages"; - obj.lpzHelpUrl = "http://wiki.miranda-im.org/"; - CallService(MS_MODERNOPT_ADDOBJECT, wParam, (LPARAM)&obj); - return 0; -} - -int LoadIdleModule(void) -{ - bModuleInitialized = TRUE; - - bIsWTSApiPresent = InitWTSAPI(); - MyGetLastInputInfo = (BOOL (WINAPI *)(LASTINPUTINFO*))GetProcAddress(GetModuleHandleA("user32"), "GetLastInputInfo"); - hIdleEvent = CreateHookableEvent(ME_IDLE_CHANGED); - IdleObject_Create(&gIdleObject); - CreateServiceFunction(MS_IDLE_GETIDLEINFO, IdleGetInfo); - HookEvent(ME_OPT_INITIALISE, IdleOptInit); - HookEvent(ME_MODERNOPT_INITIALIZE, IdleModernOptInit); - return 0; -} - -void UnloadIdleModule() -{ - if ( !bModuleInitialized) return; - - IdleObject_Destroy(&gIdleObject); - DestroyHookableEvent(hIdleEvent); - hIdleEvent = NULL; -} diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index 16606ff990..04ac293b97 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -56,12 +56,11 @@ MuuidReplacement pluginDefault[] = { MIID_IDLE, _T("stdidle"), NULL }, // 7 { MIID_AUTOAWAY, _T("stdautoaway"), NULL }, // 8 { MIID_USERONLINE, _T("stduseronline"), NULL }, // 9 - { MIID_UPDATENOTIFY, _T("stdupdate"), NULL }, // 10 - { MIID_CLIST, NULL, NULL }, // 11 - { MIID_CHAT, NULL, NULL }, // 12 - { MIID_SRMM, NULL, NULL }, // 13 - { MIID_DATABASE, NULL, NULL }, // 14 + { MIID_CLIST, NULL, NULL }, // 10 + { MIID_CHAT, NULL, NULL }, // 11 + { MIID_SRMM, NULL, NULL }, // 12 + { MIID_DATABASE, NULL, NULL }, // 13 }; static BOOL bModuleInitialized = FALSE; diff --git a/src/modules/updatenotify/updatenotify.cpp b/src/modules/updatenotify/updatenotify.cpp deleted file mode 100644 index a223076062..0000000000 --- a/src/modules/updatenotify/updatenotify.cpp +++ /dev/null @@ -1,656 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/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 "..\..\core\commonheaders.h" - -#define UN_MOD "UpdateNotify" -#define UN_ENABLE "UpdateNotifyEnable" -#define UN_ENABLE_DEF 1 -#define UN_LASTCHECK "UpdateNotifyLastCheck" -#define UN_SERVERPERIOD "UpdateNotifyPingDelayPeriod" -#define UN_CURRENTVERSION "UpdateNotifyCurrentVersion" -#define UN_CURRENTVERSIONFND "UpdateNotifyCurrentVersionFound" -#define UN_NOTIFYTYPE "UpdateNotifyType" -#define UN_NOTIFYTYPE_STABLE 1 -#define UN_NOTIFYTYPE_BETA 2 -#define UN_NOTIFYTYPE_ALPHA 3 -#define UN_NOTIFYTYPE_DEF UN_NOTIFYTYPE_STABLE -#define UN_CUSTOMXMLURL "UpdateNotifyCustomXMLURL" -#define UN_URLXML "http://update.miranda-im.org/update.xml" -#define UN_MINCHECKTIME 60*60 /* Check no more than once an hour */ -#define UN_DEFAULTCHECKTIME 60*48*60 /* Default to check once every 48 hours */ -#define UN_FIRSTCHECK 15 /* First check 15 seconds after startup */ -#define UN_REPEATNOTIFYDLY 24*60*60 /* 24 hours before showing release notification again */ - -typedef struct { - int isNew; - int isManual; - char version[64]; - char versionReal[16]; - char notesUrl[256]; - char downloadUrl[256]; - DWORD reqTime; -} UpdateNotifyData; - -typedef struct { - DWORD dwVersion; - char *szVersionPublic; - char *szVersion; - char *szDownload; - char *szNotes; -} UpdateNotifyReleaseData; - -static BOOL bModuleInitialized = FALSE; -static HANDLE hNetlibUser = 0, hHookModules, hHookPreShutdown; -static UINT_PTR updateTimerId; -static HANDLE dwUpdateThreadID = 0; -static HWND hwndUpdateDlg = 0, hwndManualUpdateDlg = 0; -static XML_API xun; - -static int UpdateNotifyOptInit(WPARAM wParam, LPARAM lParam); -static INT_PTR UpdateNotifyMenuCommand(WPARAM wParam, LPARAM lParam); -static VOID CALLBACK UpdateNotifyTimerCheck(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime); -static int UpdateNotifyMakeRequest(UpdateNotifyData *und); -static void UpdateNotifyPerform(void *m); -static INT_PTR CALLBACK UpdateNotifyProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); - -static int UpdateNotifyModulesLoaded(WPARAM, LPARAM) { - NETLIBUSER nlu; - - ZeroMemory(&nlu, sizeof(nlu)); - nlu.cbSize = sizeof(nlu); - nlu.flags = NUF_OUTGOING|NUF_HTTPCONNS; - nlu.szSettingsModule = UN_MOD; - nlu.szDescriptiveName = Translate("Update notification"); - hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); - return 0; -} - -static int UpdateNotifyPreShutdown(WPARAM, LPARAM) { - if (IsWindow(hwndUpdateDlg)) { - SendMessage(hwndUpdateDlg, WM_COMMAND, MAKELONG(IDOK, 0), 0); - } - if (IsWindow(hwndManualUpdateDlg)) { - SendMessage(hwndManualUpdateDlg, WM_COMMAND, MAKELONG(IDOK, 0), 0); - } - return 0; -} - -int LoadUpdateNotifyModule(void) { - CLISTMENUITEM mi = { 0 }; - - bModuleInitialized = TRUE; - - // Upgrade Routine - if (DBGetContactSettingByte(NULL, UN_MOD, "UpdateNotifyNotifyAlpha", 0)) { - DBDeleteContactSetting(NULL, UN_MOD, "UpdateNotifyNotifyAlpha"); - DBWriteContactSettingByte(NULL, UN_MOD, UN_NOTIFYTYPE, UN_NOTIFYTYPE_ALPHA); - } - // Ene Upgrade Routine - - CreateServiceFunction("UpdateNotify/UpdateCommand", UpdateNotifyMenuCommand); - mi.cbSize = sizeof(mi); - mi.flags = CMIF_ICONFROMICOLIB; - mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_EMPTYBLOB); - mi.pszPopupName = LPGEN("&Help"); - mi.position = 2000030000; - mi.pszName = LPGEN("Check for Update"); - mi.pszService = "UpdateNotify/UpdateCommand"; - Menu_AddMainMenuItem(&mi); - - hHookModules = HookEvent(ME_SYSTEM_MODULESLOADED, UpdateNotifyModulesLoaded); - hHookPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, UpdateNotifyPreShutdown); - HookEvent(ME_OPT_INITIALISE, UpdateNotifyOptInit); - updateTimerId = SetTimer(NULL, 0, 1000*UN_FIRSTCHECK, UpdateNotifyTimerCheck); - mir_getXI(&xun); - return 0; -} - -void UnloadUpdateNotifyModule() -{ - if ( !bModuleInitialized) return; - UnhookEvent(hHookModules); - UnhookEvent(hHookPreShutdown); -} - -static int UpdateNotifyOptInit(WPARAM wParam, LPARAM) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize = sizeof(odp); - odp.position = 100000000; - odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_UPDATENOTIFY); - odp.pszGroup = LPGEN("Events"); - odp.pszTitle = LPGEN("Update Notify"); - odp.pfnDlgProc = UpdateNotifyOptsProc; - odp.flags = ODPF_BOLDGROUPS; - Options_AddPage(wParam, &odp); - return 0; -} - -static INT_PTR UpdateNotifyMenuCommand(WPARAM, LPARAM) { - UpdateNotifyData und; - - if (IsWindow(hwndManualUpdateDlg)) { - SetForegroundWindow(hwndManualUpdateDlg); - return 0; - } - ZeroMemory(&und, sizeof(und)); - UpdateNotifyMakeRequest(&und); - if (und.isNew) { - DBWriteContactSettingString(NULL, UN_MOD, UN_CURRENTVERSION, und.versionReal); - DBWriteContactSettingDword(NULL, UN_MOD, UN_CURRENTVERSIONFND, und.reqTime); - } - und.isManual = 1; - DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_UPDATE_NOTIFY), 0, UpdateNotifyProc, (LPARAM)&und); - hwndManualUpdateDlg = 0; - return 0; -} - -static VOID CALLBACK UpdateNotifyTimerCheck(HWND, UINT, UINT_PTR, DWORD) -{ - KillTimer(NULL, updateTimerId); - if ( !DBGetContactSettingByte(NULL, UN_MOD, UN_ENABLE, UN_ENABLE_DEF)) - return; - if (dwUpdateThreadID != 0) { - Netlib_Logf(hNetlibUser, "Update notification already running, ignoring attempt"); - return; - } - { - DWORD lastCheck = 0; - - if ( !hNetlibUser) - return; - lastCheck = DBGetContactSettingDword(NULL, UN_MOD, UN_LASTCHECK, 0); - if ( !lastCheck) { // never checked for update before - Netlib_Logf(hNetlibUser, "Running update notify check for the first time."); - dwUpdateThreadID = mir_forkthread(UpdateNotifyPerform, 0); - } - else { - DWORD dwNow = time(NULL), dwTimeDiff; - DWORD dwServerPing = DBGetContactSettingDword(NULL, UN_MOD, UN_SERVERPERIOD, UN_DEFAULTCHECKTIME); - - if (lastCheck>dwNow) { - // time for last check is after the current date so reset lastcheck and quit - DBWriteContactSettingDword(NULL, UN_MOD, UN_LASTCHECK, dwNow); - return; - } - dwTimeDiff = dwNow - lastCheck; - if (dwServerPingdwServerPing) - dwUpdateThreadID = mir_forkthread(UpdateNotifyPerform, 0); - } - updateTimerId = SetTimer(NULL, 0, 1000*UN_MINCHECKTIME, UpdateNotifyTimerCheck); - } -} - -static DWORD UpdateNotifyMakeVersion(char *str) { - DWORD a1, a2, a3, a4; - if ( !str) - return 0; - sscanf(str, "%u.%u.%u.%u", &a1, &a2, &a3, &a4); - return PLUGIN_MAKE_VERSION(a1, a2, a3, a4); -} - -inline bool UpdateNotifyIsNewer(DWORD dwCurrent, DWORD dwTest) -{ return dwTest > dwCurrent; } - -inline bool UpdateNotifyReleaseDataValid(UpdateNotifyReleaseData *d) -{ return d && d->szVersionPublic && d->szVersion && d->szDownload && d->szNotes; } - -static void UpdateNotifyFreeReleaseData(UpdateNotifyReleaseData *d) { - if ( !d) - return; - if (d->szVersionPublic) mir_free(d->szVersionPublic); - if (d->szVersion) mir_free(d->szVersion); - if (d->szDownload) mir_free(d->szDownload); - if (d->szNotes) mir_free(d->szNotes); -} - -static void UpdateNotifyReleaseLogUpdate(UpdateNotifyReleaseData *d) { - if ( !UpdateNotifyReleaseDataValid(d)) - return; - #ifdef _WIN64 - Netlib_Logf(hNetlibUser, "Update server version: %s [%s] [64-bit]", d->szVersionPublic, d->szVersion); - #else defined(_UNICODE) - Netlib_Logf(hNetlibUser, "Update server version: %s [%s] [Unicode]", d->szVersionPublic, d->szVersion); - #endif -} - -static void UpdateNotifyReleaseCopyData(UpdateNotifyReleaseData *d, UpdateNotifyData *und) { - if ( !UpdateNotifyReleaseDataValid(d) || !und) - return; - mir_snprintf(und->version, sizeof(und->version), "%s", d->szVersionPublic); - mir_snprintf(und->versionReal, sizeof(und->versionReal), "%s", d->szVersion); - mir_snprintf(und->notesUrl, sizeof(und->notesUrl), "%s", d->szNotes); - mir_snprintf(und->downloadUrl, sizeof(und->downloadUrl), "%s", d->szDownload); -} - -static int UpdateNotifyMakeRequest(UpdateNotifyData *und) { - NETLIBHTTPREQUEST req; - NETLIBHTTPREQUEST *resp; - NETLIBHTTPHEADER headers[1]; - DWORD dwVersion; - char szVersion[32], szUrl[256], szVersionText[128], szUserAgent[64]; - int isUnicode, isAlphaCheck, isBetaCheck; - DBVARIANT dbv; - - if ( !und) - return 0; - und->version[0] = 0; - und->versionReal[0] = 0; - und->notesUrl[0] = 0; - und->downloadUrl[0] = 0; - und->reqTime = time(NULL); - - DBWriteContactSettingDword(NULL, UN_MOD, UN_LASTCHECK, und->reqTime); - CallService(MS_SYSTEM_GETVERSIONTEXT, sizeof(szVersionText), (LPARAM)szVersionText); - isUnicode = strstr(szVersionText, "Unicode") != NULL ? 1 : 0; - isBetaCheck = DBGetContactSettingByte(NULL, UN_MOD, UN_NOTIFYTYPE, UN_NOTIFYTYPE_DEF) == UN_NOTIFYTYPE_BETA?1:0; - isAlphaCheck = DBGetContactSettingByte(NULL, UN_MOD, UN_NOTIFYTYPE, UN_NOTIFYTYPE_DEF) == UN_NOTIFYTYPE_ALPHA?1:0; - dwVersion = CallService(MS_SYSTEM_GETVERSION, 0, 0); - mir_snprintf(szVersion, sizeof(szVersion), "%d.%d.%d.%d", - HIBYTE(HIWORD(dwVersion)), LOBYTE(HIWORD(dwVersion)), - HIBYTE(LOWORD(dwVersion)), LOBYTE(LOWORD(dwVersion))); - if ( !DBGetContactSettingString(NULL, UN_MOD, UN_CUSTOMXMLURL, &dbv)) { - mir_snprintf(szUrl, sizeof(szUrl), "%s", dbv.pszVal?dbv.pszVal:UN_URLXML); - DBFreeVariant(&dbv); - } - else mir_snprintf(szUrl, sizeof(szUrl), "%s", UN_URLXML); - ZeroMemory(&req, sizeof(req)); - req.cbSize = sizeof(req); - req.requestType = REQUEST_GET; - req.szUrl = szUrl; - req.flags = 0; - headers[0].szName = "User-Agent"; - headers[0].szValue = szUserAgent; - #ifdef _WIN64 - mir_snprintf(szUserAgent, sizeof(szUserAgent), "Miranda/%s (x64)", szVersion); - #else defined(_UNICODE) - mir_snprintf(szUserAgent, sizeof(szUserAgent), "Miranda/%s (Unicode)", szVersion); - #endif - req.headersCount = 1; - req.headers = headers; - resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&req); - if (resp) { - if (resp->resultCode == 200 && resp->dataLength > 0) { - //int i; - int resUpdate = 0; - TCHAR *tXml; - char *tmp; - HXML nodeDoc, n; - - tXml = mir_a2t(resp->pData); - nodeDoc = xun.parseString(tXml, 0, _T("miranda")); - if (nodeDoc) { - int rdStableValid = 0, rdBetaValid = 0, rdAlphaValid = 0; - // stable release - UpdateNotifyReleaseData rdStable; - ZeroMemory(&rdStable, sizeof(rdStable)); - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasestable/versionpublic"), 0)) != NULL && xun.getText(n)) { - rdStable.szVersionPublic = mir_t2a(xun.getText(n)); - } - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasestable/versionreal"), 0)) != NULL && xun.getText(n)) { - rdStable.szVersion = mir_t2a(xun.getText(n)); - if (rdStable.szVersion) - rdStable.dwVersion = UpdateNotifyMakeVersion(rdStable.szVersion); - } - #ifdef _WIN64 - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasestable/downloadx64exe"), 0)) != NULL && xun.getText(n)) { - rdStable.szDownload = mir_t2a(xun.getText(n)); - } - #else defined(_UNICODE) - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasestable/downloadunicodeexe"), 0)) != NULL && xun.getText(n)) { - rdStable.szDownload = mir_t2a(xun.getText(n)); - } - #endif - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasestable/notesurl"), 0)) != NULL && xun.getText(n)) { - rdStable.szNotes = mir_t2a(xun.getText(n)); - } - rdStableValid = UpdateNotifyReleaseDataValid(&rdStable); - - // beta release - UpdateNotifyReleaseData rdBeta; - ZeroMemory(&rdBeta, sizeof(rdBeta)); - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasebeta/versionpublic"), 0)) != NULL && xun.getText(n)) { - rdBeta.szVersionPublic = mir_t2a(xun.getText(n)); - } - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasebeta/versionreal"), 0)) != NULL && xun.getText(n)) { - rdBeta.szVersion = mir_t2a(xun.getText(n)); - if (rdBeta.szVersion) - rdBeta.dwVersion = UpdateNotifyMakeVersion(rdBeta.szVersion); - } - #ifdef _WIN64 - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasebeta/downloadx64zip"), 0)) != NULL && xun.getText(n)) { - rdBeta.szDownload = mir_t2a(xun.getText(n)); - } - #else defined(_UNICODE) - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasebeta/downloadunicodeexe"), 0)) != NULL && xun.getText(n)) { - rdBeta.szDownload = mir_t2a(xun.getText(n)); - } - #endif - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasebeta/notesurl"), 0)) != NULL && xun.getText(n)) { - rdBeta.szNotes = mir_t2a(xun.getText(n)); - } - rdBetaValid = UpdateNotifyReleaseDataValid(&rdBeta); - - // alpha release - UpdateNotifyReleaseData rdAlpha; - ZeroMemory(&rdAlpha, sizeof(rdAlpha)); - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasealpha/versionpublic"), 0)) != NULL && xun.getText(n)) { - rdAlpha.szVersionPublic = mir_t2a(xun.getText(n)); - } - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasealpha/versionreal"), 0)) != NULL && xun.getText(n)) { - rdAlpha.szVersion = mir_t2a(xun.getText(n)); - if (rdAlpha.szVersion) - rdAlpha.dwVersion = UpdateNotifyMakeVersion(rdAlpha.szVersion); - } - #ifdef _WIN64 - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasealpha/downloadx64zip"), 0)) != NULL && xun.getText(n)) { - rdAlpha.szDownload = mir_t2a(xun.getText(n)); - } - #else defined(_UNICODE) - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasealpha/downloadunicodezip"), 0)) != NULL && xun.getText(n)) { - rdAlpha.szDownload = mir_t2a(xun.getText(n)); - } - #endif - if ((n = xun.getChildByPath(nodeDoc, _T("releases/releasealpha/notesurl"), 0)) != NULL && xun.getText(n)) { - rdAlpha.szNotes = mir_t2a(xun.getText(n)); - } - rdAlphaValid = UpdateNotifyReleaseDataValid(&rdAlpha); - - if (isBetaCheck) { - if ( !rdBetaValid && rdStableValid) { - UpdateNotifyReleaseLogUpdate(&rdStable); - if (UpdateNotifyIsNewer(dwVersion, rdStable.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdStable, und); - } - else if (rdBetaValid && rdStableValid && UpdateNotifyIsNewer(rdBeta.dwVersion, rdStable.dwVersion)) { - UpdateNotifyReleaseLogUpdate(&rdStable); - if (UpdateNotifyIsNewer(dwVersion, UpdateNotifyMakeVersion(rdStable.szVersion))) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdStable, und); - } - else if (rdBetaValid) { - UpdateNotifyReleaseLogUpdate(&rdBeta); - if (UpdateNotifyIsNewer(dwVersion, rdBeta.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdBeta, und); - } - } - else if (isAlphaCheck) { - if ( !rdAlphaValid && rdStableValid) { - if (UpdateNotifyIsNewer(rdStable.dwVersion, rdAlpha.dwVersion)) { - UpdateNotifyReleaseLogUpdate(&rdAlpha); - if (UpdateNotifyIsNewer(dwVersion, rdAlpha.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdAlpha, und); - } - else { - UpdateNotifyReleaseLogUpdate(&rdStable); - if (UpdateNotifyIsNewer(dwVersion, rdStable.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdStable, und); - } - } - else if (rdAlphaValid && rdStableValid && UpdateNotifyIsNewer(rdAlpha.dwVersion, rdStable.dwVersion)) { - UpdateNotifyReleaseLogUpdate(&rdStable); - if (UpdateNotifyIsNewer(dwVersion, rdStable.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdStable, und); - } - else if ( !rdAlphaValid && rdBetaValid && rdStableValid) { - if (UpdateNotifyIsNewer(rdStable.dwVersion, rdBeta.dwVersion)) { - UpdateNotifyReleaseLogUpdate(&rdBeta); - if (UpdateNotifyIsNewer(dwVersion, rdBeta.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdBeta, und); - } - else { - UpdateNotifyReleaseLogUpdate(&rdStable); - if (UpdateNotifyIsNewer(dwVersion, rdStable.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdStable, und); - } - } - else if (rdAlphaValid) { - UpdateNotifyReleaseLogUpdate(&rdAlpha); - if (UpdateNotifyIsNewer(dwVersion, rdAlpha.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdAlpha, und); - } - } - else { - if (rdStableValid) { - UpdateNotifyReleaseLogUpdate(&rdStable); - if (UpdateNotifyIsNewer(dwVersion, rdStable.dwVersion)) - resUpdate = 1; - UpdateNotifyReleaseCopyData(&rdStable, und); - } - } - - UpdateNotifyFreeReleaseData(&rdStable); - UpdateNotifyFreeReleaseData(&rdBeta); - UpdateNotifyFreeReleaseData(&rdAlpha); - // settings - if ((n = xun.getChildByPath(nodeDoc, _T("settings/ping"), 0)) != NULL && xun.getText(n)) { - tmp = mir_t2a(xun.getText(n)); - if (tmp) { - int pingval = atoi(tmp); - if ((pingval*60*60)>UN_MINCHECKTIME) { - Netlib_Logf(hNetlibUser, "Next update check in %d hours", pingval); - DBWriteContactSettingDword(NULL, UN_MOD, UN_SERVERPERIOD, pingval*60*60); - } - mir_free(tmp); - } - } - if ((n = xun.getChildByPath(nodeDoc, _T("settings/updateurl"), 0)) != NULL && xun.getText(n)) { - tmp = mir_t2a(xun.getText(n)); - if (tmp) { - Netlib_Logf(hNetlibUser, "Update URL has changed (%s)", tmp); - DBWriteContactSettingString(NULL, UN_MOD, UN_CUSTOMXMLURL, tmp); - mir_free(tmp); - } - } - if (resUpdate && und->version && und->versionReal && und->notesUrl && und->downloadUrl) { - Netlib_Logf(hNetlibUser, "A new version of Miranda IM is available: %s", und->version); - und->isNew = 1; - } - xun.destroyNode(nodeDoc); - } - mir_free(tXml); - } - else Netlib_Logf(hNetlibUser, "Invalid response code from HTTP request"); - CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp); - } - else Netlib_Logf(hNetlibUser, "No response from HTTP request"); - return und->isNew; -} - -static void UpdateNotifyPerform(void *) -{ - UpdateNotifyData und; - DBVARIANT dbv; - - ZeroMemory(&und, sizeof(und)); - UpdateNotifyMakeRequest(&und); - if (und.isNew) { - int notify = 1; - - if ( !DBGetContactSettingString(NULL, UN_MOD, UN_CURRENTVERSION, &dbv)) { - if ( !strcmp(dbv.pszVal, und.versionReal)) { // already notified of this version - - DWORD dwNotifyLast = DBGetContactSettingDword(NULL, UN_MOD, UN_CURRENTVERSIONFND, 0); - - if (dwNotifyLast>und.reqTime) { // fix last check date if time has changed - DBWriteContactSettingDword(NULL, UN_MOD, UN_CURRENTVERSIONFND, und.reqTime); - notify = 0; - } - else if (und.reqTime-dwNotifyLastisManual) - hwndManualUpdateDlg = hwndDlg; - else hwndUpdateDlg = hwndDlg; - if (und->isNew) { - TCHAR* ptszVer = mir_a2t(und->version); - mir_sntprintf(szTmp, SIZEOF(szTmp), TranslateT("Miranda IM %s Now Available"), ptszVer); - mir_free(ptszVer); - ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATE), SW_HIDE); - } - else { - mir_sntprintf(szTmp, SIZEOF(szTmp), TranslateT("No Update Available")); - SetDlgItemText(hwndDlg, IDC_MESSAGE, TranslateT("You are running the latest version of Miranda IM. No update is available at this time.")); - EnableWindow(GetDlgItem(hwndDlg, IDC_DOWNLOAD), FALSE); - ShowWindow(GetDlgItem(hwndDlg, IDC_VERSION), SW_HIDE); - } - SetWindowText(hwndDlg, szTmp); - CallService(MS_SYSTEM_GETVERSIONTEXT, sizeof(szVersion), (LPARAM)szVersion); - p = strstr(szVersion, "x64 Unicode"); - if (p) - *p = '\0'; - p = strstr(szVersion, " Unicode"); - if (p) - *p = '\0'; - SetDlgItemTextA(hwndDlg, IDC_CURRENTVERSION, szVersion); - mir_snprintf(szVersionTmp, SIZEOF(szVersionTmp), "%s", und->version?und->version:szVersion); - SetDlgItemTextA(hwndDlg, und->isNew?IDC_VERSION:IDC_UPDATE, szVersionTmp); - if (und->isNew) { - HFONT hFont; - LOGFONT lf; - - hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_VERSION, WM_GETFONT, 0, 0); - GetObject(hFont, sizeof(lf), &lf); - lf.lfWeight = FW_BOLD; - hFont = CreateFontIndirect(&lf); - SendDlgItemMessage(hwndDlg, IDC_VERSION, WM_SETFONT, (WPARAM)hFont, 0); - hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_NEWVERSIONLABEL, WM_GETFONT, 0, 0); - GetObject(hFont, sizeof(lf), &lf); - lf.lfWeight = FW_BOLD; - hFont = CreateFontIndirect(&lf); - SendDlgItemMessage(hwndDlg, IDC_NEWVERSIONLABEL, WM_SETFONT, (WPARAM)hFont, 0); - } - SetFocus(GetDlgItem(hwndDlg, IDOK)); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - } - break; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_VERSION: - { - UpdateNotifyData *und = (UpdateNotifyData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - if (und && und->notesUrl) - CallService(MS_UTILS_OPENURL, 1, (LPARAM)und->notesUrl); - break; - } - case IDC_DOWNLOAD: - { - UpdateNotifyData *und = (UpdateNotifyData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - if (und && und->downloadUrl) { - CallService(MS_UTILS_OPENURL, 1, (LPARAM)und->downloadUrl); - DestroyWindow(hwndDlg); - } - break; - } - case IDOK: - case IDCANCEL: - DestroyWindow(hwndDlg); - return TRUE; - } - break; - - case WM_DESTROY: - Window_FreeIcon_IcoLib(hwndDlg); - break; - } - return FALSE; -} - -static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - CheckDlgButton(hwndDlg, IDC_ENABLEUPDATES, DBGetContactSettingByte(NULL, UN_MOD, UN_ENABLE, UN_ENABLE_DEF) ? BST_CHECKED : BST_UNCHECKED); - switch (DBGetContactSettingByte(NULL, UN_MOD, UN_NOTIFYTYPE, UN_NOTIFYTYPE_STABLE)) { - case UN_NOTIFYTYPE_BETA: CheckDlgButton(hwndDlg, IDC_ENABLEBETA, BST_CHECKED); break; - case UN_NOTIFYTYPE_ALPHA: CheckDlgButton(hwndDlg, IDC_ENABLEALPHA, BST_CHECKED); break; - default: CheckDlgButton(hwndDlg, IDC_ENABLESTABLE, BST_CHECKED); break; - } - return TRUE; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_ENABLEUPDATES: - case IDC_ENABLEALPHA: - case IDC_ENABLEBETA: - case IDC_ENABLESTABLE: - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } - break; - - case WM_NOTIFY: - { - NMHDR *hdr = (NMHDR *)lParam; - if (hdr && hdr->code == PSN_APPLY) { - DBWriteContactSettingByte(NULL, UN_MOD, UN_ENABLE, (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_ENABLEUPDATES))); - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLESTABLE)) - DBWriteContactSettingByte(NULL, UN_MOD, UN_NOTIFYTYPE, UN_NOTIFYTYPE_STABLE); - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLEBETA)) - DBWriteContactSettingByte(NULL, UN_MOD, UN_NOTIFYTYPE, UN_NOTIFYTYPE_BETA); - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLEALPHA)) - DBWriteContactSettingByte(NULL, UN_MOD, UN_NOTIFYTYPE, UN_NOTIFYTYPE_ALPHA); - } - break; - } - } - return FALSE; -} diff --git a/src/modules/useronline/useronline.cpp b/src/modules/useronline/useronline.cpp deleted file mode 100644 index e6f5148f50..0000000000 --- a/src/modules/useronline/useronline.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/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 "..\..\core\commonheaders.h" - -static int uniqueEventId = 0; - -static int UserOnlineSettingChanged(WPARAM wParam, LPARAM lParam) -{ - DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; - int newStatus, oldStatus; - - if ((HANDLE)wParam == NULL || strcmp(cws->szSetting, "Status")) return 0; - newStatus = cws->value.wVal; - oldStatus = DBGetContactSettingWord((HANDLE)wParam, "UserOnline", "OldStatus", ID_STATUS_OFFLINE); - DBWriteContactSettingWord((HANDLE)wParam, "UserOnline", "OldStatus", (WORD)newStatus); - if (CallService(MS_IGNORE_ISIGNORED, wParam, IGNOREEVENT_USERONLINE)) return 0; - if (DBGetContactSettingByte((HANDLE)wParam, "CList", "Hidden", 0)) return 0; - if (newStatus == ID_STATUS_OFFLINE && oldStatus != ID_STATUS_OFFLINE) { - // Remove the event from the queue if it exists since they are now offline - int lastEvent = (int)DBGetContactSettingDword((HANDLE)wParam, "UserOnline", "LastEvent", 0); - - if (lastEvent) { - CallService(MS_CLIST_REMOVEEVENT, wParam, (LPARAM)lastEvent); - DBWriteContactSettingDword((HANDLE)wParam, "UserOnline", "LastEvent", 0); - } - } - if ((newStatus == ID_STATUS_ONLINE || newStatus == ID_STATUS_FREECHAT) && - oldStatus != ID_STATUS_ONLINE && oldStatus != ID_STATUS_FREECHAT) { - { - DWORD ticked = db_dword_get(NULL, "UserOnline", cws->szModule, GetTickCount()); - // only play the sound (or show event) if this event happens at least 10 secs after the proto went from offline - if (GetTickCount() - ticked > (1000*10)) { - CLISTEVENT cle; - TCHAR tooltip[256]; - - ZeroMemory(&cle, sizeof(cle)); - cle.cbSize = sizeof(cle); - cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR; - cle.hContact = (HANDLE)wParam; - cle.hDbEvent = (HANDLE)(uniqueEventId++); - cle.hIcon = LoadSkinIcon(SKINICON_OTHER_USERONLINE, false); - cle.pszService = "UserOnline/Description"; - mir_sntprintf(tooltip, SIZEOF(tooltip), TranslateT("%s is Online"), cli.pfnGetContactDisplayName((HANDLE)wParam, 0)); - cle.ptszTooltip = tooltip; - CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); - IcoLib_ReleaseIcon(cle.hIcon, 0); - DBWriteContactSettingDword(cle.hContact, "UserOnline", "LastEvent", (DWORD)cle.hDbEvent); - SkinPlaySound("UserOnline"); - } - } - } - return 0; -} - -static int UserOnlineAck(WPARAM, LPARAM lParam) -{ - ACKDATA * ack = (ACKDATA*) lParam; - if (ack != 0 && ack->szModule && ack->type == ACKTYPE_STATUS && ack->result == ACKRESULT_SUCCESS && ack->hProcess == (HANDLE)ID_STATUS_OFFLINE) { - // if going from offline to any other mode, remember when it happened. - db_dword_set(NULL, "UserOnline", ack->szModule, GetTickCount()); - } - return 0; -} - -static int UserOnlineModulesLoaded(WPARAM, LPARAM) -{ - // reset the counter - for (int j = 0; j < accounts.getCount(); j++) - if (Proto_IsAccountEnabled(accounts[j])) db_dword_set(NULL, "UserOnline", accounts[j]->szModuleName, GetTickCount()); - - return 0; -} - -static int UserOnlineAccountsChanged(WPARAM eventCode, LPARAM lParam) -{ - PROTOACCOUNT* pa = (PROTOACCOUNT*)lParam; - - switch(eventCode) { - case PRAC_ADDED: - case PRAC_CHECKED: - // reset the counter - if (Proto_IsAccountEnabled(pa)) - db_dword_set(NULL, "UserOnline", pa->szModuleName, GetTickCount()); - break; - } - return 0; -} - -int LoadUserOnlineModule(void) -{ - HookEvent(ME_DB_CONTACT_SETTINGCHANGED, UserOnlineSettingChanged); - HookEvent(ME_PROTO_ACK, UserOnlineAck); - HookEvent(ME_SYSTEM_MODULESLOADED, UserOnlineModulesLoaded); - HookEvent(ME_PROTO_ACCLISTCHANGED, UserOnlineAccountsChanged); - SkinAddNewSoundEx("UserOnline", LPGEN("Alerts"), LPGEN("Online")); - return 0; -} diff --git a/src/resource.rc b/src/resource.rc index 9efc5754b2..62fa74bcb3 100644 --- a/src/resource.rc +++ b/src/resource.rc @@ -59,22 +59,6 @@ BEGIN EDITTEXT IDC_AUTHREQ,13,89,204,29,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL END -IDD_ABOUT DIALOGEX 0, 0, 212, 131 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "About Miranda IM" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - CONTROL "Miranda IM\n%s",IDC_HEADERBAR,"MHeaderbarCtrl",WS_TABSTOP,0,0,212,25 - LTEXT "",IDC_WHITERECT,0,25,213,81 - DEFPUSHBUTTON "OK",IDOK,152,112,55,14 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,106,213,1 - LTEXT "",IDC_DEVS,5,32,202,42 - EDITTEXT IDC_BUILDTIME,4,91,146,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - PUSHBUTTON "Credits >",IDC_CONTRIBLINK,5,112,55,14 - EDITTEXT IDC_CREDITSFILE,4,32,202,67,ES_CENTER | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL -END - IDD_DELETECONTACT DIALOGEX 0, 0, 294, 93 STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_CONTROLPARENT @@ -293,31 +277,6 @@ BEGIN CONTROL "SSL Traffic",IDC_DUMPSSL,"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,181,56,122,10 END -IDD_HISTORY_FIND DIALOGEX 0, 0, 230, 46 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "Find" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - EDITTEXT IDC_FINDWHAT,48,11,115,12,ES_AUTOHSCROLL - DEFPUSHBUTTON "&Find Next",IDOK,173,7,50,14 - PUSHBUTTON "Cancel",IDCANCEL,173,24,50,14 - LTEXT "Find What:",IDC_STATIC,7,13,39,9 -END - -IDD_HISTORY DIALOGEX 0, 0, 296, 166 -STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "Message History" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Close",IDOK,239,144,50,14 - EDITTEXT IDC_EDIT,7,83,282,52,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL - LISTBOX IDC_LIST,7,7,282,72,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "&Find...",IDC_FIND,7,144,50,14 - PUSHBUTTON "Delete",IDC_DELETEHISTORY,66,144,50,14 -END - IDD_OPT_SOUND DIALOGEX 0, 0, 285, 240 STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE EXSTYLE WS_EX_CONTROLPARENT @@ -466,37 +425,6 @@ BEGIN CTEXT "You will need to reconnect for the changes you have made on this page to take effect.",IDC_RECONNECTREQD,4,224,307,8,NOT WS_VISIBLE END -IDD_OPT_IDLE DIALOGEX 0, 0, 312, 193 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_BORDER -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_WRAP | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,71,55,12,23 - 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 (2000/XP+ only)",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,91,61,76,9 - RTEXT "for",IDC_STATIC,12,59,41,9 - 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 - IDD_PROFILE_SELECTION DIALOGEX 0, 0, 386, 142 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN EXSTYLE WS_EX_CONTROLPARENT @@ -655,36 +583,6 @@ BEGIN PUSHBUTTON "Reset",IDC_RESETPROTOCOLDATA,120,140,50,14,BS_NOTIFY END -IDD_UPDATE_NOTIFY DIALOGEX 0, 0, 259, 103 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Miranda IM v%s Now Available" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "A new version of Miranda IM is now available. Click the download button to download this new update.",IDC_MESSAGE,7,7,245,21 - LTEXT "Latest Version:",IDC_NEWVERSIONLABEL,7,47,65,8 - LTEXT "Your Version:",IDC_STATIC,7,32,65,8 - LTEXT "",IDC_CURRENTVERSION,77,32,97,8 - CONTROL "",IDC_VERSION,"Hyperlink",WS_TABSTOP,77,47,97,8 - LTEXT "",IDC_UPDATE,77,47,97,8 - PUSHBUTTON "&Download Now",IDC_DOWNLOAD,7,61,66,15 - DEFPUSHBUTTON "&Close",IDOK,202,84,50,15 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,80,245,1 -END - -IDD_OPT_UPDATENOTIFY DIALOGEX 0, 0, 268, 94 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - GROUPBOX "Update Notification Options",IDC_STATIC,2,0,265,94 - CONTROL "Automatically check for new versions of Miranda IM",IDC_ENABLEUPDATES, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,13,237,10 - LTEXT "Check for updates for the following:",IDC_STATIC,12,32,230,8 - CONTROL "Stable releases",IDC_ENABLESTABLE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,25,46,230,10 - CONTROL "Preview releases (beta)",IDC_ENABLEBETA,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,25,61,230,10 - CONTROL "Development releases (alpha)",IDC_ENABLEALPHA,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,25,76,230,10 -END - IDD_OPT_KEYBINDINGS DIALOGEX 0, 0, 316, 251 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT @@ -849,33 +747,6 @@ BEGIN LISTBOX IDC_LST_STATUS,10,13,90,95,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP END -IDD_MODERNOPT_IDLE DIALOGEX 0, 0, 369, 64 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CONTROL "Become idle if computer is left unattended for:",IDC_IDLESHORT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,13,171,9 - CONTROL "Windows",IDC_IDLEONWINDOWS,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE,325,25,26,9 - CONTROL "Miranda",IDC_IDLEONMIRANDA,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE,287,37,15,9 - EDITTEXT IDC_IDLE1STTIME,181,11,27,12,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "",IDC_IDLESPIN,"msctls_updown32",UDS_WRAP | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,193,7,11,23 - CONTROL "Become idle if the screen saver is active",IDC_SCREENSAVER, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,25,268,9 - CONTROL "Become idle if the computer is locked (2000/XP+ only)",IDC_LOCKED, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,37,249,9 - CONTROL "Become idle if a terminal session is disconnected",IDC_IDLETERMINAL, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,49,265,10 - CONTROL "Do not let protocols report any idle information",IDC_IDLEPRIVATE, - "Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,303,13,22,9 - LTEXT "minute(s)",IDC_STATIC,213,13,76,9,SS_CENTERIMAGE - COMBOBOX IDC_AASTATUS,325,46,23,50,CBS_DROPDOWNLIST | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP - CONTROL "Change my status mode to:",IDC_AASHORTIDLE,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,334,11,23,11 - CONTROL "Do not set status back to online when returning from idle",IDC_IDLESTATUSLOCK, - "Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,299,24,16,10 - LTEXT "Idle (auto-away):",IDC_TXT_TITLE1,0,0,246,8 -END - IDD_MODERNOPT_IGNORE DIALOGEX 0, 0, 369, 210 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT @@ -925,14 +796,6 @@ BEGIN BOTTOMMARGIN, 144 END - IDD_ABOUT, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 207 - TOPMARGIN, 7 - BOTTOMMARGIN, 126 - END - IDD_DELETECONTACT, DIALOG BEGIN LEFTMARGIN, 7 @@ -1051,23 +914,6 @@ BEGIN BOTTOMMARGIN, 255 END - IDD_HISTORY_FIND, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 223 - TOPMARGIN, 7 - BOTTOMMARGIN, 39 - HORZGUIDE, 17 - END - - IDD_HISTORY, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 289 - TOPMARGIN, 7 - BOTTOMMARGIN, 158 - END - IDD_OPT_SOUND, DIALOG BEGIN LEFTMARGIN, 4 @@ -1141,21 +987,6 @@ BEGIN TOPMARGIN, 4 END - IDD_UPDATE_NOTIFY, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 179 - TOPMARGIN, 7 - BOTTOMMARGIN, 83 - END - - IDD_OPT_UPDATENOTIFY, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 179 - TOPMARGIN, 7 - END - IDD_ACCMGR, DIALOG BEGIN VERTGUIDE, 7 -- cgit v1.2.3