From 48540940b6c28bb4378abfeb500ec45a625b37b6 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Tue, 15 May 2012 10:38:20 +0000 Subject: initial commit git-svn-id: http://svn.miranda-ng.org/main/trunk@2 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Sessions/Icons/Checked.ico | Bin 0 -> 2038 bytes plugins/Sessions/Icons/Load.ico | Bin 0 -> 1150 bytes plugins/Sessions/Icons/Loadlast.ico | Bin 0 -> 1150 bytes plugins/Sessions/Icons/Save.ico | Bin 0 -> 1150 bytes plugins/Sessions/Icons/Sessions.ico | Bin 0 -> 1150 bytes plugins/Sessions/Icons/Unchecked.ico | Bin 0 -> 2038 bytes plugins/Sessions/Resource.h | 58 ++ plugins/Sessions/Sessions.rc | 237 ++++++ plugins/Sessions/Sessions_10.sln | 25 + plugins/Sessions/Sessions_10.vcxproj | 259 ++++++ plugins/Sessions/Sessions_10.vcxproj.filters | 73 ++ plugins/Sessions/Sessions_8.vcproj | 547 +++++++++++++ plugins/Sessions/Src/Main.cpp | 1089 ++++++++++++++++++++++++++ plugins/Sessions/Src/Options.cpp | 572 ++++++++++++++ plugins/Sessions/Src/Sessions.h | 92 +++ plugins/Sessions/Src/Utils.cpp | 571 ++++++++++++++ plugins/Sessions/Src/Utils.h | 45 ++ plugins/Sessions/Version.h | 28 + plugins/Sessions/Version.rc | 38 + 19 files changed, 3634 insertions(+) create mode 100644 plugins/Sessions/Icons/Checked.ico create mode 100644 plugins/Sessions/Icons/Load.ico create mode 100644 plugins/Sessions/Icons/Loadlast.ico create mode 100644 plugins/Sessions/Icons/Save.ico create mode 100644 plugins/Sessions/Icons/Sessions.ico create mode 100644 plugins/Sessions/Icons/Unchecked.ico create mode 100644 plugins/Sessions/Resource.h create mode 100644 plugins/Sessions/Sessions.rc create mode 100644 plugins/Sessions/Sessions_10.sln create mode 100644 plugins/Sessions/Sessions_10.vcxproj create mode 100644 plugins/Sessions/Sessions_10.vcxproj.filters create mode 100644 plugins/Sessions/Sessions_8.vcproj create mode 100644 plugins/Sessions/Src/Main.cpp create mode 100644 plugins/Sessions/Src/Options.cpp create mode 100644 plugins/Sessions/Src/Sessions.h create mode 100644 plugins/Sessions/Src/Utils.cpp create mode 100644 plugins/Sessions/Src/Utils.h create mode 100644 plugins/Sessions/Version.h create mode 100644 plugins/Sessions/Version.rc (limited to 'plugins/Sessions') diff --git a/plugins/Sessions/Icons/Checked.ico b/plugins/Sessions/Icons/Checked.ico new file mode 100644 index 0000000000..e19208cdb3 Binary files /dev/null and b/plugins/Sessions/Icons/Checked.ico differ diff --git a/plugins/Sessions/Icons/Load.ico b/plugins/Sessions/Icons/Load.ico new file mode 100644 index 0000000000..448a2e907d Binary files /dev/null and b/plugins/Sessions/Icons/Load.ico differ diff --git a/plugins/Sessions/Icons/Loadlast.ico b/plugins/Sessions/Icons/Loadlast.ico new file mode 100644 index 0000000000..a86082e547 Binary files /dev/null and b/plugins/Sessions/Icons/Loadlast.ico differ diff --git a/plugins/Sessions/Icons/Save.ico b/plugins/Sessions/Icons/Save.ico new file mode 100644 index 0000000000..9d19bff626 Binary files /dev/null and b/plugins/Sessions/Icons/Save.ico differ diff --git a/plugins/Sessions/Icons/Sessions.ico b/plugins/Sessions/Icons/Sessions.ico new file mode 100644 index 0000000000..823c49aa17 Binary files /dev/null and b/plugins/Sessions/Icons/Sessions.ico differ diff --git a/plugins/Sessions/Icons/Unchecked.ico b/plugins/Sessions/Icons/Unchecked.ico new file mode 100644 index 0000000000..30331f14d8 Binary files /dev/null and b/plugins/Sessions/Icons/Unchecked.ico differ diff --git a/plugins/Sessions/Resource.h b/plugins/Sessions/Resource.h new file mode 100644 index 0000000000..0a70198bcf --- /dev/null +++ b/plugins/Sessions/Resource.h @@ -0,0 +1,58 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by sessions.rc +// +#define IDD_OPTIONS 101 +#define IDI_SESSIONS 102 +#define IDI_SESSIONS_LOAD 103 +#define IDD_SESSIONS_SAVE 104 +#define IDD_SESSIONS_LOADLAST 105 + +#define IDD_SESSION_CHECKED 106 +#define IDD_SESSION_UNCHECKED 107 + +#define IDD_WLCMDIALOG 120 +#define IDD_SAVEDIALOG 121 +#define IDD_EXDIALOG 123 +#define IDC_LIST 1020 +#define IDC_STARTDIALOG 1021 +#define IDC_STARTDELAY 1022 +#define IDC_STATICMS 1023 +#define IDC_STATICOP 1024 +#define IDC_SANDCCHECK 1025 +#define IDC_SESSDEL 1026 +#define IDC_ADDTOMENU 1027 +#define IDC_SELCONTACTS 1029 +#define IDC_CLIST 1032 +#define IDC_ADDTBUTTON 1033 +#define IDC_OPCLIST 1034 +#define IDC_DEL 1036 +#define IDC_EDIT 1037 +#define IDC_SAVE 1038 +#define IDC_EMCLIST 1039 +#define IDC_REXSAVE 1040 +#define IDC_REXDSAVE 1041 +#define IDC_REXASK 1043 +#define IDC_RLOADLAST 1045 +#define IDC_RNOTHING 1047 +#define IDC_CHECKLAST 1049 +#define IDC_TRACK 1051 +#define IDC_SPIN1 1052 +#define IDC_EXSTATIC1 1054 +#define IDC_EXSTATIC2 1055 +#define IDC_EXCLHIDDEN 1056 +#define IDC_LASTHIDDENWARN 1057 +#define IDC_WARNINGS 1058 +#define IDC_CRASHRECOVERY 1059 +#define IDC_STATIC -1 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 124 +#define _APS_NEXT_COMMAND_VALUE 40015 +#define _APS_NEXT_CONTROL_VALUE 1059 +#define _APS_NEXT_SYMED_VALUE 1125 +#endif +#endif diff --git a/plugins/Sessions/Sessions.rc b/plugins/Sessions/Sessions.rc new file mode 100644 index 0000000000..7f430930a0 --- /dev/null +++ b/plugins/Sessions/Sessions.rc @@ -0,0 +1,237 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Neutral resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#pragma code_page(1251) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "version.rc\0" +END + +2 TEXTINCLUDE +BEGIN + "#include \r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPTIONS DIALOGEX 0, 0, 303, 246 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "Action on Startup",IDC_STATIC,6,11,157,75 + CONTROL "Open Sessions Manager dialog",IDC_STARTDIALOG,"Button",BS_AUTORADIOBUTTON | WS_GROUP,9,21,144,10 + CONTROL "Restore Last Session",IDC_RLOADLAST,"Button",BS_AUTORADIOBUTTON,9,42,144,10 + CONTROL "Do nothing",IDC_RNOTHING,"Button",BS_AUTORADIOBUTTON,9,54,144,10 + CONTROL "Only if last session present",IDC_CHECKLAST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,31,126,10 + EDITTEXT IDC_STARTDELAY,105,70,26,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "Startup delay",IDC_STATICOP,51,72,54,8 + LTEXT "ms",IDC_STATICMS,136,72,16,8 + GROUPBOX "User Sessions Management",IDC_STATIC,6,96,157,129 + PUSHBUTTON "Edit",IDC_EDIT,119,132,42,13,WS_DISABLED + COMBOBOX IDC_LIST,9,107,107,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + LISTBOX IDC_OPCLIST,9,122,107,100,LBS_NOINTEGRALHEIGHT | LBS_NOSEL | WS_VSCROLL + PUSHBUTTON "Delete",IDC_DEL,119,107,42,13 + PUSHBUTTON "Save",IDC_SAVE,119,145,42,13,WS_DISABLED + GROUPBOX "Action on Exit",IDC_STATIC,170,11,128,75 + CONTROL "Ask",IDC_REXASK,"Button",BS_AUTORADIOBUTTON | WS_GROUP,173,23,122,10 + CONTROL "Save Current Session",IDC_REXSAVE,"Button",BS_AUTORADIOBUTTON,173,37,122,10 + CONTROL "Do nothing",IDC_REXDSAVE,"Button",BS_AUTORADIOBUTTON,173,50,122,10 + EDITTEXT IDC_TRACK,224,70,27,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER + CONTROL "",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_TABSTOP,241,62,10,14 + LTEXT "Save only last",IDC_EXSTATIC1,173,72,48,8 + LTEXT "Sessions",IDC_EXSTATIC2,253,72,28,8 + GROUPBOX "Misc",IDC_STATIC,170,96,128,95 + CONTROL "Exclude hidden contacts from session on exit",IDC_EXCLHIDDEN, + "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,173,104,122,16 + CONTROL "Warn, when some of LastSession contacts are hidden",IDC_LASTHIDDENWARN, + "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,173,121,122,20 + CONTROL "Show other warnings (""session already opened"" etc...)",IDC_WARNINGS, + "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,173,143,122,17 + CONTROL "Crash Recovery mode",IDC_CRASHRECOVERY,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,173,162,122,17 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPTIONS, DIALOG + BEGIN + LEFTMARGIN, 3 + RIGHTMARGIN, 298 + VERTGUIDE, 9 + VERTGUIDE, 116 + VERTGUIDE, 119 + VERTGUIDE, 161 + VERTGUIDE, 170 + VERTGUIDE, 173 + VERTGUIDE, 285 + TOPMARGIN, 6 + BOTTOMMARGIN, 243 + HORZGUIDE, 96 + HORZGUIDE, 225 + END +END +#endif // APSTUDIO_INVOKED + +#endif // Neutral resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// Russian resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +#ifdef _WIN32 +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_WLCMDIALOG DIALOGEX 0, 0, 169, 80 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Restore Session" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "&Restore Session",IDOK,46,58,61,14 + PUSHBUTTON "&Cancel",IDCANCEL,110,58,52,14 + LTEXT "Choose session to restore from the list:",IDC_STATIC,10,16,149,11 + COMBOBOX IDC_LIST,12,30,126,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Del",IDC_SESSDEL,140,31,22,11 +END + +IDD_SAVEDIALOG DIALOGEX 0, 0, 169, 80 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Save Session" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "&Save Session",IDOK,44,58,61,14 + PUSHBUTTON "&Cancel",IDCANCEL,107,58,52,14 + LTEXT "Enter session name:",IDC_STATIC,13,16,123,11 + COMBOBOX IDC_LIST,12,30,148,65,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + CONTROL "Save and Close",IDC_SANDCCHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,46,137,10 + CONTROL "adv.",IDC_SELCONTACTS,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_FLAT | WS_TABSTOP,136,4,24,10 +END + +IDD_EXDIALOG DIALOGEX 0, 0, 170, 70 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Sessions Manager" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,61,49,50,14 + PUSHBUTTON "Cancel",IDCANCEL,113,49,50,14 + LTEXT "Save your current session?",IDC_STATIC,15,22,135,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_WLCMDIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 162 + VERTGUIDE, 12 + TOPMARGIN, 7 + BOTTOMMARGIN, 73 + END + + IDD_SAVEDIALOG, DIALOG + BEGIN + RIGHTMARGIN, 168 + END + + IDD_EXDIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 163 + TOPMARGIN, 7 + BOTTOMMARGIN, 63 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_SESSIONS ICON "icons\\sessions.ico" +IDI_SESSIONS_LOAD ICON "icons\\load.ico" +IDD_SESSIONS_SAVE ICON "icons\\save.ico" +IDD_SESSIONS_LOADLAST ICON "icons\\loadlast.ico" +IDD_SESSION_CHECKED ICON "icons\\checked.ico" +IDD_SESSION_UNCHECKED ICON "icons\\unchecked.ico" + + +#endif // Russian resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/Sessions/Sessions_10.sln b/plugins/Sessions/Sessions_10.sln new file mode 100644 index 0000000000..67cc2b053f --- /dev/null +++ b/plugins/Sessions/Sessions_10.sln @@ -0,0 +1,25 @@ +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sessions", "Sessions_10.vcxproj", "{DD76B998-ED0D-4BFD-9660-3ADC3A334872}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug Unicode|Win32 = Debug Unicode|Win32 + Debug Unicode|x64 = Debug Unicode|x64 + Release Unicode|Win32 = Release Unicode|Win32 + Release Unicode|x64 = Release Unicode|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DD76B998-ED0D-4BFD-9660-3ADC3A334872}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32 + {DD76B998-ED0D-4BFD-9660-3ADC3A334872}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32 + {DD76B998-ED0D-4BFD-9660-3ADC3A334872}.Debug Unicode|x64.ActiveCfg = Debug Unicode|x64 + {DD76B998-ED0D-4BFD-9660-3ADC3A334872}.Debug Unicode|x64.Build.0 = Debug Unicode|x64 + {DD76B998-ED0D-4BFD-9660-3ADC3A334872}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32 + {DD76B998-ED0D-4BFD-9660-3ADC3A334872}.Release Unicode|Win32.Build.0 = Release Unicode|Win32 + {DD76B998-ED0D-4BFD-9660-3ADC3A334872}.Release Unicode|x64.ActiveCfg = Release Unicode|x64 + {DD76B998-ED0D-4BFD-9660-3ADC3A334872}.Release Unicode|x64.Build.0 = Release Unicode|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/plugins/Sessions/Sessions_10.vcxproj b/plugins/Sessions/Sessions_10.vcxproj new file mode 100644 index 0000000000..2b90390c59 --- /dev/null +++ b/plugins/Sessions/Sessions_10.vcxproj @@ -0,0 +1,259 @@ + + + + + Debug Unicode + Win32 + + + Debug Unicode + x64 + + + Release Unicode + Win32 + + + Release Unicode + x64 + + + + {DD76B998-ED0D-4BFD-9660-3ADC3A334872} + Sessions + Sessions + + + + DynamicLibrary + false + Unicode + + + DynamicLibrary + false + Unicode + + + DynamicLibrary + false + Unicode + true + + + DynamicLibrary + false + Unicode + true + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)/Plugins\ + $(SolutionDir)$(Configuration)64/Plugins\ + $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ + $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ + true + true + $(SolutionDir)$(Configuration)/Plugins\ + $(SolutionDir)$(Configuration)64/Plugins\ + $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ + $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Release/sessions.tlb + + + + + Full + AnySuitable + true + MultiThreadedDLL + true + Use + Level3 + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + Size + sessions.h + + + NDEBUG;%(PreprocessorDefinitions) + + + /filealign:0x200 %(AdditionalOptions) + msimg32.lib;%(AdditionalDependencies) + 0x67100000 + $(IntDir)$(TargetName).lib + MachineX86 + true + true + false + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/sessions.tlb + + + + + Full + AnySuitable + true + MultiThreadedDLL + true + Use + Level3 + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + Size + sessions.h + + + NDEBUG;%(PreprocessorDefinitions) + + + /filealign:0x200 %(AdditionalOptions) + msimg32.lib;%(AdditionalDependencies) + 0x67100000 + $(IntDir)$(TargetName).lib + true + true + false + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\release/sessions.tlb + + + + + /D "DEBUG" %(AdditionalOptions) + MultiThreadedDebug + Use + Level3 + EditAndContinue + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + Disabled + sessions.h + + + NDEBUG;%(PreprocessorDefinitions) + + + /filealign:0x200 %(AdditionalOptions) + true + 0x67100000 + $(IntDir)$(TargetName).lib + MachineX86 + msimg32.lib;%(AdditionalDependencies) + false + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\release/sessions.tlb + + + + + /D "DEBUG" %(AdditionalOptions) + Disabled + MultiThreadedDebug + Use + Level3 + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + sessions.h + + + NDEBUG;%(PreprocessorDefinitions) + + + /filealign:0x200 %(AdditionalOptions) + true + 0x67100000 + $(IntDir)$(TargetName).lib + msimg32.lib;%(AdditionalDependencies) + false + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/Sessions/Sessions_10.vcxproj.filters b/plugins/Sessions/Sessions_10.vcxproj.filters new file mode 100644 index 0000000000..0926730b25 --- /dev/null +++ b/plugins/Sessions/Sessions_10.vcxproj.filters @@ -0,0 +1,73 @@ + + + + + {7924bb78-e0e0-41a9-bef3-21ee81d65e4e} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {69bb5ab9-e440-4eb0-87c5-ab15198f3f7d} + h;hpp;hxx;hm;inl + + + {b6a581e7-b460-4f40-b782-acff3afc0a00} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/plugins/Sessions/Sessions_8.vcproj b/plugins/Sessions/Sessions_8.vcproj new file mode 100644 index 0000000000..55ef4ef6da --- /dev/null +++ b/plugins/Sessions/Sessions_8.vcproj @@ -0,0 +1,547 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/Sessions/Src/Main.cpp b/plugins/Sessions/Src/Main.cpp new file mode 100644 index 0000000000..47ec1b98bb --- /dev/null +++ b/plugins/Sessions/Src/Main.cpp @@ -0,0 +1,1089 @@ +/* +Sessions Management plugin for Miranda IM + +Copyright (C) 2007-2008 Danil Mozhar + +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 3 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, see . +*/ + +#include "sessions.h" + +HINSTANCE hinstance = NULL; + +WNDPROC mainProc; + +HANDLE hEventDbWindowEvent,hEventDbOkToExit, hEventDbOptionsInit, hEventDbPluginsLoaded, +hEventDbPreShutdown,hServiceOpenManager,hServiceShowFavMenu,hServiceCloseCurrentSession,hServiceSaveUserSession, +hServiceLoadLastSession,hmSaveCurrentSession, +hmLoadLastSession,hmLoadSession,hmSessionsManager,hibSessionsLoad,hibSessionsSave,hibSessionsLoadLast,hibChecked,hibNotChecked ; + +HICON hiChecked,hiNotChecked,hiSessions,hiSessionsLoad ,hiSessionsSave,hiSessionsLoadLast; + + +HANDLE hmTBButton[2],hiTBbutton[2],iTBbutton[2]; + +BOOL g_hghostw; + +HWND hClistControl; + +unsigned int ses_limit; +unsigned int g_ses_count; +BOOL g_bExclHidden; +BOOL g_bWarnOnHidden; +BOOL g_bOtherWarnings; +BOOL g_bCrashRecovery; +BOOL g_bIncompletedSave; + +struct MM_INTERFACE mmi; +HWND g_hDlg; +HWND g_hSDlg; +BOOL DONT = FALSE; +BOOL StartUp,isLastTRUE = FALSE,g_mode,bSC = FALSE; + +DWORD session_list[255] = {0}; +DWORD user_session_list[255] = {0}; +DWORD session_list_recovered[255]; + +int count = 0; +unsigned int ses_count = 0; + +PLUGINLINK *pluginLink; +int hLangpack; + +int OptionsInit(WPARAM,LPARAM); + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + 0, +#ifdef _UNICODE + // {60558872-2AAB-45aa-888D-097691C9B683} + { 0x60558872, 0x2aab, 0x45aa, { 0x88, 0x8d, 0x9, 0x76, 0x91, 0xc9, 0xb6, 0x83 } } +#else + // {F929B07B-DC4D-43d6-A6F3-3AA51F9FF81A} + { 0xf929b07b, 0xdc4d, 0x43d6, { 0xa6, 0xf3, 0x3a, 0xa5, 0x1f, 0x9f, 0xf8, 0x1a } } +#endif +}; + + +INT_PTR CALLBACK ExitDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hdlg); + LoadPosition(hdlg, "ExitDlg"); + ShowWindow(hdlg,SW_SHOW); + }break; + + case WM_COMMAND: + switch(LOWORD(wparam)) + { + case IDOK: + { + SavePosition(hdlg, "ExitDlg"); + SaveSessionDate(); + SaveSessionHandles(0,0); + DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "lastempty", 0); + DestroyWindow(hdlg); + }break; + + case IDCANCEL: + { + SavePosition(hdlg, "ExitDlg"); + DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "lastempty", 1); + DestroyWindow(hdlg); + }break; + } + + case WM_CLOSE: + DestroyWindow(hdlg); + break; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + default: + return FALSE; + } + return TRUE; +} + +INT_PTR CALLBACK SaveSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) +{ + g_hSDlg = hdlg; + switch(msg) + { + case WM_INITDIALOG: + { + HWND hList; + hList = GetDlgItem(hdlg, IDC_LIST); + TranslateDialogDefault(hdlg); + LoadSessionToCombobox(hdlg, 1, 5, "UserSessionDsc", 0); + + LoadPosition(hdlg, "SaveDlg"); + ShowWindow(hdlg, SW_SHOW); + }break; + + case WM_CLOSE: + DestroyWindow(hdlg); + g_hSDlg = 0; + break; + + case WM_NOTIFY: + { + switch (((LPNMHDR) lparam)->idFrom) + { + case IDC_CLIST: + switch (((LPNMHDR)lparam)->code) + { + case CLN_CHECKCHANGED: + { + bSC = TRUE; + memcpy(user_session_list, session_list, SIZEOF(user_session_list)); + }break; + + } + }break; + }break; + + case WM_COMMAND: + switch(LOWORD(wparam)) + { + case IDC_SELCONTACTS: + { + HANDLE hItem; + RECT rWnd; + int i=0, x=0,y=0,dy=0,dx=0,dd=0; + + GetWindowRect(hdlg, &rWnd); + x=rWnd.right-rWnd.left; + y=rWnd.bottom-rWnd.top; + if(IsDlgButtonChecked(hdlg,IDC_SELCONTACTS)) + { + EnableWindow(GetDlgItem(hdlg,IDC_SANDCCHECK),FALSE); + dy=20; + dx=150; + dd=5; + hClistControl = CreateWindowEx(WS_EX_CLIENTEDGE,CLISTCONTROL_CLASS, _T(""), + WS_TABSTOP |WS_VISIBLE | WS_CHILD , + x, y, dx, dy, hdlg, (HMENU)IDC_CLIST, hinstance, 0); + + SetWindowLongPtr(hClistControl, GWL_STYLE, + GetWindowLongPtr(hClistControl, GWL_STYLE)|CLS_CHECKBOXES|CLS_HIDEEMPTYGROUPS|CLS_USEGROUPS|CLS_GREYALTERNATE|CLS_GROUPCHECKBOXES); + SendMessage(hClistControl, CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP|CLS_EX_TRACKSELECT, 0); + } + else + { + EnableWindow(GetDlgItem(hdlg,IDC_SANDCCHECK),TRUE); + dy=-20; + dx=-150; + dd=5; + DestroyWindow(hClistControl); + } + + SetWindowPos(hdlg, NULL, rWnd.left,rWnd.top, x+dx, y+(dx/3), SWP_NOZORDER | SWP_NOOWNERZORDER|SWP_NOMOVE); + + SetWindowPos(hClistControl,0,x-dd,dd,dx-dd,y+(dx/12),SWP_NOZORDER/*|SWP_NOSIZE|SWP_SHOWWINDOW*/); + SendMessage(hClistControl,WM_TIMER,TIMERID_REBUILDAFTER,0); + + for ( i = 0; session_list[i] > 0; i++) + { + hItem=(HANDLE)SendMessage(hClistControl,CLM_FINDCONTACT, (WPARAM)session_list[i], 0); + SendMessage(hClistControl, CLM_SETCHECKMARK, (WPARAM)hItem,1); + } + + OffsetWindow(hdlg, GetDlgItem(hdlg,IDC_LIST), 0, dy); + OffsetWindow(hdlg, GetDlgItem(hdlg,IDC_STATIC), 0, dy); + OffsetWindow(hdlg, GetDlgItem(hdlg,IDC_SANDCCHECK), 0, dy); + OffsetWindow(hdlg, GetDlgItem(hdlg,IDOK), 0, dy); + OffsetWindow(hdlg, GetDlgItem(hdlg,IDCANCEL), 0, dy); + + }break; + + case IDOK: + { + DWORD session_list_temp[255]={0}; + int lenght,i; + TCHAR szUserSessionName[MAX_PATH]; + lenght = GetWindowTextLength(GetDlgItem(hdlg, IDC_LIST)); + SavePosition(hdlg, "SaveDlg"); + if (lenght>0) + { + GetWindowText(GetDlgItem(hdlg, IDC_LIST), szUserSessionName, SIZEOF(szUserSessionName)); + szUserSessionName[lenght+1]='\0'; + if(IsDlgButtonChecked(hdlg,IDC_SELCONTACTS)&&bSC) + { + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + for (i=0; hContact; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) + { + BYTE res =(BYTE)SendMessage(hClistControl, CLM_GETCHECKMARK, SendMessage(hClistControl, CLM_FINDCONTACT, (WPARAM)hContact, 0), 0); + if (res) + { + user_session_list[i]=(DWORD)hContact; + i++; + } + } + memcpy(session_list_temp,session_list,SIZEOF(session_list_temp)); + memcpy(session_list,user_session_list,SIZEOF(session_list)); + SaveSessionHandles(0,1); + SaveUserSessionName(szUserSessionName); + memcpy(session_list,session_list_temp,SIZEOF(session_list)); + DestroyWindow(hdlg); + g_hSDlg=0; + } + else if(!SaveUserSessionName(szUserSessionName)) + { + SaveSessionHandles(0,1); + + if(IsDlgButtonChecked(hdlg,IDC_SANDCCHECK)) + CloseCurrentSession(0,0); + DestroyWindow(hdlg); + g_hSDlg=0; + } + else + MessageBox(NULL,TranslateT("Current session is empty!"),TranslateT("Sessions Manager"),MB_OK|MB_ICONWARNING); + } + else + MessageBox(NULL,TranslateT("Session name is empty, enter the name and try again"),TranslateT("Sessions Manager"),MB_OK|MB_ICONWARNING); + }break; + + case IDCANCEL: + { + SavePosition(hdlg, "SaveDlg"); + DestroyWindow(hdlg); + g_hSDlg=0; + }break; + } + break; + + default: + return FALSE; + } + return TRUE; +} + +INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) +{ + g_hDlg=hdlg; + switch(msg) + { + case WM_INITDIALOG: + { + int iDelay=DBGetContactSettingWord(NULL, __INTERNAL_NAME, "StartupModeDelay", 1500); + if(g_hghostw==TRUE) + SetTimer(hdlg, TIMERID_LOAD, iDelay, NULL); + else + { + ses_count=0; + TranslateDialogDefault(hdlg); + if((ses_count=LoadSessionToCombobox(hdlg,0,ses_limit,"SessionDate",0))==ses_limit) + EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),TRUE); + + if(LoadSessionToCombobox(hdlg,0,255,"UserSessionDsc",ses_limit)==0 && ses_count!=0) + ses_count=0; + + if(session_list_recovered[0]) + ses_count=256; + + SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, (WPARAM)0, 0); + LoadPosition(hdlg, "LoadDlg"); + if(StartUp) + SetTimer(hdlg, TIMERID_SHOW, iDelay, NULL); + else + ShowWindow(g_hDlg,SW_SHOW); + } + }break; + + case WM_TIMER: + if(wparam == TIMERID_SHOW) + { + KillTimer(hdlg, TIMERID_SHOW); + ShowWindow(hdlg,SW_SHOW); + StartUp=FALSE; + } + else + { + KillTimer(hdlg, TIMERID_LOAD); + LoadSession(0,0); + g_hghostw=StartUp=FALSE; + DestroyWindow(hdlg); + g_hDlg=0; + } + break; + + case WM_CLOSE: + SavePosition(hdlg, "LoadDlg"); + DestroyWindow(hdlg); + g_hDlg=0; + break; + + case WM_COMMAND: + switch(LOWORD(wparam)) + { + case IDC_LIST: + { + switch(HIWORD(wparam)) + { + case CBN_SELCHANGE: + { + HWND hCombo = GetDlgItem(hdlg, IDC_LIST); + int index = SendMessage(hCombo, CB_GETCURSEL, 0, 0); + if(index != CB_ERR) + ses_count = SendMessage(hCombo, CB_GETITEMDATA, (WPARAM)index, 0); + }break; + }break; + }break; + + case IDC_SESSDEL: + { + if(session_list_recovered[0]&&ses_count==256) + { + int i=0; + while(session_list_recovered[i]) + { + DBWriteContactSettingByte((HANDLE)session_list_recovered[i], __INTERNAL_NAME, "wasInLastSession", 0); + i++; + } + ZeroMemory(session_list_recovered,SIZEOF(session_list_recovered)); + g_bIncompletedSave=0; + + EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),FALSE); + SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0); + + if((ses_count=LoadSessionToCombobox(hdlg,1,ses_limit,"SessionDate",0))==ses_limit) + EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),TRUE); + + if(LoadSessionToCombobox(hdlg,1,255,"UserSessionDsc",ses_limit)==0 && ses_count!=0) + ses_count=0; + + SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, (WPARAM)0, 0); + + } + else if (ses_count>=ses_limit) + { + ses_count-=ses_limit; + DelUserDefSession(ses_count); + EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),FALSE); + SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0); + + if((ses_count=LoadSessionToCombobox(hdlg,0,ses_limit,"SessionDate",0))==ses_limit) + EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),TRUE); + + if(LoadSessionToCombobox(hdlg,0,255,"UserSessionDsc",ses_limit)==0 && ses_count!=0) + ses_count=0; + + if(session_list_recovered[0]) ses_count=256; + + SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, (WPARAM)0, 0); + } + else + { + DeleteAutoSession(ses_count); + EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),FALSE); + SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0); + if((ses_count=LoadSessionToCombobox(hdlg,0,ses_limit,"SessionDate",0))==ses_limit) + EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),TRUE); + + if(LoadSessionToCombobox(hdlg,0,255,"UserSessionDsc",ses_limit)==0 && ses_count!=0) + ses_count=0; + + if(session_list_recovered[0]) ses_count=256; + + SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, (WPARAM)0, 0); + } + if (SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, 0, 0)) + EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),TRUE); + else + EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),FALSE); + }break; + + case IDOK: + { + if(!LoadSession(0,ses_count)) + { + SavePosition(hdlg, "LoadDlg"); + DestroyWindow(hdlg); + g_hDlg=0; + } + }break; + + case IDCANCEL: + { + SavePosition(hdlg, "LoadDlg"); + DestroyWindow(hdlg); + g_hDlg=0; + }break; + } + break; + + default: + return FALSE; + } + return TRUE; +} + +INT_PTR CloseCurrentSession(WPARAM wparam,LPARAM lparam) +{ + HWND hWnd; + int i=0; + MessageWindowInputData mwid; + MessageWindowData mwd; + + while(session_list[0]!=0) + { + mwid.cbSize = sizeof(MessageWindowInputData); + mwid.hContact=(HANDLE)session_list[i]; + mwid.uFlags=MSG_WINDOW_UFLAG_MSG_BOTH; + + mwd.cbSize = sizeof(MessageWindowData); + mwd.hContact = mwid.hContact; + mwd.uFlags=MSG_WINDOW_UFLAG_MSG_BOTH; + CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&mwid,(LPARAM)&mwd); + + if (g_mode) + { + hWnd=GetAncestor(mwd.hwndWindow,GA_ROOT); + SendMessage(hWnd,WM_CLOSE,0,1); + } + else + SendMessage(mwd.hwndWindow, WM_CLOSE, 0, 0); + } + ZeroMemory(session_list,SIZEOF(session_list)); + return 0; +} + +int SaveSessionHandles(WPARAM wparam,LPARAM lparam) +{ + int k=0; + + if(session_list[0]!=0) + { + for (HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact; + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) + { + if ((k=CheckForDuplicate(session_list,(DWORD)hContact))!=-1 + &&!(g_bExclHidden&&!CheckContactVisibility(hContact))) + { + AddSessionMark((HANDLE)hContact,lparam,'1'); + AddInSessionOrder((HANDLE)hContact,lparam,k,1); + } + else + { + AddSessionMark((HANDLE)hContact,lparam,'0'); + AddInSessionOrder((HANDLE)hContact,lparam,0,0); + } + } + if(lparam==1) + { + g_ses_count++; + DBWriteContactSettingByte(0, __INTERNAL_NAME, "UserSessionsCount", (BYTE)g_ses_count); + } + return 0; + } + else + return 1; +} + +INT_PTR SaveUserSessionHandles(WPARAM wparam,LPARAM lparam) +{ + if (g_hSDlg) + { + ShowWindow(g_hSDlg,SW_SHOW); + return 1; + } + else + g_hSDlg=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_SAVEDIALOG), 0, SaveSessionDlgProc); + + return 0; +} + +INT_PTR OpenSessionsManagerWindow(WPARAM wparam,LPARAM lparam) +{ + if (g_hDlg) + { + ShowWindow(g_hDlg,SW_SHOW); + return 0; + } + if(g_bIncompletedSave||DBGetStringT(NULL, __INTERNAL_NAME, "SessionDate_0")||DBGetStringT(NULL, __INTERNAL_NAME, "UserSessionDsc_0")) + { + g_hDlg=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_WLCMDIALOG), 0, LoadSessionDlgProc); + return 0; + } + if (g_bOtherWarnings) + MessageBox(NULL, TranslateT("No sessions to open"), TranslateT("Sessions Manager"), MB_OK|MB_ICONWARNING); + return 1; +} + +int SaveSessionDate() +{ + if(session_list[0]!=0) + { + int TimeSize = GetTimeFormat(LOCALE_USER_DEFAULT, 0/*TIME_NOSECONDS*/, NULL, NULL, NULL, 0); + TCHAR *szTimeBuf = (TCHAR*)mir_alloc((TimeSize+1)*sizeof(TCHAR)); + + GetTimeFormat(LOCALE_USER_DEFAULT, 0/*TIME_NOSECONDS*/, NULL, NULL, szTimeBuf, TimeSize); + + int DateSize = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, NULL, 0); + TCHAR *szDateBuf = (TCHAR*)mir_alloc((DateSize+1)*sizeof(TCHAR)); + + GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, szDateBuf, DateSize ); + TCHAR *szSessionTime = (TCHAR*)mir_alloc((DateSize+TimeSize+5)*sizeof(TCHAR)); + int lenn = (int)_tcslen(szSessionTime); + mir_sntprintf(szSessionTime, lenn, _T("%s - %s"), szTimeBuf, szDateBuf); + + char szSessionDate[256]; + DBVARIANT dbv = {0}; + mir_snprintf(szSessionDate, SIZEOF(szSessionDate), "%s_%d", "SessionDate", 0); + DBGetContactSettingTString(NULL, __INTERNAL_NAME, szSessionDate, &dbv); + TCHAR *szSessionDateBuf_1 = mir_tstrdup(dbv.ptszVal); + DBFreeVariant(&dbv); + + DBWriteContactSettingTString(NULL, __INTERNAL_NAME, szSessionDate, szSessionTime); + mir_free(szSessionTime); + ResaveSettings("SessionDate", 1, ses_limit, szSessionDateBuf_1); + + if(szTimeBuf) + mir_free(szTimeBuf); + if(szDateBuf) + mir_free(szDateBuf); + } + if(g_bCrashRecovery) + DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "lastSaveCompleted", 1); + return 0; +} + +int SaveUserSessionName(TCHAR *szUSessionName) +{ + int i=0; + DBVARIANT dbv={0}; + char szUserSessionNameBuf[256]={0}; + TCHAR *szUserSessionNameBuf_1=NULL; + TCHAR *szUserSessionName=NULL; + TCHAR *ptr=NULL; + + if(session_list[0]!=0) + { + szUserSessionName = mir_tstrdup(szUSessionName); + mir_snprintf(szUserSessionNameBuf, SIZEOF(szUserSessionNameBuf), "%s_%u", "UserSessionDsc", 0); + if(!DBGetContactSettingTString(NULL, __INTERNAL_NAME, szUserSessionNameBuf, &dbv)) + { + szUserSessionNameBuf_1 = mir_tstrdup(dbv.ptszVal); + DBFreeVariant(&dbv); + ResaveSettings("UserSessionDsc",1,255,szUserSessionNameBuf_1); + } + + DBWriteContactSettingTString(NULL, __INTERNAL_NAME, szUserSessionNameBuf, szUserSessionName); + + //free(szUserSessionNameBuf_1); + mir_free(szUserSessionName); + return 0; + } + + return 1; +} + +INT_PTR LoadLastSession(WPARAM wparam,LPARAM lparam) +{ + int ret=0; + if(isLastTRUE) + ret=LoadSession(wparam,lparam); + else if (g_bOtherWarnings) + MessageBox(NULL, TranslateT("Last Sessions is empty"), TranslateT("Sessions Manager"), MB_OK); + return ret; +} + +int LoadSession(WPARAM wparam,LPARAM lparam) +{ + int dup=0; + int hidden[255]={'0'}; + HANDLE hContact; + DWORD session_list_t[255]={0}; + int mode=0; + int i=0,j=0; + if ((UINT)lparam>=ses_limit&&lparam!=256) + { + mode=1; + lparam-=ses_limit; + } + if(session_list_recovered[0]&&lparam==256&&mode==0) + memcpy(session_list_t,session_list_recovered,SIZEOF(session_list_t)); + else + for (hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact; + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) + { + if(LoadContactsFromMask(hContact,mode,lparam)) + { + i=GetInSessionOrder(hContact,mode, lparam); + session_list_t[i]=(DWORD)hContact; + } + } + i=0; + //TODO: change to "switch" + while(session_list_t[i]!=0) + { + if (CheckForDuplicate(session_list,session_list_t[i])==-1) + CallService(MS_CLIST_CONTACTDOUBLECLICKED, (WPARAM)session_list_t[i], 0); + else if(g_bWarnOnHidden) + { + if(!CheckContactVisibility((HANDLE)session_list_t[i])) + { + hidden[j]=i+1; + j++; + } + dup++; + } + i++; + } + + if(i==0) + { + if(g_bOtherWarnings) + MessageBox(NULL, TranslateT("No contacts to open"), TranslateT("Sessions Manager"), MB_OK|MB_ICONWARNING); + return 1; + } + else if(dup==i) + { + if(!hidden) + { + if(g_bOtherWarnings) + MessageBox(NULL, TranslateT("This Session already opened"), TranslateT("Sessions Manager"), MB_OK|MB_ICONWARNING); + return 1; + } + else if(!g_bWarnOnHidden&&g_bOtherWarnings) + { + MessageBox(NULL, TranslateT("This Session already opened"), TranslateT("Sessions Manager"), MB_OK|MB_ICONWARNING); + return 1; + } + else if(g_bWarnOnHidden) + { + if(MessageBox(NULL, TranslateT("This Session already opened(but probably hidden)\nDo you want to show hidden contacts?"), TranslateT("Sessions Manager"), MB_YESNO|MB_ICONQUESTION)==IDYES) + { + j=0; + while(hidden[j]!=0) + { + CallService(MS_CLIST_CONTACTDOUBLECLICKED, (WPARAM)session_list_t[hidden[j]-1], 0); + j++; + } + } + } + } + + return 0; +} + +int DelUserDefSession(int ses_count) +{ + int i=0; + HANDLE hContact; + char szSessionName[256]={0}; + TCHAR *szSessionNameBuf=NULL; + + for (hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact; + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) + { + RemoveSessionMark(hContact,1,ses_count); + SetInSessionOrder(hContact,1,ses_count,0); + } + + mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "UserSessionDsc", ses_count); + DBDeleteContactSetting(NULL, __INTERNAL_NAME, szSessionName); + + mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "FavUserSession", ses_count); + DBDeleteContactSetting(NULL, __INTERNAL_NAME, szSessionName); + + for (i=(ses_count+1);;i++) + { + mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "UserSessionDsc", i); + + if ((szSessionNameBuf=DBGetStringT(NULL, __INTERNAL_NAME, szSessionName))/*&&(szSessionHandlesBuf=DBGetStringT(NULL,PLGNAME,szSessionHandles))*/) + { + MarkUserDefSession(i-1,IsMarkedUserDefSession(i)); + mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "UserSessionDsc", i-1); + DBWriteContactSettingTString(NULL, __INTERNAL_NAME, szSessionName, szSessionNameBuf); + } + else + { + mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "UserSessionDsc", i-1); + DBDeleteContactSetting(NULL, __INTERNAL_NAME, szSessionName); + + mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "FavUserSession", i-1); + DBDeleteContactSetting(NULL, __INTERNAL_NAME, szSessionName); + break; + } + } + g_ses_count--; + DBWriteContactSettingByte(0, __INTERNAL_NAME, "UserSessionsCount", (BYTE)g_ses_count); + mir_free(szSessionNameBuf); + return 0; +} + +int DeleteAutoSession(int ses_count) +{ + int i=0; + HANDLE hContact; + char szSessionName[256]={0}; + + TCHAR *szSessionNameBuf=NULL; + + for (hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact; + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) + { + RemoveSessionMark(hContact,0,ses_count); + SetInSessionOrder(hContact,0,ses_count,0); + } + + mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "SessionDate", ses_count); + DBDeleteContactSetting(NULL, __INTERNAL_NAME, szSessionName); + + for (i=(ses_count+1);;i++) + { + mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "SessionDate", i); + + if ((szSessionNameBuf=DBGetStringT(NULL, __INTERNAL_NAME, szSessionName))/*&&(szSessionHandlesBuf=DBGetStringT(NULL,PLGNAME,szSessionHandles))*/) + { + mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "SessionDate", i-1); + DBWriteContactSettingTString(NULL, __INTERNAL_NAME, szSessionName, szSessionNameBuf); + + } + else + { + mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "SessionDate", i-1); + DBDeleteContactSetting(NULL, __INTERNAL_NAME, szSessionName); + break; + } + } + mir_free(szSessionNameBuf); + return 0; +} + +int SessionPreShutdown(WPARAM wparam,LPARAM lparam) +{ + DONT=1; + if (hEventDbWindowEvent) UnhookEvent(hEventDbWindowEvent); + DestroyServiceFunction(hServiceOpenManager); + DestroyServiceFunction(hServiceCloseCurrentSession); + DestroyServiceFunction(hServiceShowFavMenu); + DestroyServiceFunction(hServiceLoadLastSession); + DestroyServiceFunction(hServiceSaveUserSession); + + if (hEventDbPluginsLoaded) UnhookEvent(hEventDbPluginsLoaded); + + if (hEventDbOptionsInit) UnhookEvent(hEventDbOptionsInit); + if (hEventDbOkToExit) UnhookEvent(hEventDbOkToExit); + if (hEventDbPreShutdown) UnhookEvent(hEventDbPreShutdown); + + if (g_hDlg) DestroyWindow(g_hDlg); + if (g_hSDlg) DestroyWindow(g_hSDlg); + + DestroyIcon(hiSessions); + DestroyIcon(hiSessionsLoad); + DestroyIcon(hiSessionsSave); + DestroyIcon(hiSessionsLoadLast); + DestroyIcon(hiChecked); + DestroyIcon(hiNotChecked); + + if(g_bIncompletedSave) + { + int i=0; + while(session_list_recovered[i]) + { + DBWriteContactSettingByte((HANDLE)session_list_recovered[i], __INTERNAL_NAME, "wasInLastSession", 0); + i++; + } + } + + DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "lastSaveCompleted", 1); + return 0; +} + +int OkToExit(WPARAM wparam,LPARAM lparam) +{ + int exitmode=DBGetContactSettingByte(NULL, __INTERNAL_NAME, "ShutdownMode", 2); + DONT=1; + if(exitmode==2&&session_list[0]!=0) + { + SaveSessionDate(); + SaveSessionHandles(0,0); + DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "lastempty", 0); + } + else if(exitmode==1&&session_list[0]!=0) + { + DialogBox(hinstance,MAKEINTRESOURCE(IDD_EXDIALOG), 0, ExitDlgProc); + } + else DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "lastempty", 1); + return 0; +} + +static int GetContactHandle(WPARAM wparam,LPARAM lParam) +{ + MessageWindowEventData *MWeventdata = (MessageWindowEventData*)lParam; + + if(MWeventdata->uType == MSG_WINDOW_EVT_OPEN) + { + if (strstr(MWeventdata->szModule,"tabSRMsg")) g_mode=1; + AddToCurSession((DWORD)MWeventdata->hContact,0); + if(g_bCrashRecovery) DBWriteContactSettingByte(MWeventdata->hContact, __INTERNAL_NAME, "wasInLastSession", 1); + } + else if(MWeventdata->uType == MSG_WINDOW_EVT_CLOSE) + { + if(!DONT) DelFromCurSession((DWORD)MWeventdata->hContact,0); + if(g_bCrashRecovery) DBWriteContactSettingByte(MWeventdata->hContact, __INTERNAL_NAME, "wasInLastSession", 0); + } + + return 0; +} + +INT_PTR BuildFavMenu(WPARAM wparam,LPARAM lparam) +{ + HMENU hMenu=NULL; + POINT pt; + int res=0; + hMenu = CreatePopupMenu(); + GetCursorPos(&pt); + FillFavoritesMenu(hMenu,g_ses_count); + res = TrackPopupMenu(hMenu, TPM_RETURNCMD|TPM_NONOTIFY, pt.x, pt.y, 0, GetActiveWindow(), NULL); + if(res==0) return 1; + LoadSession(0,(res-1)+ses_limit); + return 0; +} + +static int PluginInit(WPARAM wparam,LPARAM lparam) +{ + int startup=0; + + hEventDbWindowEvent=HookEvent(ME_MSG_WINDOWEVENT, GetContactHandle); + hEventDbOptionsInit=HookEvent(ME_OPT_INITIALISE, OptionsInit); + + hServiceShowFavMenu=CreateServiceFunction(MS_SESSIONS_SHOWFAVORITESMENU, BuildFavMenu); + hServiceOpenManager=CreateServiceFunction(MS_SESSIONS_OPENMANAGER, OpenSessionsManagerWindow); + hServiceLoadLastSession=CreateServiceFunction(MS_SESSIONS_RESTORELASTSESSION, LoadLastSession/*LoadSession*/); + hServiceSaveUserSession=CreateServiceFunction(MS_SESSIONS_SAVEUSERSESSION, SaveUserSessionHandles); + hServiceCloseCurrentSession=CreateServiceFunction(MS_SESSIONS_CLOSESESSION, CloseCurrentSession); + + g_ses_count=DBGetContactSettingByte(0, __INTERNAL_NAME, "UserSessionsCount", 0); + if (!g_ses_count) g_ses_count=DBGetContactSettingByte(0, "Sessions (Unicode)", "UserSessionsCount", 0); + ses_limit=DBGetContactSettingByte(0, __INTERNAL_NAME, "TrackCount", 10); + g_bExclHidden=DBGetContactSettingByte(NULL, __INTERNAL_NAME, "ExclHidden", 0); + g_bWarnOnHidden=DBGetContactSettingByte(NULL, __INTERNAL_NAME, "WarnOnHidden", 0); + g_bOtherWarnings=DBGetContactSettingByte(NULL, __INTERNAL_NAME, "OtherWarnings", 1); + g_bCrashRecovery=DBGetContactSettingByte(NULL, __INTERNAL_NAME, "CrashRecovery", 0); + + + if(g_bCrashRecovery) + g_bIncompletedSave=!DBGetContactSettingByte(NULL, __INTERNAL_NAME, "lastSaveCompleted", 0); + + if(g_bIncompletedSave) + { + int i=0; + HANDLE hContact; + ZeroMemory(session_list_recovered,255); + + for (hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact; + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) + { + if(DBGetContactSettingByte(hContact, __INTERNAL_NAME, "wasInLastSession", 0)) + session_list_recovered[i++]=(DWORD)hContact; + } + } + if(!session_list_recovered[0]) g_bIncompletedSave=FALSE; + DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "lastSaveCompleted", 0); + + if (!DBGetContactSettingByte(NULL, __INTERNAL_NAME, "lastempty", 1)||g_bIncompletedSave) isLastTRUE=TRUE; + + startup=DBGetContactSettingByte(NULL, __INTERNAL_NAME, "StartupMode", 3); + + if (startup==1||(startup==3&&isLastTRUE==TRUE)) + { + StartUp=TRUE; + g_hDlg=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_WLCMDIALOG), 0, LoadSessionDlgProc); + } + else if (startup==2&&isLastTRUE==TRUE) + { + g_hghostw=TRUE; + g_hDlg=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_WLCMDIALOG), 0, LoadSessionDlgProc); + } + + HOTKEYDESC hkd = {0}; + hkd.cbSize = sizeof(hkd); + hkd.dwFlags = HKD_TCHAR; + hkd.ptszSection = _T("Sessions"); + hkd.pszName = "OpenSessionsManager"; + hkd.ptszDescription = _T("Open Sessions Manager"); + hkd.pszService = MS_SESSIONS_OPENMANAGER; + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hkd.pszName = "RestoreLastSession"; + hkd.ptszDescription = _T("Restore last Session"); + hkd.pszService = MS_SESSIONS_RESTORELASTSESSION; + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hkd.pszName = "SaveSession"; + hkd.ptszDescription = _T("Save Session"); + hkd.pszService = MS_SESSIONS_SAVEUSERSESSION; + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hkd.pszName = "CloseSession"; + hkd.ptszDescription = _T("Close Session"); + hkd.pszService = MS_SESSIONS_CLOSESESSION; + CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&hkd); + + hiChecked = LoadIcon(hinstance, MAKEINTRESOURCE(IDD_SESSION_CHECKED)); + hiNotChecked = LoadIcon(hinstance, MAKEINTRESOURCE(IDD_SESSION_UNCHECKED)); + + hiSessions = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_SESSIONS)); + hiSessionsLoad = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_SESSIONS_LOAD)); + hiSessionsSave = LoadIcon(hinstance, MAKEINTRESOURCE(IDD_SESSIONS_SAVE)); + hiSessionsLoadLast = LoadIcon(hinstance, MAKEINTRESOURCE(IDD_SESSIONS_LOADLAST)); + + hibChecked =(HANDLE)AddIcon(hiChecked, "SessionMarked", _T("Favorite Session")); + hibNotChecked =(HANDLE)AddIcon(hiNotChecked, "SessionUnMarked", _T("Not favorite Session")); + + hibSessionsLoad =(HANDLE)AddIcon(hiSessionsLoad, "SessionsLoad", _T("Load Session")); + hibSessionsSave =(HANDLE)AddIcon(hiSessionsSave, "SessionsSave", _T("Save Session")); + hibSessionsLoadLast =(HANDLE)AddIcon(hiSessionsLoadLast, "SessionsLoadLast", _T("Load last Session")); + + CLISTMENUITEM cl; + ZeroMemory(&cl, sizeof(cl)); + cl.cbSize = sizeof(CLISTMENUITEM); + cl.position = 1000000000; + cl.flags = CMIM_ALL | CMIF_TCHAR; + + cl.ptszName = _T("Save session..."); + cl.ptszPopupName = _T("Sessions Manager"); + cl.hIcon = hiSessions; + cl.pszService = MS_SESSIONS_SAVEUSERSESSION; + hmSaveCurrentSession = (HANDLE) CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) &cl); + + cl.ptszName = _T("Load session..."); + cl.pszService = MS_SESSIONS_OPENMANAGER; + cl.hIcon = hiSessionsLoad; + hmLoadLastSession = (HANDLE) CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) &cl); + + cl.ptszName = _T("Close session"); + cl.pszService = MS_SESSIONS_CLOSESESSION; + cl.hIcon = 0; + hmLoadSession = (HANDLE) CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) &cl); + + cl.ptszName = _T("Load last session"); + cl.pszService = MS_SESSIONS_RESTORELASTSESSION; + cl.hIcon = hiSessionsLoadLast; + cl.position = 10100000; + hmLoadSession = (HANDLE) CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM) &cl); + + ZeroMemory(&cl, sizeof(cl)); + cl.cbSize = sizeof(cl); + cl.flags = CMIM_ICON; + cl.hIcon = hiSessionsSave; + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hmSaveCurrentSession, (LPARAM)&cl); + + if (ServiceExists(MS_TB_ADDBUTTON)) + { + TBButton button = {0}; + button.defPos = 102200; + button.tbbFlags = TBBF_SHOWTOOLTIP|TBBF_VISIBLE; + + button.pszButtonID = MS_SESSIONS_OPENMANAGER; + button.pszServiceName = MS_SESSIONS_OPENMANAGER; + button.pszTooltipUp = button.pszTooltipUp = button.pszButtonName = "Open Sessions Manager"; + button.hSecondaryIconHandle = button.hPrimaryIconHandle = hibSessionsLoad; + CallService(MS_TB_ADDBUTTON, 0, (LPARAM)&button); + button.defPos++; + + button.pszButtonID = MS_SESSIONS_SAVEUSERSESSION; + button.pszServiceName = MS_SESSIONS_SAVEUSERSESSION; + button.pszTooltipUp = button.pszTooltipUp = button.pszButtonName = "Save Session"; + button.hSecondaryIconHandle = button.hPrimaryIconHandle = hibSessionsSave; + CallService(MS_TB_ADDBUTTON, 0, (LPARAM)&button); + button.defPos++; + + button.pszButtonID = MS_SESSIONS_RESTORELASTSESSION; + button.pszServiceName = MS_SESSIONS_RESTORELASTSESSION; + button.pszTooltipUp = button.pszTooltipUp = button.pszButtonName = "Restore Last Session"; + button.hSecondaryIconHandle = button.hPrimaryIconHandle = hibSessionsLoadLast; + CallService(MS_TB_ADDBUTTON, 0, (LPARAM)&button); + button.defPos++; + + button.pszButtonID = MS_SESSIONS_SHOWFAVORITESMENU; + button.pszServiceName = MS_SESSIONS_SHOWFAVORITESMENU; + button.pszTooltipUp = button.pszTooltipUp = button.pszButtonName = "Show Favorite Sessions Menu"; + button.hSecondaryIconHandle = button.hPrimaryIconHandle = hibChecked; + CallService(MS_TB_ADDBUTTON, 0, (LPARAM)&button); + } + + if(ServiceExists(MS_UPDATE_REGISTER)) + { + char buffer[1024]; + Update update = {0}; + update.cbSize = sizeof(Update); + update.szComponentName = pluginInfo.shortName; + update.pbVersion = (BYTE *) CreateVersionString(pluginInfo.version, buffer); + update.cpbVersion = (int)strlen((char *) update.pbVersion); + //update.szUpdateURL = UPDATER_AUTOREGISTER; + update.szBetaVersionURL = SESSIONS_VERSION_URL; + update.szBetaUpdateURL = SESSIONS_UPDATE_URL; + update.pbBetaVersionPrefix = (BYTE *) SESSIONS_VERSION_PREFIX; + update.cpbBetaVersionPrefix = (int)strlen(SESSIONS_VERSION_PREFIX); + CallService(MS_UPDATE_REGISTER, 0, (LPARAM) &update); + } + + return 0; +} + +// {28EE6FE2-B005-4073-BA90-148203C807D0} +static const MUUID interfaces[] = {{ 0x28ee6fe2, 0xb005, 0x4073, { 0xba, 0x90, 0x14, 0x82, 0x3, 0xc8, 0x7, 0xd0 } }, MIID_LAST}; +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + if (mirandaVersion < PLUGIN_MAKE_VERSION(0, 9, 0, 0)) + return NULL; + + return &pluginInfo; +} + +extern "C" __declspec(dllexport) int Unload(void) +{ + return 0; +} + +BOOL WINAPI DllMain(HINSTANCE hinst,DWORD fdwReason,LPVOID lpvReserved) +{ + hinstance=hinst; + return 1; +} + +extern "C" __declspec(dllexport) int Load(PLUGINLINK *link) +{ + pluginLink=link; + mir_getMMI(&mmi); + mir_getLP(&pluginInfo); + + hEventDbPluginsLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,PluginInit); + hEventDbOkToExit=HookEvent(ME_SYSTEM_OKTOEXIT,OkToExit); + hEventDbPreShutdown=HookEvent(ME_SYSTEM_PRESHUTDOWN,SessionPreShutdown); + return 0; +} \ No newline at end of file diff --git a/plugins/Sessions/Src/Options.cpp b/plugins/Sessions/Src/Options.cpp new file mode 100644 index 0000000000..3998f2de2c --- /dev/null +++ b/plugins/Sessions/Src/Options.cpp @@ -0,0 +1,572 @@ +/* +Sessions Management plugin for Miranda IM + +Copyright (C) 2007-2008 Danil Mozhar + +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 3 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, see . +*/ + + +#include "sessions.h" + +HICON hIcon; +HICON hMarked,hNotMarked; + +HWND hComboBox=NULL; +HWND hComboBoxEdit=NULL; + +WNDPROC oldComboProc=0; + +HWND hOpClistControl=NULL; + +static BOOL bOptionsInit; +int opses_count; +BOOL bSesssionNameChanged=0; + +DWORD session_list_t[255]={0}; + +HWND g_opHdlg; + +int width; +HDC hdc=NULL; +RECT lprect; +RECT rc; +POINT pt; +BOOL bChecked=FALSE; + +int OpLoadSessionContacts(WPARAM wparam,LPARAM lparam) +{ + HANDLE hContact; + int i=0; + ZeroMemory(session_list_t,SIZEOF(session_list_t)); + + for (hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact; + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) + { + if(LoadContactsFromMask(hContact,1,lparam)) + { + i=GetInSessionOrder(hContact,1, lparam); + session_list_t[i]=(DWORD)hContact; + } + } + + i=0; + while(session_list_t[i]!=0) + { + SendDlgItemMessage(g_opHdlg, IDC_OPCLIST, LB_ADDSTRING, 0, + (LPARAM)(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, + (WPARAM)session_list_t[i], GCDNF_TCHAR)); + i++; + } + return i; +} + +static LRESULT CALLBACK ComboBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_ERASEBKGND: + return TRUE; + + case EM_SETSEL: + if(!hOpClistControl) + return HideCaret(hwnd); + break; + + case WM_GETDLGCODE: + if(!hOpClistControl) + return DLGC_WANTARROWS; + break; + + case WM_SETCURSOR: + { + if(!hOpClistControl) + { + SetCursor(LoadCursor(NULL, IDC_ARROW)); + return TRUE; + } + }break; + + case WM_LBUTTONDOWN: + if(hOpClistControl) + break; + HideCaret(hwnd); + + case WM_LBUTTONDBLCLK: + case WM_MBUTTONDOWN: + case WM_MBUTTONDBLCLK: + SendMessage(hComboBox,CB_SHOWDROPDOWN,1,0); + return TRUE; + + case WM_NCLBUTTONDBLCLK: + case WM_NCLBUTTONDOWN: + if(!bChecked) + { + MarkUserDefSession(opses_count,1); + hIcon=hMarked; + bChecked=TRUE; + RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE|RDW_UPDATENOW|RDW_FRAME); + } + else + { + MarkUserDefSession(opses_count,0); + hIcon=hNotMarked; + bChecked=FALSE; + RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE|RDW_UPDATENOW|RDW_FRAME); + } + break; + + case WM_MOUSEMOVE: + if(hOpClistControl) + break; + + case WM_NCMOUSEMOVE: + return TRUE; + + case WM_NCPAINT: + { + hdc=GetDC(hwnd); + GetClientRect(hwnd, &rc); + rc.left=rc.right; + rc.right=rc.left+16; + + FillRect(hdc, &rc, (HBRUSH)GetSysColor(COLOR_WINDOW)); + DrawIconEx(hdc, rc.left, 0, hIcon, 16, 16, 0, NULL, DI_NORMAL); + ReleaseDC(hwnd, hdc); + }break; + + case WM_NCCALCSIZE: + { + NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS*)lParam; + ncsParam->rgrc[ 0 ].right -= 16; + }break; + + case WM_NCHITTEST: + { + LRESULT lr = CallWindowProc( oldComboProc, hwnd, msg, wParam, lParam ); + if(lr==HTNOWHERE ) + lr = HTOBJECT; + return lr; + } + } + return CallWindowProc(oldComboProc, hwnd, msg, wParam, lParam); +} + +INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + int startupmode,exitmode; + COMBOBOXINFO cbi={0}; + cbi.cbSize = sizeof(cbi); + + opses_count=0; + g_opHdlg=hdlg; + bOptionsInit=TRUE; + TranslateDialogDefault(hdlg); + hMarked=(HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)hibChecked); + hNotMarked=(HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)hibNotChecked); + + hIcon=(bChecked=IsMarkedUserDefSession(opses_count))?hMarked:hNotMarked; + + SetDlgItemInt(hdlg, IDC_TRACK,ses_limit=DBGetContactSettingByte(0, __INTERNAL_NAME, "TrackCount", 10), FALSE); + SendDlgItemMessage(hdlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(10, 1)); + SendDlgItemMessage(hdlg, IDC_SPIN1, UDM_SETPOS, 0, GetDlgItemInt(hdlg, IDC_TRACK, NULL, FALSE)); + + SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0); + SetDlgItemInt(hdlg, IDC_STARTDELAY, DBGetContactSettingWord(NULL, __INTERNAL_NAME, "StartupModeDelay", 1500), FALSE); + startupmode = DBGetContactSettingByte(NULL, __INTERNAL_NAME, "StartupMode", 3); + exitmode = DBGetContactSettingByte(NULL, __INTERNAL_NAME, "ShutdownMode", 2); + + g_bExclHidden = DBGetContactSettingByte(NULL, __INTERNAL_NAME, "ExclHidden", 0); + g_bWarnOnHidden = DBGetContactSettingByte(NULL, __INTERNAL_NAME, "WarnOnHidden", 0); + g_bOtherWarnings = DBGetContactSettingByte(NULL, __INTERNAL_NAME, "OtherWarnings", 1); + g_bCrashRecovery = DBGetContactSettingByte(NULL, __INTERNAL_NAME, "CrashRecovery", 0); + + CheckDlgButton(hdlg,IDC_EXCLHIDDEN,g_bExclHidden?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hdlg,IDC_LASTHIDDENWARN,g_bWarnOnHidden?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hdlg,IDC_WARNINGS,g_bOtherWarnings?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hdlg,IDC_CRASHRECOVERY,g_bCrashRecovery?BST_CHECKED:BST_UNCHECKED); + + + if(startupmode==1) + CheckDlgButton(hdlg,IDC_STARTDIALOG,BST_CHECKED); + else if (startupmode==3) + { + CheckDlgButton(hdlg,IDC_STARTDIALOG,BST_CHECKED); + CheckDlgButton(hdlg,IDC_CHECKLAST,BST_CHECKED); + } + else if (startupmode==2) + { + CheckDlgButton(hdlg,IDC_RLOADLAST,BST_CHECKED); + EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE); + } + else if (startupmode==0) + { + CheckDlgButton(hdlg,IDC_RNOTHING,BST_CHECKED); + EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), FALSE); + EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), FALSE); + EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), FALSE); + EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE); + } + if(exitmode==0) + { + CheckDlgButton(hdlg,IDC_REXDSAVE,BST_CHECKED); + EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),FALSE); + EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),FALSE); + EnableWindow(GetDlgItem(hdlg,IDC_TRACK),FALSE); + EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),FALSE); + } + else if (exitmode==1) CheckDlgButton(hdlg,IDC_REXASK,BST_CHECKED); + else if (exitmode==2) CheckDlgButton(hdlg,IDC_REXSAVE,BST_CHECKED); + + LoadSessionToCombobox (hdlg,1,255,"UserSessionDsc",0); + if(SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, (WPARAM)0, 0)) + { + EnableWindow(GetDlgItem(hdlg,IDC_EDIT),TRUE); + SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, (WPARAM)0, 0); + if(!OpLoadSessionContacts(0,opses_count)) + EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE); + } + + GetComboBoxInfo(GetDlgItem(hdlg,IDC_LIST),&cbi); + oldComboProc=(WNDPROC)SetWindowLongPtr(cbi.hwndItem, GWLP_WNDPROC, (LONG) ComboBoxSubclassProc); + + hComboBoxEdit=cbi.hwndItem; + hComboBox=cbi.hwndCombo; + + SetWindowPos( hComboBoxEdit, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED ); + + bOptionsInit=FALSE; + }break; + + case WM_CTLCOLORLISTBOX: + { + switch(GetDlgCtrlID((HWND) lparam)) + { + case IDC_OPCLIST: + SetBkMode((HDC) wparam, TRANSPARENT); + return (BOOL) CreateSolidBrush(GetSysColor(COLOR_3DFACE)); + default: + break; + } + }break; + + case WM_NOTIFY: + switch(((LPNMHDR)lparam)->code) + { + case PSN_APPLY: + { + int iDelay=GetDlgItemInt(hdlg, IDC_STARTDELAY,NULL, FALSE); + DBWriteContactSettingWord(0, __INTERNAL_NAME, "StartupModeDelay", (WORD)iDelay); + + DBWriteContactSettingByte(0, __INTERNAL_NAME, "TrackCount", (BYTE)(ses_limit=GetDlgItemInt(hdlg, IDC_TRACK,NULL, FALSE))); + if(IsDlgButtonChecked(hdlg, IDC_REXSAVE)) DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "ShutdownMode", 2); + else if(IsDlgButtonChecked(hdlg, IDC_REXDSAVE)) DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "ShutdownMode", 0); + else if(IsDlgButtonChecked(hdlg, IDC_REXASK)) DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "ShutdownMode", 1); + + if(IsDlgButtonChecked(hdlg, IDC_STARTDIALOG)) + { + if(!IsDlgButtonChecked(hdlg, IDC_CHECKLAST)) + DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "StartupMode", 1); + else DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "StartupMode", 3); + } + else if(IsDlgButtonChecked(hdlg, IDC_RLOADLAST)) DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "StartupMode", 2); + else if(IsDlgButtonChecked(hdlg, IDC_RNOTHING)) DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "StartupMode", 0); + + DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "ExclHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_EXCLHIDDEN) ? (g_bExclHidden = 1) : (g_bExclHidden = 0))); + DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "WarnOnHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_LASTHIDDENWARN) ? (g_bWarnOnHidden = 1) : (g_bWarnOnHidden = 0))); + DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "OtherWarnings", (BYTE)(IsDlgButtonChecked(hdlg, IDC_WARNINGS) ? (g_bOtherWarnings = 1) : (g_bOtherWarnings = 0))); + DBWriteContactSettingByte(NULL, __INTERNAL_NAME, "CrashRecovery", (BYTE)(IsDlgButtonChecked(hdlg, IDC_CRASHRECOVERY) ? (g_bCrashRecovery = 1) : (g_bCrashRecovery = 0))); + + return 1; + } + + case CLN_CHECKCHANGED: + { + if (((LPNMHDR)lparam)->idFrom ==IDC_EMCLIST) + { + int iSelection = (int)((NMCLISTCONTROL *)lparam)->hItem; + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + for ( ; hContact; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) + if (SendDlgItemMessage(hdlg, IDC_EMCLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0) == iSelection) + break; + if (hContact) + EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE); + else + EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE); + } + } + } + break; + + case WM_COMMAND: + switch(LOWORD(wparam)) + { + case IDC_LIST: + switch(HIWORD(wparam)) + { + case CBN_EDITCHANGE: + EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE); + bSesssionNameChanged=TRUE; + break; + + case CBN_SELCHANGE: + { + HWND hCombo = GetDlgItem(hdlg, IDC_LIST); + int index = SendMessage(hCombo, CB_GETCURSEL, 0, 0); + if(index != CB_ERR) + { + opses_count = SendMessage(hCombo, CB_GETITEMDATA, (WPARAM)index, 0); + SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0); + if(IsMarkedUserDefSession(opses_count)) + { + hIcon=hMarked; + bChecked=TRUE; + RedrawWindow(hComboBoxEdit, NULL, NULL, RDW_INVALIDATE|RDW_NOCHILDREN|RDW_UPDATENOW|RDW_FRAME); + } + else + { + hIcon=hNotMarked; + bChecked=FALSE; + RedrawWindow(hComboBoxEdit, NULL, NULL, RDW_INVALIDATE|RDW_NOCHILDREN|RDW_UPDATENOW|RDW_FRAME); + } + OpLoadSessionContacts(0,opses_count); + if(!hOpClistControl) + EnableWindow(GetDlgItem(hdlg,IDC_DEL),TRUE); + else + { + int i; + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + + for ( ; hContact; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) + SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hContact,0); + for (i=0 ; session_list_t[i]>0; i++) + { + hContact=(HANDLE)SendMessage(hOpClistControl,CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0); + //hItem=session_list[i]; + SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hContact,1); + } + EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE); + } + } + }break; + }break; + + case IDC_EDIT: + { + if(!hOpClistControl) + { + int i; + HANDLE hItem; + ShowWindow(GetDlgItem(hdlg,IDC_OPCLIST),SW_HIDE); + EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE); + //EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE); + SetWindowText(GetDlgItem(hdlg,IDC_EDIT),TranslateT("View")); + hOpClistControl = CreateWindowEx(WS_EX_STATICEDGE,CLISTCONTROL_CLASS, _T(""), + WS_TABSTOP |WS_VISIBLE | WS_CHILD , + 14,198,161,163,hdlg, (HMENU)IDC_EMCLIST, hinstance, 0); + + SetWindowLongPtr(hOpClistControl, GWL_STYLE, + GetWindowLongPtr(hOpClistControl, GWL_STYLE)|CLS_CHECKBOXES|CLS_HIDEEMPTYGROUPS|CLS_USEGROUPS|CLS_GREYALTERNATE|CLS_GROUPCHECKBOXES); + SendMessage(hOpClistControl, CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP|CLS_EX_TRACKSELECT, 0); + + SendMessage(hOpClistControl,WM_TIMER,TIMERID_REBUILDAFTER,0); + + for (i=0 ; session_list_t[i]>0; i++) + { + hItem=(HANDLE)SendMessage(hOpClistControl,CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0); + //hItem=session_list[i]; + SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hItem,1); + } + } + else + { + ShowWindow(GetDlgItem(hdlg,IDC_OPCLIST),SW_SHOWNA); + EnableWindow(GetDlgItem(hdlg,IDC_DEL),TRUE); + EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE); + SetWindowText(GetDlgItem(hdlg,IDC_EDIT),TranslateT("Edit")); + DestroyWindow(hOpClistControl); + hOpClistControl=NULL; + } + }break; + + case IDC_SAVE: + { + int i; + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + for (i=0 ; hContact;hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) + { + BYTE res =(BYTE)SendMessage(GetDlgItem(hdlg,IDC_EMCLIST), CLM_GETCHECKMARK, + SendMessage(GetDlgItem(hdlg,IDC_EMCLIST), CLM_FINDCONTACT, (WPARAM)hContact, 0), 0); + if (res) + { + SetSessionMark(hContact,1,'1',opses_count); + SetInSessionOrder(hContact,1,opses_count,i); + i++; + } + else + { + SetSessionMark(hContact,1,'0',opses_count); + SetInSessionOrder(hContact,1,opses_count,0); + } + } + if(bSesssionNameChanged) + { + if(GetWindowTextLength(hComboBoxEdit)) + { + TCHAR szUserSessionName[MAX_PATH]={'\0'}; + GetWindowText(hComboBoxEdit, szUserSessionName, SIZEOF(szUserSessionName)); + RenameUserDefSession(opses_count,szUserSessionName); + SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT ,0,0); + LoadSessionToCombobox (hdlg,1,255,"UserSessionDsc",0); + } + bSesssionNameChanged=FALSE; + } + EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE); + }break; + + case IDC_DEL: + { + int i=0,index=0; + DelUserDefSession(opses_count); + + SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0); + SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0); + + LoadSessionToCombobox (hdlg,1,255,"UserSessionDsc",0); + + opses_count=0; + + if(SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, (WPARAM)0, 0)) + { + EnableWindow(GetDlgItem(hdlg,IDC_EDIT),TRUE); + SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, (WPARAM)0, 0); + if(!OpLoadSessionContacts(0,opses_count)) + EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE); + } + else + { + EnableWindow(GetDlgItem(hdlg,IDC_EDIT),FALSE); + EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE); + } + }break; + + case IDC_STARTDIALOG: + { + EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), TRUE); + EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), TRUE); + EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), TRUE); + EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), TRUE); + SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); + }break; + + case IDC_RLOADLAST: + { + EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), TRUE); + EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), TRUE); + EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), TRUE); + EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE); + SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); + }break; + + case IDC_RNOTHING: + { + EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), FALSE); + EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), FALSE); + EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), FALSE); + EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE); + SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); + }break; + + case IDC_REXSAVE: + { + EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),TRUE); + EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),TRUE); + EnableWindow(GetDlgItem(hdlg,IDC_TRACK),TRUE); + EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),TRUE); + SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); + }break; + + case IDC_REXDSAVE: + { + EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),FALSE); + EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),FALSE); + EnableWindow(GetDlgItem(hdlg,IDC_TRACK),FALSE); + EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),FALSE); + SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); + }break; + + case IDC_REXASK: + { + EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),TRUE); + EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),TRUE); + EnableWindow(GetDlgItem(hdlg,IDC_TRACK),TRUE); + EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),TRUE); + SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); + }break; + } + + if (HIWORD(wparam)==CBN_DROPDOWN&&!hOpClistControl) + { + SendMessage(hComboBoxEdit,EM_SETSEL ,0,0); + SendMessage(hComboBoxEdit,EM_SCROLLCARET ,0,0); + SendMessage(hComboBoxEdit,WM_KILLFOCUS ,0,0); + HideCaret(hComboBoxEdit); + } + + if((HIWORD(wparam)!=CBN_DROPDOWN)&&(LOWORD(wparam)==IDC_LIST)&&!hOpClistControl) + { + SendMessage(hComboBoxEdit,EM_SCROLLCARET ,0,0); + HideCaret(hComboBoxEdit); + } + + if ((LOWORD(wparam) == IDC_STARTDELAY) && (HIWORD(wparam)!=EN_CHANGE || (HWND)lparam != GetFocus())) + return 0; + + if (lparam&&!bOptionsInit&&(HIWORD(wparam)==BN_CLICKED)&& (GetFocus()==(HWND)lparam) + &&((LOWORD(wparam)==IDC_CHECKLAST)||((LOWORD(wparam)>=IDC_EXCLHIDDEN)&&(LOWORD(wparam)<=IDC_CRASHRECOVERY)))) + SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); + + return 0; + + case WM_NCDESTROY: + SetWindowLongPtr(hComboBoxEdit, GWLP_WNDPROC, (LONG)oldComboProc); + break; + + case WM_CLOSE: + EndDialog(hdlg,0); + return 0; + } + return 0; +} + +int OptionsInit(WPARAM wparam,LPARAM lparam) +{ + OPTIONSDIALOGPAGE odp={0}; + + odp.cbSize = sizeof(odp); + odp.position=955000000; + odp.hInstance=hinstance; + odp.pszTemplate=MAKEINTRESOURCEA(IDD_OPTIONS); + odp.ptszTitle=LPGENT(__INTERNAL_NAME); + odp.pfnDlgProc=OptionsProc; + odp.ptszGroup=LPGENT("Message Sessions"); + odp.flags=ODPF_BOLDGROUPS | ODPF_TCHAR; + + CallService(MS_OPT_ADDPAGE,wparam,(LPARAM)&odp); + return 0; +} \ No newline at end of file diff --git a/plugins/Sessions/Src/Sessions.h b/plugins/Sessions/Src/Sessions.h new file mode 100644 index 0000000000..e4d5425c07 --- /dev/null +++ b/plugins/Sessions/Src/Sessions.h @@ -0,0 +1,92 @@ +/* +Sessions Management plugin for Miranda IM + +Copyright (C) 2007-2008 Danil Mozhar + +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 3 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, see . +*/ + +#define _CRT_SECURE_NO_DEPRECATE + +#define _WIN32_WINNT 0x0501 + +#define MIRANDA_VER 0x0900 +#define MIRANDA_CUSTOM_LP + +#include +#include + +#include "newpluginapi.h" +#include "m_utils.h" +#include "m_system.h" +#include "m_options.h" +#include "m_clc.h" +#include "m_database.h" +#include "m_langpack.h" +#include "m_icolib.h" +#include "m_message.h" +#include "m_clist.h" +#include "m_hotkeys.h" +#include "win2k.h" + +#include "m_updater.h" +#include "m_toolbar.h" +#include "m_sessions.h" + +#include "Utils.h" +#include "../Version.h" +#include "../Resource.h" + +extern HANDLE hibChecked; +extern HANDLE hibNotChecked; + +#define MIIM_STRING 0x00000040 + +int DelUserDefSession(int ses_count); +int DeleteAutoSession(int ses_count); +int LoadSession(WPARAM ,LPARAM ); +int SaveSessionHandles(WPARAM ,LPARAM ); +INT_PTR SaveUserSessionHandles(WPARAM ,LPARAM ); +int SaveUserSessionName(TCHAR*); +INT_PTR CloseCurrentSession(WPARAM ,LPARAM ); +int SaveSessionDate(); + +extern HINSTANCE hinstance; +extern DWORD session_list_recovered[255]; +extern DWORD session_list[255]; +extern unsigned int ses_limit; +extern unsigned int g_ses_count; +extern BOOL g_bExclHidden; +extern BOOL g_bWarnOnHidden; +extern BOOL g_bOtherWarnings; +extern BOOL g_bCrashRecovery; +extern BOOL g_bIncompletedSave; + +#define TIMERID_LOAD 12 +#define TIMERID_SHOW 11 +#define TIMERID_REBUILDAFTER 14 + +#ifdef _UNICODE +#define SESSIONS_NAME "sessions_u" +#else +#define SESSIONS_NAME "sessions_a" +#endif + +#define SESSIONS_VERSION_URL "http://miranda.radicaled.ru/public/updater/sessions.txt" + +#define SESSIONS_UPDATE_URL "http://miranda.radicaled.ru/public/sessions/"SESSIONS_NAME".zip" + +#define SESSIONS_UPDATE_URL "http://miranda.radicaled.ru/public/sessions/"SESSIONS_NAME".zip" + +#define SESSIONS_VERSION_PREFIX "Sessions " diff --git a/plugins/Sessions/Src/Utils.cpp b/plugins/Sessions/Src/Utils.cpp new file mode 100644 index 0000000000..4b5ba065a0 --- /dev/null +++ b/plugins/Sessions/Src/Utils.cpp @@ -0,0 +1,571 @@ +/* +Sessions Management plugin for Miranda IM + +Copyright (C) 2007-2008 Danil Mozhar + +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 3 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, see . +*/ + + +#include "sessions.h" + +void AddSessionMark(HANDLE hContact,int mode,char bit) +{ + unsigned int i; + char temp_1[1]={'\0'},temp_2[1]={'\0'}; + char szDst[256]={'\0'}; + char* pszBuffer=NULL; + if(mode==0) + { + DBVARIANT dbv; + if(!DBGetContactSettingString(hContact, __INTERNAL_NAME, "LastSessionsMarks", &dbv) && dbv.pszVal) + { + temp_1[0]=dbv.pszVal[0]; + for (i=0;i. +*/ + +#ifndef __UTILS_H__ +# define __UTILS_H__ + +void SetInSessionOrder(HANDLE hContact,int mode,int count,unsigned int ordernum); +void AddInSessionOrder(HANDLE hContact,int mode,int ordernum,int writemode); +int GetInSessionOrder(HANDLE hContact,int mode,int count); +void AddSessionMark(HANDLE hContact,int mode,char bit); +void RemoveSessionMark(HANDLE hContact,int mode,int marknum); +void SetSessionMark(HANDLE hContact,int mode,char bit,unsigned int marknum); +BOOL LoadContactsFromMask(HANDLE hContact,int mode,int count); +int AddToCurSession (DWORD wparam,LPARAM lparam); +int DelFromCurSession(DWORD wparam,LPARAM lparam); +int CheckForDuplicate(DWORD contact_list[],DWORD lparam); +BOOL ResaveSettings(char* szName,int iFirst,int iLimit,TCHAR* pszPrevSetting); +void OffsetWindow(HWND parent, HWND hwnd, int dx, int dy); +int LoadSessionToCombobox (HWND hdlg,BOOL mode,int iLimit,char* pszSetting,int iFirstNum); +int AddIcon(HICON icon, char *name, TCHAR *description); +int MarkUserDefSession(int ses_count,BYTE bCheck); +BYTE IsMarkedUserDefSession(int ses_count); +void SavePosition(HWND hWnd, char *wndName); +void LoadPosition(HWND hWnd, char *wndName); +int CheckContactVisibility(HANDLE hContact); +void RenameUserDefSession(int ses_count,TCHAR* ptszNewName); +int FillFavoritesMenu (HMENU hMenu,int iLimit); + +#endif // __UTILS_H__ \ No newline at end of file diff --git a/plugins/Sessions/Version.h b/plugins/Sessions/Version.h new file mode 100644 index 0000000000..35c74bfb55 --- /dev/null +++ b/plugins/Sessions/Version.h @@ -0,0 +1,28 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 1 +#define __RELEASE_NUM 3 +#define __BUILD_NUM 0 + +#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM +#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM + +#define __STRINGIFY_IMPL(x) #x +#define __STRINGIFY(x) __STRINGIFY_IMPL(x) +#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS) + +#ifdef _UNICODE +#if defined(WIN64) || defined(_WIN64) + #define __PLUGIN_NAME "Sessions (Unicode x64)" +#else + #define __PLUGIN_NAME "Sessions (Unicode)" +#endif +#else + #define __PLUGIN_NAME "Sessions" +#endif +#define __INTERNAL_NAME "Sessions" +#define __FILENAME "Sessions.dll" +#define __DESCRIPTION "Sessions Manager for Miranda IM." +#define __AUTHOR "MaD_CLuSTeR" +#define __AUTHOREMAIL "daniok@yandex.ru" +#define __AUTHORWEB "http://miranda.radicaled.ru/index.php?plugin=2" +#define __COPYRIGHT "© 2007-2008 Danil Mozhar" diff --git a/plugins/Sessions/Version.rc b/plugins/Sessions/Version.rc new file mode 100644 index 0000000000..e637f0cb33 --- /dev/null +++ b/plugins/Sessions/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 -- cgit v1.2.3