diff options
author | George Hazan <george.hazan@gmail.com> | 2016-06-09 15:55:11 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-06-09 15:55:11 +0000 |
commit | c3da3167feb57fabd16cf5b0da116c4da5ec061c (patch) | |
tree | 558952088f9fbfd2c358c20e450c21f45541fe81 /plugins/Sessions | |
parent | c9efa92db9841b30e756a826d57c4ff7d28fc013 (diff) |
fix for automated session restoration
git-svn-id: http://svn.miranda-ng.org/main/trunk@16946 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Sessions')
-rw-r--r-- | plugins/Sessions/Src/Main.cpp | 35 | ||||
-rw-r--r-- | plugins/Sessions/Src/Options.cpp | 174 | ||||
-rw-r--r-- | plugins/Sessions/Src/Version.h | 2 |
3 files changed, 103 insertions, 108 deletions
diff --git a/plugins/Sessions/Src/Main.cpp b/plugins/Sessions/Src/Main.cpp index 765c791e05..fd71716171 100644 --- a/plugins/Sessions/Src/Main.cpp +++ b/plugins/Sessions/Src/Main.cpp @@ -100,7 +100,7 @@ INT_PTR CALLBACK ExitDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM) DestroyWindow(hdlg);
break;
}
- break;
+ break;
case WM_CLOSE:
DestroyWindow(hdlg);
@@ -289,7 +289,7 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM) }
else {
KillTimer(hdlg, TIMERID_LOAD);
- LoadSession(0, 0);
+ LoadSession(0, g_bIncompletedSave ? 256 : 0);
g_hghostw = StartUp = FALSE;
DestroyWindow(hdlg);
g_hDlg = 0;
@@ -346,7 +346,8 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM) if (LoadSessionToCombobox(hdlg, 0, 255, "UserSessionDsc", g_ses_limit) == 0 && ses_count != 0)
ses_count = 0;
- if (session_list_recovered[0]) ses_count = 256;
+ if (session_list_recovered[0])
+ ses_count = 256;
SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
}
@@ -360,7 +361,8 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM) if (LoadSessionToCombobox(hdlg, 0, 255, "UserSessionDsc", g_ses_limit) == 0 && ses_count != 0)
ses_count = 0;
- if (session_list_recovered[0]) ses_count = 256;
+ if (session_list_recovered[0])
+ ses_count = 256;
SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
}
@@ -536,7 +538,6 @@ int LoadSession(WPARAM, LPARAM lparam) {
int dup = 0;
int hidden[255] = { '0' };
- MCONTACT hContact;
MCONTACT session_list_t[255] = { 0 };
int mode = 0;
if ((int)lparam >= g_ses_limit && lparam != 256) {
@@ -546,14 +547,14 @@ int LoadSession(WPARAM, LPARAM lparam) if (session_list_recovered[0] && lparam == 256 && mode == 0)
memcpy(session_list_t, session_list_recovered, sizeof(session_list_t));
else
- for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
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"
+ // 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);
@@ -663,10 +664,6 @@ int SessionPreShutdown(WPARAM, LPARAM) if (g_hDlg) DestroyWindow(g_hDlg);
if (g_hSDlg) DestroyWindow(g_hSDlg);
- if (g_bIncompletedSave)
- for (int i = 0; session_list_recovered[i]; i++)
- db_set_b(session_list_recovered[i], MODNAME, "wasInLastSession", 0);
-
db_set_b(NULL, MODNAME, "lastSaveCompleted", 1);
return 0;
}
@@ -687,7 +684,7 @@ int OkToExit(WPARAM, LPARAM) return 0;
}
-static int GetContactHandle(WPARAM, LPARAM lParam)
+static int OnSrmmWindowEvent(WPARAM, LPARAM lParam)
{
MessageWindowEventData *MWeventdata = (MessageWindowEventData*)lParam;
if (MWeventdata->uType == MSG_WINDOW_EVT_OPEN) {
@@ -765,7 +762,7 @@ static INT_PTR LaunchSessions(WPARAM wParam, LPARAM) static int PluginInit(WPARAM, LPARAM)
{
- HookEvent(ME_MSG_WINDOWEVENT, GetContactHandle);
+ HookEvent(ME_MSG_WINDOWEVENT, OnSrmmWindowEvent);
HookEvent(ME_OPT_INITIALISE, OptionsInit);
HookEvent(ME_TTB_MODULELOADED, CreateButtons);
@@ -858,10 +855,8 @@ extern "C" __declspec(dllexport) int Load(void) CallService(MS_SYSTEM_WAITONHANDLE, (WPARAM)hEvent, (LPARAM)MS_SESSIONS_LAUNCHME);
}
- g_ses_count = db_get_b(0, MODNAME, "UserSessionsCount", 0);
- if (!g_ses_count)
- g_ses_count = db_get_b(0, "Sessions (Unicode)", "UserSessionsCount", 0);
- g_ses_limit = db_get_b(0, MODNAME, "TrackCount", 10);
+ g_ses_count = db_get_b(NULL, MODNAME, "UserSessionsCount", 0);
+ g_ses_limit = db_get_b(NULL, MODNAME, "TrackCount", 10);
g_bExclHidden = db_get_b(NULL, MODNAME, "ExclHidden", 0) != 0;
g_bWarnOnHidden = db_get_b(NULL, MODNAME, "WarnOnHidden", 0) != 0;
g_bOtherWarnings = db_get_b(NULL, MODNAME, "OtherWarnings", 1) != 0;
@@ -880,12 +875,12 @@ extern "C" __declspec(dllexport) int Load(void) }
if (!session_list_recovered[0])
- g_bIncompletedSave = FALSE;
+ g_bIncompletedSave = false;
db_set_b(NULL, MODNAME, "lastSaveCompleted", 0);
if (!db_get_b(NULL, MODNAME, "lastempty", 1) || g_bIncompletedSave)
- isLastTRUE = TRUE;
+ isLastTRUE = true;
HookEvent(ME_SYSTEM_MODULESLOADED, PluginInit);
HookEvent(ME_SYSTEM_OKTOEXIT, OkToExit);
diff --git a/plugins/Sessions/Src/Options.cpp b/plugins/Sessions/Src/Options.cpp index 4825450c9e..f9bd00bb8a 100644 --- a/plugins/Sessions/Src/Options.cpp +++ b/plugins/Sessions/Src/Options.cpp @@ -128,11 +128,11 @@ static LRESULT CALLBACK ComboBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, break;
case WM_NCCALCSIZE:
- {
- NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS*)lParam;
- ncsParam->rgrc[0].right -= 16;
- }
- break;
+ {
+ NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS*)lParam;
+ ncsParam->rgrc[0].right -= 16;
+ }
+ break;
case WM_NCHITTEST:
LRESULT lr = mir_callNextSubclass(hwnd, ComboBoxSubclassProc, msg, wParam, lParam);
@@ -160,7 +160,7 @@ static INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM l hIcon = (bChecked = IsMarkedUserDefSession(opses_count)) ? hMarked : hNotMarked;
- SetDlgItemInt(hdlg, IDC_TRACK, g_ses_limit = db_get_b(0, MODNAME, "TrackCount", 10), FALSE);
+ SetDlgItemInt(hdlg, IDC_TRACK, g_ses_limit = db_get_b(NULL, MODNAME, "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));
@@ -240,34 +240,34 @@ static INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM l case WM_NOTIFY:
switch (((LPNMHDR)lparam)->code) {
case PSN_APPLY:
- {
- int iDelay = GetDlgItemInt(hdlg, IDC_STARTDELAY, NULL, FALSE);
- db_set_w(0, MODNAME, "StartupModeDelay", (WORD)iDelay);
- db_set_b(0, MODNAME, "TrackCount", (BYTE)(g_ses_limit = GetDlgItemInt(hdlg, IDC_TRACK, NULL, FALSE)));
- if (IsDlgButtonChecked(hdlg, IDC_REXSAVE))
- db_set_b(NULL, MODNAME, "ShutdownMode", 2);
- else if (IsDlgButtonChecked(hdlg, IDC_REXDSAVE))
- db_set_b(NULL, MODNAME, "ShutdownMode", 0);
- else if (IsDlgButtonChecked(hdlg, IDC_REXASK))
- db_set_b(NULL, MODNAME, "ShutdownMode", 1);
-
- if (IsDlgButtonChecked(hdlg, IDC_STARTDIALOG)) {
- if (BST_UNCHECKED == IsDlgButtonChecked(hdlg, IDC_CHECKLAST))
- db_set_b(NULL, MODNAME, "StartupMode", 1);
- else
- db_set_b(NULL, MODNAME, "StartupMode", 3);
+ {
+ int iDelay = GetDlgItemInt(hdlg, IDC_STARTDELAY, NULL, FALSE);
+ db_set_w(0, MODNAME, "StartupModeDelay", (WORD)iDelay);
+ db_set_b(0, MODNAME, "TrackCount", (BYTE)(g_ses_limit = GetDlgItemInt(hdlg, IDC_TRACK, NULL, FALSE)));
+ if (IsDlgButtonChecked(hdlg, IDC_REXSAVE))
+ db_set_b(NULL, MODNAME, "ShutdownMode", 2);
+ else if (IsDlgButtonChecked(hdlg, IDC_REXDSAVE))
+ db_set_b(NULL, MODNAME, "ShutdownMode", 0);
+ else if (IsDlgButtonChecked(hdlg, IDC_REXASK))
+ db_set_b(NULL, MODNAME, "ShutdownMode", 1);
+
+ if (IsDlgButtonChecked(hdlg, IDC_STARTDIALOG)) {
+ if (BST_UNCHECKED == IsDlgButtonChecked(hdlg, IDC_CHECKLAST))
+ db_set_b(NULL, MODNAME, "StartupMode", 1);
+ else
+ db_set_b(NULL, MODNAME, "StartupMode", 3);
+ }
+ else if (IsDlgButtonChecked(hdlg, IDC_RLOADLAST))
+ db_set_b(NULL, MODNAME, "StartupMode", 2);
+ else if (IsDlgButtonChecked(hdlg, IDC_RNOTHING))
+ db_set_b(NULL, MODNAME, "StartupMode", 0);
+
+ db_set_b(NULL, MODNAME, "ExclHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_EXCLHIDDEN) ? (g_bExclHidden = 1) : (g_bExclHidden = 0)));
+ db_set_b(NULL, MODNAME, "WarnOnHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_LASTHIDDENWARN) ? (g_bWarnOnHidden = 1) : (g_bWarnOnHidden = 0)));
+ db_set_b(NULL, MODNAME, "OtherWarnings", (BYTE)(IsDlgButtonChecked(hdlg, IDC_WARNINGS) ? (g_bOtherWarnings = 1) : (g_bOtherWarnings = 0)));
+ db_set_b(NULL, MODNAME, "CrashRecovery", (BYTE)(IsDlgButtonChecked(hdlg, IDC_CRASHRECOVERY) ? (g_bCrashRecovery = 1) : (g_bCrashRecovery = 0)));
}
- else if (IsDlgButtonChecked(hdlg, IDC_RLOADLAST))
- db_set_b(NULL, MODNAME, "StartupMode", 2);
- else if (IsDlgButtonChecked(hdlg, IDC_RNOTHING))
- db_set_b(NULL, MODNAME, "StartupMode", 0);
-
- db_set_b(NULL, MODNAME, "ExclHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_EXCLHIDDEN) ? (g_bExclHidden = 1) : (g_bExclHidden = 0)));
- db_set_b(NULL, MODNAME, "WarnOnHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_LASTHIDDENWARN) ? (g_bWarnOnHidden = 1) : (g_bWarnOnHidden = 0)));
- db_set_b(NULL, MODNAME, "OtherWarnings", (BYTE)(IsDlgButtonChecked(hdlg, IDC_WARNINGS) ? (g_bOtherWarnings = 1) : (g_bOtherWarnings = 0)));
- db_set_b(NULL, MODNAME, "CrashRecovery", (BYTE)(IsDlgButtonChecked(hdlg, IDC_CRASHRECOVERY) ? (g_bCrashRecovery = 1) : (g_bCrashRecovery = 0)));
- }
- return 1;
+ return 1;
case CLN_CHECKCHANGED:
if (((LPNMHDR)lparam)->idFrom == IDC_EMCLIST) {
@@ -294,38 +294,38 @@ static INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM l 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 {
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- SendMessage(hOpClistControl, CLM_SETCHECKMARK, hContact, 0);
-
- for (int i = 0; session_list_t[i] > 0; i++) {
- MCONTACT hContact = (MCONTACT)SendMessage(hOpClistControl, CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
- SendMessage(hOpClistControl, CLM_SETCHECKMARK, hContact, 1);
+ {
+ 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 {
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ SendMessage(hOpClistControl, CLM_SETCHECKMARK, hContact, 0);
+
+ for (int i = 0; session_list_t[i] > 0; i++) {
+ MCONTACT hContact = (MCONTACT)SendMessage(hOpClistControl, CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
+ SendMessage(hOpClistControl, CLM_SETCHECKMARK, hContact, 1);
+ }
+ EnableWindow(GetDlgItem(hdlg, IDC_SAVE), FALSE);
}
- EnableWindow(GetDlgItem(hdlg, IDC_SAVE), FALSE);
}
}
}
- }
break;
case IDC_EDIT:
@@ -342,7 +342,7 @@ static INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM l 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, CLM_AUTOREBUILD, 0, 0);
-
+
for (int i = 0; session_list_t[i] > 0; i++) {
HANDLE hItem = (HANDLE)SendMessage(hOpClistControl, CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hItem, 1);
@@ -359,34 +359,34 @@ static INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM l break;
case IDC_SAVE:
- {
- int i = 0;
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- BYTE res = (BYTE)SendDlgItemMessage(hdlg, IDC_EMCLIST, CLM_GETCHECKMARK,
- SendDlgItemMessage(hdlg, IDC_EMCLIST, CLM_FINDCONTACT, 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);
+ {
+ int i = 0;
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ BYTE res = (BYTE)SendDlgItemMessage(hdlg, IDC_EMCLIST, CLM_GETCHECKMARK,
+ SendDlgItemMessage(hdlg, IDC_EMCLIST, CLM_FINDCONTACT, 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, _countof(szUserSessionName));
- RenameUserDefSession(opses_count, szUserSessionName);
- SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);
- LoadSessionToCombobox(hdlg, 1, 255, "UserSessionDsc", 0);
+ if (bSesssionNameChanged) {
+ if (GetWindowTextLength(hComboBoxEdit)) {
+ TCHAR szUserSessionName[MAX_PATH] = { '\0' };
+ GetWindowText(hComboBoxEdit, szUserSessionName, _countof(szUserSessionName));
+ RenameUserDefSession(opses_count, szUserSessionName);
+ SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);
+ LoadSessionToCombobox(hdlg, 1, 255, "UserSessionDsc", 0);
+ }
+ bSesssionNameChanged = FALSE;
}
- bSesssionNameChanged = FALSE;
+ EnableWindow(GetDlgItem(hdlg, IDC_SAVE), FALSE);
}
- EnableWindow(GetDlgItem(hdlg, IDC_SAVE), FALSE);
- }
- break;
+ break;
case IDC_DEL:
DelUserDefSession(opses_count);
diff --git a/plugins/Sessions/Src/Version.h b/plugins/Sessions/Src/Version.h index 6664b4d8e9..b758f6cf53 100644 --- a/plugins/Sessions/Src/Version.h +++ b/plugins/Sessions/Src/Version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 3
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
|