summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-03-29 19:00:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-03-29 19:00:04 +0300
commit763dc81bdc7ef636d6477f2933876e80ca8fc58d (patch)
tree1c6653e78465da7af5a1daaa04ca5261f25e12b9 /plugins
parent89a9193b6c6a8f87314634618b6893c8b62473aa (diff)
Sessions:
- fixes #2816 (Sessions: "Save and close" option closes message log instead of container); - massive code reordering; - session saving dialog -> UI classes
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Sessions/Sessions.vcxproj2
-rw-r--r--plugins/Sessions/Sessions.vcxproj.filters6
-rw-r--r--plugins/Sessions/Src/LoadSessions.cpp272
-rw-r--r--plugins/Sessions/Src/Main.cpp483
-rw-r--r--plugins/Sessions/Src/Options.cpp24
-rw-r--r--plugins/Sessions/Src/SaveSessions.cpp237
-rw-r--r--plugins/Sessions/Src/stdafx.h30
-rw-r--r--plugins/Sessions/res/Sessions.rc3
8 files changed, 565 insertions, 492 deletions
diff --git a/plugins/Sessions/Sessions.vcxproj b/plugins/Sessions/Sessions.vcxproj
index 9188688b9a..b1a8b267f5 100644
--- a/plugins/Sessions/Sessions.vcxproj
+++ b/plugins/Sessions/Sessions.vcxproj
@@ -26,8 +26,10 @@
<Import Project="$(ProjectDir)..\..\build\vc.common\plugin.props" />
</ImportGroup>
<ItemGroup>
+ <ClCompile Include="Src\LoadSessions.cpp" />
<ClCompile Include="src\Main.cpp" />
<ClCompile Include="src\Options.cpp" />
+ <ClCompile Include="Src\SaveSessions.cpp" />
<ClCompile Include="src\stdafx.cxx">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
diff --git a/plugins/Sessions/Sessions.vcxproj.filters b/plugins/Sessions/Sessions.vcxproj.filters
index e77ade1bd0..b3f50e8d3a 100644
--- a/plugins/Sessions/Sessions.vcxproj.filters
+++ b/plugins/Sessions/Sessions.vcxproj.filters
@@ -14,6 +14,12 @@
<ClCompile Include="src\Utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="Src\LoadSessions.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Src\SaveSessions.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\Resource.h">
diff --git a/plugins/Sessions/Src/LoadSessions.cpp b/plugins/Sessions/Src/LoadSessions.cpp
new file mode 100644
index 0000000000..dcc8e419a3
--- /dev/null
+++ b/plugins/Sessions/Src/LoadSessions.cpp
@@ -0,0 +1,272 @@
+/*
+Copyright (C) 2012-21 Miranda NG team (https://miranda-ng.org)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation version 2
+of the License.
+
+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 <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h"
+
+bool g_hghostw, g_bStartup;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM)
+{
+ static int ses_count;
+
+ g_hDlg = hdlg;
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hdlg);
+ {
+ int iDelay = g_plugin.getWord("StartupModeDelay", 1500);
+ if (g_hghostw == TRUE)
+ SetTimer(hdlg, TIMERID_LOAD, iDelay, nullptr);
+ else {
+ if ((ses_count = LoadSessionToCombobox(hdlg, 0, g_ses_limit, "SessionDate", 0)) == g_ses_limit)
+ EnableWindow(GetDlgItem(hdlg, IDC_SESSDEL), TRUE);
+
+ if (LoadSessionToCombobox(hdlg, 0, 255, "UserSessionDsc", g_ses_limit) == 0 && ses_count != 0)
+ ses_count = 0;
+
+ if (session_list_recovered[0])
+ ses_count = 256;
+
+ SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
+ LoadPosition(hdlg, "LoadDlg");
+ if (g_bStartup)
+ SetTimer(hdlg, TIMERID_SHOW, iDelay, nullptr);
+ else
+ ShowWindow(g_hDlg, SW_SHOW);
+ }
+ }
+ break;
+
+ case WM_TIMER:
+ if (wparam == TIMERID_SHOW) {
+ KillTimer(hdlg, TIMERID_SHOW);
+ ShowWindow(hdlg, SW_SHOW);
+ g_bStartup = FALSE;
+ }
+ else {
+ KillTimer(hdlg, TIMERID_LOAD);
+ LoadSession(0, g_bIncompletedSave ? 256 : 0);
+ g_hghostw = g_bStartup = FALSE;
+ DestroyWindow(hdlg);
+ g_hDlg = nullptr;
+ }
+ break;
+
+ case WM_CLOSE:
+ SavePosition(hdlg, "LoadDlg");
+ DestroyWindow(hdlg);
+ g_hDlg = nullptr;
+ 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;
+
+ case IDC_SESSDEL:
+ if (session_list_recovered[0] && ses_count == 256) {
+ for (int i = 0; session_list_recovered[i]; i++)
+ g_plugin.setByte(session_list_recovered[i], "wasInLastSession", 0);
+
+ memset(session_list_recovered, 0, 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, g_ses_limit, "SessionDate", 0)) == g_ses_limit)
+ EnableWindow(GetDlgItem(hdlg, IDC_SESSDEL), TRUE);
+
+ if (LoadSessionToCombobox(hdlg, 1, 255, "UserSessionDsc", g_ses_limit) == 0 && ses_count != 0)
+ ses_count = 0;
+
+ SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
+
+ }
+ else if (ses_count >= g_ses_limit) {
+ ses_count -= g_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, g_ses_limit, "SessionDate", 0)) == g_ses_limit)
+ EnableWindow(GetDlgItem(hdlg, IDC_SESSDEL), TRUE);
+
+ if (LoadSessionToCombobox(hdlg, 0, 255, "UserSessionDsc", g_ses_limit) == 0 && ses_count != 0)
+ ses_count = 0;
+
+ if (session_list_recovered[0])
+ ses_count = 256;
+
+ SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 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, g_ses_limit, "SessionDate", 0)) == g_ses_limit)
+ EnableWindow(GetDlgItem(hdlg, IDC_SESSDEL), TRUE);
+
+ if (LoadSessionToCombobox(hdlg, 0, 255, "UserSessionDsc", g_ses_limit) == 0 && ses_count != 0)
+ ses_count = 0;
+
+ if (session_list_recovered[0])
+ ses_count = 256;
+
+ SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 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 = nullptr;
+ }
+ break;
+
+ case IDCANCEL:
+ SavePosition(hdlg, "LoadDlg");
+ DestroyWindow(hdlg);
+ g_hDlg = nullptr;
+ break;
+ }
+ break;
+
+ default:
+ return FALSE;
+ }
+ return TRUE;
+}
+
+INT_PTR OpenSessionsManagerWindow(WPARAM, LPARAM)
+{
+ if (g_hDlg) {
+ ShowWindow(g_hDlg, SW_SHOW);
+ return 0;
+ }
+
+ ptrW tszSession(g_plugin.getWStringA("SessionDate_0")), tszUserSession(g_plugin.getWStringA("UserSessionDsc_0"));
+ if (g_bIncompletedSave || tszSession || tszUserSession) {
+ g_hDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WLCMDIALOG), nullptr, LoadSessionDlgProc);
+ return 0;
+ }
+
+ if (g_bOtherWarnings)
+ MessageBox(nullptr, TranslateT("No sessions to open"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
+ return 1;
+}
+
+void CALLBACK LaunchSessions()
+{
+ int startup = g_plugin.getByte("StartupMode", 3);
+ if (startup == 1 || (startup == 3 && isLastTRUE == TRUE)) {
+ g_bStartup = TRUE;
+ g_hDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WLCMDIALOG), nullptr, LoadSessionDlgProc);
+ }
+ else if (startup == 2 && isLastTRUE == TRUE) {
+ g_hghostw = TRUE;
+ g_hDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WLCMDIALOG), nullptr, LoadSessionDlgProc);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+INT_PTR LoadLastSession(WPARAM wparam, LPARAM lparam)
+{
+ if (isLastTRUE)
+ return LoadSession(wparam, lparam);
+ if (g_bOtherWarnings)
+ MessageBox(nullptr, TranslateT("Last Sessions is empty"), TranslateT("Sessions Manager"), MB_OK);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Load session dialog
+
+int LoadSession(WPARAM, LPARAM lparam)
+{
+ int dup = 0;
+ int hidden[255] = { '0' };
+ MCONTACT session_list_t[255] = { 0 };
+ int mode = 0;
+ if ((int)lparam >= g_ses_limit && lparam != 256) {
+ mode = 1;
+ lparam -= g_ses_limit;
+ }
+ if (session_list_recovered[0] && lparam == 256 && mode == 0)
+ memcpy(session_list_t, session_list_recovered, sizeof(session_list_t));
+ else
+ for (auto &hContact : Contacts())
+ if (LoadContactsFromMask(hContact, mode, lparam)) {
+ int i = GetInSessionOrder(hContact, mode, lparam);
+ session_list_t[i] = hContact;
+ }
+
+ int i = 0, j = 0;
+ // TODO: change to "switch"
+ while (session_list_t[i] != 0) {
+ if (CheckForDuplicate(session_list, session_list_t[i]) == -1)
+ Clist_ContactDoubleClicked(session_list_t[i]);
+ else if (g_bWarnOnHidden) {
+ if (!CheckContactVisibility(session_list_t[i])) {
+ hidden[j] = i + 1;
+ j++;
+ }
+ dup++;
+ }
+ i++;
+ }
+
+ if (i == 0) {
+ if (g_bOtherWarnings)
+ MessageBox(nullptr, TranslateT("No contacts to open"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
+ return 1;
+ }
+
+ if (dup == i) {
+ if (!hidden[i]) {
+ if (g_bOtherWarnings)
+ MessageBox(nullptr, TranslateT("This Session already opened"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
+ return 1;
+ }
+ if (!g_bWarnOnHidden && g_bOtherWarnings) {
+ MessageBox(nullptr, TranslateT("This Session already opened"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
+ return 1;
+ }
+ if (g_bWarnOnHidden) {
+ if (IDYES == MessageBox(nullptr, TranslateT("This Session already opened (but probably hidden).\nDo you want to show hidden contacts?"), TranslateT("Sessions Manager"), MB_YESNO | MB_ICONQUESTION))
+ for (j = 0; hidden[j] != 0; j++)
+ Clist_ContactDoubleClicked(session_list_t[hidden[j] - 1]);
+ }
+ }
+
+ return 0;
+}
diff --git a/plugins/Sessions/Src/Main.cpp b/plugins/Sessions/Src/Main.cpp
index 8a5ca2565b..5692a6d442 100644
--- a/plugins/Sessions/Src/Main.cpp
+++ b/plugins/Sessions/Src/Main.cpp
@@ -23,10 +23,6 @@ HGENMENU hmSaveCurrentSession;
HANDLE hmTBButton[2], hiTBbutton[2], iTBbutton[2];
-bool g_hghostw;
-
-HWND hClistControl;
-
int g_ses_limit;
int g_ses_count;
bool g_bExclHidden;
@@ -36,12 +32,10 @@ bool g_bCrashRecovery;
bool g_bIncompletedSave;
HWND g_hDlg;
-HWND g_hSDlg;
bool DONT = false;
-bool StartUp, isLastTRUE = false, bSC = false;
+bool isLastTRUE = false;
MCONTACT session_list[255] = { 0 };
-MCONTACT user_session_list[255] = { 0 };
MCONTACT session_list_recovered[255];
CMPlugin g_plugin;
@@ -94,7 +88,7 @@ INT_PTR CALLBACK ExitDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM)
case IDOK:
SavePosition(hdlg, "ExitDlg");
SaveSessionDate();
- SaveSessionHandles(0, 0);
+ SaveSessionHandles(session_list, false);
g_plugin.setByte("lastempty", 0);
DestroyWindow(hdlg);
break;
@@ -121,463 +115,17 @@ INT_PTR CALLBACK ExitDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM)
return TRUE;
}
-INT_PTR CALLBACK SaveSessionDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
-{
- g_hSDlg = hdlg;
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hdlg);
- LoadSessionToCombobox(hdlg, 1, 5, "UserSessionDsc", 0);
-
- LoadPosition(hdlg, "SaveDlg");
- ShowWindow(hdlg, SW_SHOW);
- break;
-
- case WM_CLOSE:
- DestroyWindow(hdlg);
- g_hSDlg = nullptr;
- 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;
-
- 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_CLASSW, L"",
- WS_TABSTOP | WS_VISIBLE | WS_CHILD,
- x, y, dx, dy, hdlg, (HMENU)IDC_CLIST, g_plugin.getInst(), nullptr);
-
- 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, nullptr, rWnd.left, rWnd.top, x + dx, y + (dx / 3), SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE);
-
- SetWindowPos(hClistControl, nullptr, x - dd, dd, dx - dd, y + (dx / 12), SWP_NOZORDER/*|SWP_NOSIZE|SWP_SHOWWINDOW*/);
- SendMessage(hClistControl, CLM_AUTOREBUILD, 0, 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:
- wchar_t szUserSessionName[MAX_PATH];
- {
- DWORD session_list_temp[255] = { 0 };
- int i = 0, length = GetWindowTextLength(GetDlgItem(hdlg, IDC_LIST));
- SavePosition(hdlg, "SaveDlg");
- if (length > 0) {
- GetDlgItemText(hdlg, IDC_LIST, szUserSessionName, _countof(szUserSessionName));
- szUserSessionName[length + 1] = '\0';
- if (IsDlgButtonChecked(hdlg, IDC_SELCONTACTS) && bSC) {
- for (auto &hContact : Contacts()) {
- BYTE res = (BYTE)SendMessage(hClistControl, CLM_GETCHECKMARK, SendMessage(hClistControl, CLM_FINDCONTACT, hContact, 0), 0);
- if (res) {
- user_session_list[i] = 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 = nullptr;
- }
- else if (!SaveUserSessionName(szUserSessionName)) {
- SaveSessionHandles(0, 1);
-
- if (IsDlgButtonChecked(hdlg, IDC_SANDCCHECK))
- CloseCurrentSession(0, 0);
- DestroyWindow(hdlg);
- g_hSDlg = nullptr;
- }
- else MessageBox(nullptr, TranslateT("Current session is empty!"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
- }
- else MessageBox(nullptr, 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 = nullptr;
- }
- break;
-
- default:
- return FALSE;
- }
- return TRUE;
-}
-
-INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM)
-{
- static int ses_count;
-
- g_hDlg = hdlg;
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hdlg);
- {
- int iDelay = g_plugin.getWord("StartupModeDelay", 1500);
- if (g_hghostw == TRUE)
- SetTimer(hdlg, TIMERID_LOAD, iDelay, nullptr);
- else {
- if ((ses_count = LoadSessionToCombobox(hdlg, 0, g_ses_limit, "SessionDate", 0)) == g_ses_limit)
- EnableWindow(GetDlgItem(hdlg, IDC_SESSDEL), TRUE);
-
- if (LoadSessionToCombobox(hdlg, 0, 255, "UserSessionDsc", g_ses_limit) == 0 && ses_count != 0)
- ses_count = 0;
-
- if (session_list_recovered[0])
- ses_count = 256;
-
- SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
- LoadPosition(hdlg, "LoadDlg");
- if (StartUp)
- SetTimer(hdlg, TIMERID_SHOW, iDelay, nullptr);
- 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, g_bIncompletedSave ? 256 : 0);
- g_hghostw = StartUp = FALSE;
- DestroyWindow(hdlg);
- g_hDlg = nullptr;
- }
- break;
-
- case WM_CLOSE:
- SavePosition(hdlg, "LoadDlg");
- DestroyWindow(hdlg);
- g_hDlg = nullptr;
- 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;
-
- case IDC_SESSDEL:
- if (session_list_recovered[0] && ses_count == 256) {
- for (int i = 0; session_list_recovered[i]; i++)
- g_plugin.setByte(session_list_recovered[i], "wasInLastSession", 0);
-
- memset(session_list_recovered, 0, 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, g_ses_limit, "SessionDate", 0)) == g_ses_limit)
- EnableWindow(GetDlgItem(hdlg, IDC_SESSDEL), TRUE);
-
- if (LoadSessionToCombobox(hdlg, 1, 255, "UserSessionDsc", g_ses_limit) == 0 && ses_count != 0)
- ses_count = 0;
-
- SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
-
- }
- else if (ses_count >= g_ses_limit) {
- ses_count -= g_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, g_ses_limit, "SessionDate", 0)) == g_ses_limit)
- EnableWindow(GetDlgItem(hdlg, IDC_SESSDEL), TRUE);
-
- if (LoadSessionToCombobox(hdlg, 0, 255, "UserSessionDsc", g_ses_limit) == 0 && ses_count != 0)
- ses_count = 0;
-
- if (session_list_recovered[0])
- ses_count = 256;
-
- SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 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, g_ses_limit, "SessionDate", 0)) == g_ses_limit)
- EnableWindow(GetDlgItem(hdlg, IDC_SESSDEL), TRUE);
-
- if (LoadSessionToCombobox(hdlg, 0, 255, "UserSessionDsc", g_ses_limit) == 0 && ses_count != 0)
- ses_count = 0;
-
- if (session_list_recovered[0])
- ses_count = 256;
-
- SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 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 = nullptr;
- }
- break;
-
- case IDCANCEL:
- SavePosition(hdlg, "LoadDlg");
- DestroyWindow(hdlg);
- g_hDlg = nullptr;
- break;
- }
- break;
-
- default:
- return FALSE;
- }
- return TRUE;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
INT_PTR CloseCurrentSession(WPARAM, LPARAM)
{
while (session_list[0] != 0) {
- MessageWindowData mwd;
- Srmm_GetWindowData(session_list[0], mwd);
- SendMessage(mwd.hwndWindow, WM_CLOSE, 0, 0);
- }
- memset(session_list, 0, sizeof(session_list));
- return 0;
-}
-
-int SaveSessionHandles(WPARAM, LPARAM lparam)
-{
- if (session_list[0] == 0)
- return 1;
-
- int k = 0;
- for (auto &hContact : Contacts()) {
- if ((k = CheckForDuplicate(session_list, hContact)) != -1 && !(g_bExclHidden && !CheckContactVisibility(hContact))) {
- AddSessionMark(hContact, lparam, '1');
- AddInSessionOrder(hContact, lparam, k, 1);
- }
- else {
- AddSessionMark(hContact, lparam, '0');
- AddInSessionOrder(hContact, lparam, 0, 0);
- }
- }
- if (lparam == 1) {
- g_ses_count++;
- g_plugin.setByte("UserSessionsCount", (BYTE)g_ses_count);
- }
- return 0;
-}
-
-INT_PTR SaveUserSessionHandles(WPARAM, LPARAM)
-{
- if (g_hSDlg) {
- ShowWindow(g_hSDlg, SW_SHOW);
- return 1;
- }
-
- g_hSDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SAVEDIALOG), nullptr, SaveSessionDlgProc);
- return 0;
-}
-
-INT_PTR OpenSessionsManagerWindow(WPARAM, LPARAM)
-{
- if (g_hDlg) {
- ShowWindow(g_hDlg, SW_SHOW);
- return 0;
- }
-
- ptrW
- tszSession(g_plugin.getWStringA("SessionDate_0")),
- tszUserSession(g_plugin.getWStringA("UserSessionDsc_0"));
- if (g_bIncompletedSave || tszSession || tszUserSession) {
- g_hDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WLCMDIALOG), nullptr, LoadSessionDlgProc);
- return 0;
- }
- if (g_bOtherWarnings)
- MessageBox(nullptr, 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*/, nullptr, nullptr, nullptr, 0);
- wchar_t *szTimeBuf = (wchar_t*)mir_alloc((TimeSize + 1)*sizeof(wchar_t));
-
- GetTimeFormat(LOCALE_USER_DEFAULT, 0/*TIME_NOSECONDS*/, nullptr, nullptr, szTimeBuf, TimeSize);
-
- int DateSize = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, nullptr, nullptr, nullptr, 0);
- wchar_t *szDateBuf = (wchar_t*)mir_alloc((DateSize + 1)*sizeof(wchar_t));
-
- GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, nullptr, nullptr, szDateBuf, DateSize);
- int lenn = (DateSize + TimeSize + 5);
- wchar_t *szSessionTime = (wchar_t*)mir_alloc(lenn*sizeof(wchar_t));
- mir_snwprintf(szSessionTime, lenn, L"%s - %s", szTimeBuf, szDateBuf);
-
- char szSetting[256];
- mir_snprintf(szSetting, "%s_%d", "SessionDate", 0);
- wchar_t *ptszSaveSessionDate = g_plugin.getWStringA(szSetting);
-
- g_plugin.setWString(szSetting, szSessionTime);
- mir_free(szSessionTime);
-
- if (ptszSaveSessionDate)
- ResaveSettings("SessionDate", 1, g_ses_limit, ptszSaveSessionDate);
-
- if (szTimeBuf)
- mir_free(szTimeBuf);
- if (szDateBuf)
- mir_free(szDateBuf);
- }
- if (g_bCrashRecovery)
- g_plugin.setByte("lastSaveCompleted", 1);
- return 0;
-}
-
-int SaveUserSessionName(wchar_t *szUSessionName)
-{
- if (session_list[0] == 0)
- return 1;
-
- char szSetting[256];
- mir_snprintf(szSetting, "%s_%u", "UserSessionDsc", 0);
- wchar_t *ptszUserSessionName = g_plugin.getWStringA(szSetting);
- if (ptszUserSessionName)
- ResaveSettings("UserSessionDsc", 1, 255, ptszUserSessionName);
-
- g_plugin.setWString(szSetting, szUSessionName);
- return 0;
-}
-
-INT_PTR LoadLastSession(WPARAM wparam, LPARAM lparam)
-{
- if (isLastTRUE)
- return LoadSession(wparam, lparam);
- if (g_bOtherWarnings)
- MessageBox(nullptr, TranslateT("Last Sessions is empty"), TranslateT("Sessions Manager"), MB_OK);
- return 0;
-}
-
-int LoadSession(WPARAM, LPARAM lparam)
-{
- int dup = 0;
- int hidden[255] = { '0' };
- MCONTACT session_list_t[255] = { 0 };
- int mode = 0;
- if ((int)lparam >= g_ses_limit && lparam != 256) {
- mode = 1;
- lparam -= g_ses_limit;
- }
- if (session_list_recovered[0] && lparam == 256 && mode == 0)
- memcpy(session_list_t, session_list_recovered, sizeof(session_list_t));
- else
- for (auto &hContact : Contacts())
- if (LoadContactsFromMask(hContact, mode, lparam)) {
- int i = GetInSessionOrder(hContact, mode, lparam);
- session_list_t[i] = hContact;
- }
-
- int i = 0, j = 0;
- // TODO: change to "switch"
- while (session_list_t[i] != 0) {
- if (CheckForDuplicate(session_list, session_list_t[i]) == -1)
- Clist_ContactDoubleClicked(session_list_t[i]);
- else if (g_bWarnOnHidden) {
- if (!CheckContactVisibility(session_list_t[i])) {
- hidden[j] = i + 1;
- j++;
- }
- dup++;
- }
- i++;
- }
-
- if (i == 0) {
- if (g_bOtherWarnings)
- MessageBox(nullptr, TranslateT("No contacts to open"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
- return 1;
- }
-
- if (dup == i) {
- if (!hidden[i]) {
- if (g_bOtherWarnings)
- MessageBox(nullptr, TranslateT("This Session already opened"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
- return 1;
- }
- if (!g_bWarnOnHidden && g_bOtherWarnings) {
- MessageBox(nullptr, TranslateT("This Session already opened"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
- return 1;
- }
- if (g_bWarnOnHidden) {
- if (IDYES == MessageBox(nullptr, TranslateT("This Session already opened (but probably hidden).\nDo you want to show hidden contacts?"), TranslateT("Sessions Manager"), MB_YESNO | MB_ICONQUESTION))
- for (j = 0; hidden[j] != 0; j++)
- Clist_ContactDoubleClicked(session_list_t[hidden[j] - 1]);
- }
+ if (auto *pDlg = Srmm_FindDialog(session_list[0]))
+ pDlg->CloseTab();
+ SleepEx(50, TRUE);
}
+ memset(session_list, 0, sizeof(session_list));
return 0;
}
@@ -661,7 +209,7 @@ int OkToExit(WPARAM, LPARAM)
DONT = 1;
if (exitmode == 2 && session_list[0] != 0) {
SaveSessionDate();
- SaveSessionHandles(0, 0);
+ SaveSessionHandles(session_list, false);
g_plugin.setByte("lastempty", 0);
}
else if (exitmode == 1 && session_list[0] != 0) {
@@ -729,19 +277,6 @@ static int CreateButtons(WPARAM, LPARAM)
return 0;
}
-static void CALLBACK LaunchSessions()
-{
- int startup = g_plugin.getByte("StartupMode", 3);
- if (startup == 1 || (startup == 3 && isLastTRUE == TRUE)) {
- StartUp = TRUE;
- g_hDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WLCMDIALOG), nullptr, LoadSessionDlgProc);
- }
- else if (startup == 2 && isLastTRUE == TRUE) {
- g_hghostw = TRUE;
- g_hDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WLCMDIALOG), nullptr, LoadSessionDlgProc);
- }
-}
-
static int PluginInit(WPARAM, LPARAM)
{
HookEvent(ME_MSG_WINDOWEVENT, OnSrmmWindowEvent);
@@ -809,7 +344,7 @@ int CMPlugin::Load()
{
CreateServiceFunction(MS_SESSIONS_SHOWFAVORITESMENU, BuildFavMenu);
CreateServiceFunction(MS_SESSIONS_OPENMANAGER, OpenSessionsManagerWindow);
- CreateServiceFunction(MS_SESSIONS_RESTORELASTSESSION, LoadLastSession/*LoadSession*/);
+ CreateServiceFunction(MS_SESSIONS_RESTORELASTSESSION, LoadLastSession);
CreateServiceFunction(MS_SESSIONS_SAVEUSERSESSION, SaveUserSessionHandles);
CreateServiceFunction(MS_SESSIONS_CLOSESESSION, CloseCurrentSession);
diff --git a/plugins/Sessions/Src/Options.cpp b/plugins/Sessions/Src/Options.cpp
index 0467c50705..5cfd0c4f7b 100644
--- a/plugins/Sessions/Src/Options.cpp
+++ b/plugins/Sessions/Src/Options.cpp
@@ -429,48 +429,60 @@ public:
}
}
- void onChange_StartDialog(CCtrlCheck *)
+ void onChange_StartDialog(CCtrlCheck *pCheck)
{
+ if (!pCheck->IsChecked()) return;
+
EnableWindow(GetDlgItem(m_hwnd, IDC_STARTDELAY), TRUE);
EnableWindow(GetDlgItem(m_hwnd, IDC_STATICOP), TRUE);
EnableWindow(GetDlgItem(m_hwnd, IDC_STATICMS), TRUE);
chkLast.Enable();
}
- void onChange_LoadLast(CCtrlCheck *)
+ void onChange_LoadLast(CCtrlCheck *pCheck)
{
+ if (!pCheck->IsChecked()) return;
+
EnableWindow(GetDlgItem(m_hwnd, IDC_STARTDELAY), TRUE);
EnableWindow(GetDlgItem(m_hwnd, IDC_STATICOP), TRUE);
EnableWindow(GetDlgItem(m_hwnd, IDC_STATICMS), TRUE);
chkLast.Disable();
}
- void onChange_Nothing(CCtrlCheck *)
+ void onChange_Nothing(CCtrlCheck *pCheck)
{
+ if (!pCheck->IsChecked()) return;
+
EnableWindow(GetDlgItem(m_hwnd, IDC_STARTDELAY), FALSE);
EnableWindow(GetDlgItem(m_hwnd, IDC_STATICOP), FALSE);
EnableWindow(GetDlgItem(m_hwnd, IDC_STATICMS), FALSE);
chkLast.Disable();
}
- void onChange_ExSave(CCtrlCheck *)
+ void onChange_ExSave(CCtrlCheck *pCheck)
{
+ if (!pCheck->IsChecked()) return;
+
EnableWindow(GetDlgItem(m_hwnd, IDC_EXSTATIC1), TRUE);
EnableWindow(GetDlgItem(m_hwnd, IDC_EXSTATIC2), TRUE);
EnableWindow(GetDlgItem(m_hwnd, IDC_TRACK), TRUE);
EnableWindow(GetDlgItem(m_hwnd, IDC_SPIN1), TRUE);
}
- void onChange_ExNothing(CCtrlCheck *)
+ void onChange_ExNothing(CCtrlCheck *pCheck)
{
+ if (!pCheck->IsChecked()) return;
+
EnableWindow(GetDlgItem(m_hwnd, IDC_EXSTATIC1), FALSE);
EnableWindow(GetDlgItem(m_hwnd, IDC_EXSTATIC2), FALSE);
EnableWindow(GetDlgItem(m_hwnd, IDC_TRACK), FALSE);
EnableWindow(GetDlgItem(m_hwnd, IDC_SPIN1), FALSE);
}
- void onChange_ExAsk(CCtrlCheck *)
+ void onChange_ExAsk(CCtrlCheck *pCheck)
{
+ if (!pCheck->IsChecked()) return;
+
EnableWindow(GetDlgItem(m_hwnd, IDC_EXSTATIC1), TRUE);
EnableWindow(GetDlgItem(m_hwnd, IDC_EXSTATIC2), TRUE);
EnableWindow(GetDlgItem(m_hwnd, IDC_TRACK), TRUE);
diff --git a/plugins/Sessions/Src/SaveSessions.cpp b/plugins/Sessions/Src/SaveSessions.cpp
new file mode 100644
index 0000000000..b715cfd502
--- /dev/null
+++ b/plugins/Sessions/Src/SaveSessions.cpp
@@ -0,0 +1,237 @@
+/*
+Copyright (C) 2012-21 Miranda NG team (https://miranda-ng.org)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation version 2
+of the License.
+
+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 <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h"
+
+HWND g_hSDlg;
+
+bool bSC = false;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+int SaveSessionDate()
+{
+ if (session_list[0] != 0) {
+ int TimeSize = GetTimeFormat(LOCALE_USER_DEFAULT, 0/*TIME_NOSECONDS*/, nullptr, nullptr, nullptr, 0);
+ wchar_t *szTimeBuf = (wchar_t*)mir_alloc((TimeSize + 1)*sizeof(wchar_t));
+
+ GetTimeFormat(LOCALE_USER_DEFAULT, 0/*TIME_NOSECONDS*/, nullptr, nullptr, szTimeBuf, TimeSize);
+
+ int DateSize = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, nullptr, nullptr, nullptr, 0);
+ wchar_t *szDateBuf = (wchar_t*)mir_alloc((DateSize + 1)*sizeof(wchar_t));
+
+ GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, nullptr, nullptr, szDateBuf, DateSize);
+ int lenn = (DateSize + TimeSize + 5);
+ wchar_t *szSessionTime = (wchar_t*)mir_alloc(lenn*sizeof(wchar_t));
+ mir_snwprintf(szSessionTime, lenn, L"%s - %s", szTimeBuf, szDateBuf);
+
+ char szSetting[256];
+ mir_snprintf(szSetting, "%s_%d", "SessionDate", 0);
+ wchar_t *ptszSaveSessionDate = g_plugin.getWStringA(szSetting);
+
+ g_plugin.setWString(szSetting, szSessionTime);
+ mir_free(szSessionTime);
+
+ if (ptszSaveSessionDate)
+ ResaveSettings("SessionDate", 1, g_ses_limit, ptszSaveSessionDate);
+
+ if (szTimeBuf)
+ mir_free(szTimeBuf);
+ if (szDateBuf)
+ mir_free(szDateBuf);
+ }
+
+ if (g_bCrashRecovery)
+ g_plugin.setByte("lastSaveCompleted", 1);
+ return 0;
+}
+
+static int SaveUserSessionName(MCONTACT *pSession, wchar_t *szUSessionName)
+{
+ if (pSession[0] == 0)
+ return 1;
+
+ char szSetting[256];
+ mir_snprintf(szSetting, "%s_%u", "UserSessionDsc", 0);
+ wchar_t *ptszUserSessionName = g_plugin.getWStringA(szSetting);
+ if (ptszUserSessionName)
+ ResaveSettings("UserSessionDsc", 1, 255, ptszUserSessionName);
+
+ g_plugin.setWString(szSetting, szUSessionName);
+ return 0;
+}
+
+int SaveSessionHandles(MCONTACT *pSession, bool bNewSession)
+{
+ if (pSession[0] == 0)
+ return 1;
+
+ int k = 0;
+ for (auto &hContact : Contacts()) {
+ if ((k = CheckForDuplicate(pSession, hContact)) != -1 && !(g_bExclHidden && !CheckContactVisibility(hContact))) {
+ AddSessionMark(hContact, bNewSession, '1');
+ AddInSessionOrder(hContact, bNewSession, k, 1);
+ }
+ else {
+ AddSessionMark(hContact, bNewSession, '0');
+ AddInSessionOrder(hContact, bNewSession, 0, 0);
+ }
+ }
+ if (bNewSession) {
+ g_ses_count++;
+ g_plugin.setByte("UserSessionsCount", (BYTE)g_ses_count);
+ }
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Save session dialog
+
+class CSessionDlg : public CDlgBase
+{
+ CCtrlClc m_clist;
+ CCtrlCombo m_sessions;
+ CCtrlCheck chkSelContacts, chkSaveAndClose;
+
+ MCONTACT user_session_list[255];
+
+public:
+ CSessionDlg() :
+ CDlgBase(g_plugin, IDD_SAVEDIALOG),
+ m_clist(this, IDC_CLIST),
+ m_sessions(this, IDC_LIST),
+ chkSelContacts(this, IDC_SELCONTACTS),
+ chkSaveAndClose(this, IDC_SANDCCHECK)
+ {
+ memset(user_session_list, 0, sizeof(user_session_list));
+
+ chkSelContacts.OnChange = Callback(this, &CSessionDlg::onChange_SelContacts);
+
+ m_clist.OnCheckChanged = Callback(this, &CSessionDlg::onCheckChanged_Clist);
+ }
+
+ bool OnInitDialog() override
+ {
+ g_hSDlg = m_hwnd;
+ LoadSessionToCombobox(m_hwnd, 1, 5, "UserSessionDsc", 0);
+
+ SetWindowLongPtr(m_clist.GetHwnd(), GWL_STYLE,
+ GetWindowLongPtr(m_clist.GetHwnd(), GWL_STYLE) | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE | CLS_GROUPCHECKBOXES);
+ m_clist.SetExStyle(CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT);
+ m_clist.AutoRebuild();
+
+ LoadPosition(m_hwnd, "SaveDlg");
+ return true;
+ }
+
+ bool OnApply() override
+ {
+ wchar_t szUserSessionName[MAX_PATH];
+ m_sessions.GetText(szUserSessionName, _countof(szUserSessionName));
+ if (szUserSessionName[0] == 0) {
+ MessageBox(nullptr, TranslateT("Session name is empty, enter the name and try again"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
+ return false;
+ }
+
+ if (chkSelContacts.IsChecked() && bSC) {
+ int i = 0;
+ for (auto &hContact : Contacts()) {
+ BYTE res = m_clist.GetCheck(m_clist.FindContact(hContact));
+ if (res) {
+ user_session_list[i] = hContact;
+ i++;
+ }
+ }
+
+ SaveSessionHandles(user_session_list, true);
+ SaveUserSessionName(user_session_list, szUserSessionName);
+ return true;
+ }
+
+ if (!SaveUserSessionName(session_list, szUserSessionName)) {
+ SaveSessionHandles(session_list, true);
+
+ if (chkSaveAndClose.IsChecked())
+ CloseCurrentSession(0, 0);
+ return true;
+ }
+
+ MessageBox(nullptr, TranslateT("Current session is empty!"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
+ return false;
+ }
+
+ void OnDestroy() override
+ {
+ SavePosition(m_hwnd, "SaveDlg");
+ g_hSDlg = nullptr;
+ }
+
+ void onCheckChanged_Clist(CCtrlClc*)
+ {
+ bSC = TRUE;
+ memcpy(user_session_list, session_list, sizeof(user_session_list));
+ }
+
+ void onChange_SelContacts(CCtrlCheck *)
+ {
+ if (!m_bInitialized)
+ return;
+
+ RECT rWnd;
+ GetWindowRect(m_hwnd, &rWnd);
+
+ int x = rWnd.right - rWnd.left, y = rWnd.bottom - rWnd.top, dy, dx, dd;
+
+ if (chkSelContacts.IsChecked()) {
+ chkSaveAndClose.Disable();
+ dy = 20;
+ dx = 150;
+ dd = 5;
+ m_clist.Show();
+ }
+ else {
+ chkSaveAndClose.Enable();
+ dy = -20;
+ dx = -150;
+ dd = 5;
+ m_clist.Hide();
+ }
+
+ SetWindowPos(m_hwnd, nullptr, rWnd.left, rWnd.top, x + dx, y + (dx / 3), SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE);
+ SetWindowPos(m_clist.GetHwnd(), nullptr, x - dd, dd, dx - dd, y + (dx / 12), SWP_NOZORDER);
+
+ for (int i = 0; session_list[i] > 0; i++)
+ m_clist.SetCheck(m_clist.FindContact(session_list[i]), 1);
+
+ OffsetWindow(m_hwnd, GetDlgItem(m_hwnd, IDC_LIST), 0, dy);
+ OffsetWindow(m_hwnd, GetDlgItem(m_hwnd, IDC_STATIC), 0, dy);
+ OffsetWindow(m_hwnd, GetDlgItem(m_hwnd, IDC_SANDCCHECK), 0, dy);
+ OffsetWindow(m_hwnd, GetDlgItem(m_hwnd, IDOK), 0, dy);
+ OffsetWindow(m_hwnd, GetDlgItem(m_hwnd, IDCANCEL), 0, dy);
+ }
+};
+
+INT_PTR SaveUserSessionHandles(WPARAM, LPARAM)
+{
+ if (g_hSDlg) {
+ ShowWindow(g_hSDlg, SW_SHOW);
+ return 1;
+ }
+
+ (new CSessionDlg())->Show();
+ return 0;
+}
diff --git a/plugins/Sessions/Src/stdafx.h b/plugins/Sessions/Src/stdafx.h
index 41cfa7aa1b..8444734075 100644
--- a/plugins/Sessions/Src/stdafx.h
+++ b/plugins/Sessions/Src/stdafx.h
@@ -27,16 +27,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <malloc.h>
#include <newpluginapi.h>
-#include <m_contacts.h>
-#include <m_options.h>
#include <m_clc.h>
-#include <m_utils.h>
-#include <m_langpack.h>
-#include <m_metacontacts.h>
-#include <m_icolib.h>
-#include <m_message.h>
#include <m_clistint.h>
+#include <m_contacts.h>
#include <m_hotkeys.h>
+#include <m_icolib.h>
+#include <m_langpack.h>
+#include <m_message.h>
+#include <m_metacontacts.h>
+#include <m_options.h>
+#include <m_srmm_int.h>
+#include <m_utils.h>
#include <m_toptoolbar.h>
#include <m_sessions.h>
@@ -61,16 +62,23 @@ extern IconItem iconList[];
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(wchar_t*);
-INT_PTR CloseCurrentSession(WPARAM, LPARAM);
+int SaveSessionHandles(MCONTACT *pSession, bool bNewSession);
int SaveSessionDate();
+void CALLBACK LaunchSessions();
+
+INT_PTR CloseCurrentSession(WPARAM, LPARAM);
+INT_PTR LoadLastSession(WPARAM wparam, LPARAM lparam);
+INT_PTR OpenSessionsManagerWindow(WPARAM, LPARAM);
+INT_PTR SaveUserSessionHandles(WPARAM, LPARAM);
+
extern MCONTACT session_list_recovered[255];
extern MCONTACT session_list[255];
+
+extern HWND g_hDlg, g_hSDlg;
extern int g_ses_limit;
extern int g_ses_count;
+extern bool isLastTRUE;
extern bool g_bExclHidden;
extern bool g_bWarnOnHidden;
extern bool g_bOtherWarnings;
diff --git a/plugins/Sessions/res/Sessions.rc b/plugins/Sessions/res/Sessions.rc
index bf5fc4cae0..199996ab26 100644
--- a/plugins/Sessions/res/Sessions.rc
+++ b/plugins/Sessions/res/Sessions.rc
@@ -67,7 +67,7 @@ BEGIN
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
- CONTROL "",IDC_EMCLIST,"CListControl",NOT WS_VISIBLE | WS_TABSTOP,9,122,107,100
+ CONTROL "",IDC_EMCLIST,"CListControl",NOT WS_VISIBLE | WS_TABSTOP | WS_CHILD,9,122,107,100
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
@@ -109,6 +109,7 @@ BEGIN
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 "",IDC_CLIST,"CListControl",NOT WS_VISIBLE | WS_TABSTOP | WS_CHILD,12,30,148,65
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