diff options
-rw-r--r-- | plugins/Sessions/Src/LoadSessions.cpp | 19 | ||||
-rw-r--r-- | plugins/Sessions/Src/Main.cpp | 12 | ||||
-rw-r--r-- | plugins/Sessions/Src/Options.cpp | 50 | ||||
-rw-r--r-- | plugins/Sessions/Src/SaveSessions.cpp | 2 | ||||
-rw-r--r-- | plugins/Sessions/Src/stdafx.h | 10 | ||||
-rw-r--r-- | plugins/Sessions/res/Sessions.rc | 2 |
6 files changed, 47 insertions, 48 deletions
diff --git a/plugins/Sessions/Src/LoadSessions.cpp b/plugins/Sessions/Src/LoadSessions.cpp index 690ff664d2..fe5dc17d74 100644 --- a/plugins/Sessions/Src/LoadSessions.cpp +++ b/plugins/Sessions/Src/LoadSessions.cpp @@ -54,13 +54,12 @@ public: m_list.SetCurSel(0);
pSession = (CSession *)m_list.GetItemData(0);
- int iDelay = g_plugin.getWord("StartupModeDelay", 1500);
if (g_bDontShow == TRUE)
- timerLoad.Start(iDelay);
+ timerLoad.Start(g_plugin.iStartupDelay);
else {
LoadPosition(m_hwnd, "LoadDlg");
if (g_bStartup)
- timerShow.Start(iDelay);
+ timerShow.Start(g_plugin.iStartupDelay);
else
Show();
}
@@ -137,7 +136,7 @@ INT_PTR OpenSessionsManagerWindow(WPARAM, LPARAM) return 0;
}
- if (g_bOtherWarnings)
+ if (g_plugin.bOtherWarnings)
MessageBox(nullptr, TranslateT("No sessions to open"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
return 1;
}
@@ -163,7 +162,7 @@ INT_PTR LoadLastSession(WPARAM, LPARAM) if (g_bLastSessionPresent && cnt)
return LoadSession(&g_arDateSessions[cnt-1]);
- if (g_bOtherWarnings)
+ if (g_plugin.bOtherWarnings)
MessageBox(nullptr, TranslateT("Last Sessions is empty"), TranslateT("Sessions Manager"), MB_OK);
return 0;
}
@@ -190,7 +189,7 @@ int LoadSession(CSession *pSession) 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) {
+ else if (g_plugin.bWarnOnHidden) {
if (!CheckContactVisibility(session_list_t[i])) {
hidden[j] = i + 1;
j++;
@@ -201,22 +200,22 @@ int LoadSession(CSession *pSession) }
if (i == 0) {
- if (g_bOtherWarnings)
+ if (g_plugin.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)
+ if (g_plugin.bOtherWarnings)
MessageBox(nullptr, TranslateT("This Session already opened"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
return 1;
}
- if (!g_bWarnOnHidden && g_bOtherWarnings) {
+ if (!g_plugin.bWarnOnHidden && g_plugin.bOtherWarnings) {
MessageBox(nullptr, TranslateT("This Session already opened"), TranslateT("Sessions Manager"), MB_OK | MB_ICONWARNING);
return 1;
}
- if (g_bWarnOnHidden) {
+ if (g_plugin.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]);
diff --git a/plugins/Sessions/Src/Main.cpp b/plugins/Sessions/Src/Main.cpp index 9bf7a0e20e..4489df8646 100644 --- a/plugins/Sessions/Src/Main.cpp +++ b/plugins/Sessions/Src/Main.cpp @@ -25,7 +25,6 @@ OBJLIST<CSession> g_arUserSessions(1, NumericKeySortT), g_arDateSessions(1, Nume HANDLE hmTBButton[2], hiTBbutton[2], iTBbutton[2];
-int g_ses_limit;
int g_lastUserId, g_lastDateId;
bool g_bExclHidden;
@@ -64,7 +63,13 @@ PLUGININFOEX pluginInfoEx = CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx),
g_lastUserId(MODULENAME, "LastUserId", 0),
- g_lastDateId(MODULENAME, "LastDateId", 0)
+ g_lastDateId(MODULENAME, "LastDateId", 0),
+ bExclHidden(MODULENAME, "ExclHidden", false),
+ bWarnOnHidden(MODULENAME, "WarnOnHidden", false),
+ bOtherWarnings(MODULENAME, "OtherWarnings", true),
+ bCrashRecovery(MODULENAME, "CrashRecovery", false),
+ iTrackCount(MODULENAME, "TrackCount", 10),
+ iStartupDelay(MODULENAME, "StartupModeDelay", 1500)
{}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -116,7 +121,7 @@ static void SaveDateSession() mir_snprintf(szSetting, "%s_%d", "SessionDate", int(g_plugin.g_lastDateId));
g_plugin.setUString(szSetting, data.toString().c_str());
- while (g_arDateSessions.getCount() >= g_ses_limit) {
+ while (g_arDateSessions.getCount() >= g_plugin.iTrackCount) {
mir_snprintf(szSetting, "%s_%d", "SessionDate", g_arDateSessions[0].id);
g_plugin.delSetting(szSetting);
g_arDateSessions.remove(int(0));
@@ -389,7 +394,6 @@ int CMPlugin::Load() Miranda_WaitOnHandle(LaunchSessions);
// Settimgs
- g_ses_limit = g_plugin.getByte("TrackCount", 10);
g_bExclHidden = g_plugin.getByte("ExclHidden", 0) != 0;
g_bWarnOnHidden = g_plugin.getByte("WarnOnHidden", 0) != 0;
g_bOtherWarnings = g_plugin.getByte("OtherWarnings", 1) != 0;
diff --git a/plugins/Sessions/Src/Options.cpp b/plugins/Sessions/Src/Options.cpp index b2f7a8d492..2fcacc6b1e 100644 --- a/plugins/Sessions/Src/Options.cpp +++ b/plugins/Sessions/Src/Options.cpp @@ -137,6 +137,9 @@ class COptionsDlg : public CDlgBase CCtrlCombo m_list;
CCtrlListBox m_opclist;
+ CCtrlEdit edtDelay;
+ CCtrlSpin spinCount;
+ CCtrlCheck chkExclHidden, chkWarnOnHidden, chkOtherWarnings, chkCrashRecovery;
CCtrlCheck chkStartDialog, chkLoadLast, chkLast, chkNothing;
CCtrlCheck chkExitAsk, chkExitSave, chkExitNothing;
CCtrlButton btnSave, btnEdit, btnDel;
@@ -152,14 +155,28 @@ public: btnDel(this, IDC_DEL),
btnEdit(this, IDC_EDIT),
btnSave(this, IDC_SAVE),
+ edtDelay(this, IDC_STARTDELAY),
+ spinCount(this, IDC_SPIN1, 10, 1),
chkLast(this, IDC_CHECKLAST),
chkExitAsk(this, IDC_REXASK),
chkNothing(this, IDC_RNOTHING),
chkExitSave(this, IDC_REXSAVE),
chkLoadLast(this, IDC_RLOADLAST),
chkExitNothing(this, IDC_REXDSAVE),
- chkStartDialog(this, IDC_STARTDIALOG)
+ chkStartDialog(this, IDC_STARTDIALOG),
+ chkExclHidden(this, IDC_EXCLHIDDEN),
+ chkWarnOnHidden(this, IDC_LASTHIDDENWARN),
+ chkOtherWarnings(this, IDC_WARNINGS),
+ chkCrashRecovery(this, IDC_CRASHRECOVERY)
{
+ CreateLink(edtDelay, g_plugin.iStartupDelay);
+ CreateLink(spinCount, g_plugin.iTrackCount);
+
+ CreateLink(chkExclHidden, g_plugin.bExclHidden);
+ CreateLink(chkWarnOnHidden, g_plugin.bWarnOnHidden);
+ CreateLink(chkOtherWarnings, g_plugin.bOtherWarnings);
+ CreateLink(chkCrashRecovery, g_plugin.bCrashRecovery);
+
btnDel.OnClick = Callback(this, &COptionsDlg::onClick_Del);
btnEdit.OnClick = Callback(this, &COptionsDlg::onClick_Edit);
btnSave.OnClick = Callback(this, &COptionsDlg::onClick_Save);
@@ -194,25 +211,9 @@ public: m_clist.SetExStyle(CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT);
m_clist.AutoRebuild();
- SetDlgItemInt(m_hwnd, IDC_TRACK, g_ses_limit = g_plugin.getByte("TrackCount", 10), FALSE);
- SendDlgItemMessage(m_hwnd, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(10, 1));
- SendDlgItemMessage(m_hwnd, IDC_SPIN1, UDM_SETPOS, 0, GetDlgItemInt(m_hwnd, IDC_TRACK, nullptr, FALSE));
-
m_opclist.ResetContent();
- SetDlgItemInt(m_hwnd, IDC_STARTDELAY, g_plugin.getWord("StartupModeDelay", 1500), FALSE);
- int startupmode = g_plugin.getByte("StartupMode", 3);
- int exitmode = g_plugin.getByte("ShutdownMode", 2);
-
- g_bExclHidden = g_plugin.getByte("ExclHidden", 0) != 0;
- g_bWarnOnHidden = g_plugin.getByte("WarnOnHidden", 0) != 0;
- g_bOtherWarnings = g_plugin.getByte("OtherWarnings", 1) != 0;
- g_bCrashRecovery = g_plugin.getByte("CrashRecovery", 0) != 0;
-
- CheckDlgButton(m_hwnd, IDC_EXCLHIDDEN, g_bExclHidden ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(m_hwnd, IDC_LASTHIDDENWARN, g_bWarnOnHidden ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(m_hwnd, IDC_WARNINGS, g_bOtherWarnings ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(m_hwnd, IDC_CRASHRECOVERY, g_bCrashRecovery ? BST_CHECKED : BST_UNCHECKED);
+ int startupmode = g_plugin.getByte("StartupMode", 3);
if (startupmode == 1)
chkStartDialog.SetState(true);
else if (startupmode == 3)
@@ -222,6 +223,7 @@ public: else if (startupmode == 0)
chkNothing.SetState(true);
+ int exitmode = g_plugin.getByte("ShutdownMode", 2);
if (exitmode == 0)
chkExitNothing.SetState(true);
else if (exitmode == 1)
@@ -237,7 +239,10 @@ public: if (!LoadSessionContacts())
btnDel.Disable();
}
- else btnDel.Disable();
+ else {
+ m_list.Disable();
+ btnDel.Disable();
+ }
GetComboBoxInfo(m_list.GetHwnd(), &cbi);
mir_subclassWindow(cbi.hwndItem, ComboBoxSubclassProc);
@@ -253,7 +258,7 @@ public: {
int iDelay = GetDlgItemInt(m_hwnd, IDC_STARTDELAY, nullptr, FALSE);
g_plugin.setWord("StartupModeDelay", (uint16_t)iDelay);
- g_plugin.setByte("TrackCount", (uint8_t)(g_ses_limit = GetDlgItemInt(m_hwnd, IDC_TRACK, nullptr, FALSE)));
+
if (chkExitSave.IsChecked())
g_plugin.setByte("ShutdownMode", 2);
else if (IsDlgButtonChecked(m_hwnd, IDC_REXDSAVE))
@@ -269,11 +274,6 @@ public: g_plugin.setByte("StartupMode", 2);
else if (chkNothing.IsChecked())
g_plugin.setByte("StartupMode", 0);
-
- g_plugin.setByte("ExclHidden", (uint8_t)(IsDlgButtonChecked(m_hwnd, IDC_EXCLHIDDEN) ? (g_bExclHidden = 1) : (g_bExclHidden = 0)));
- g_plugin.setByte("WarnOnHidden", (uint8_t)(IsDlgButtonChecked(m_hwnd, IDC_LASTHIDDENWARN) ? (g_bWarnOnHidden = 1) : (g_bWarnOnHidden = 0)));
- g_plugin.setByte("OtherWarnings", (uint8_t)(IsDlgButtonChecked(m_hwnd, IDC_WARNINGS) ? (g_bOtherWarnings = 1) : (g_bOtherWarnings = 0)));
- g_plugin.setByte("CrashRecovery", (uint8_t)(IsDlgButtonChecked(m_hwnd, IDC_CRASHRECOVERY) ? (g_bCrashRecovery = 1) : (g_bCrashRecovery = 0)));
return true;
}
diff --git a/plugins/Sessions/Src/SaveSessions.cpp b/plugins/Sessions/Src/SaveSessions.cpp index c9792d8ee2..3356c44df5 100644 --- a/plugins/Sessions/Src/SaveSessions.cpp +++ b/plugins/Sessions/Src/SaveSessions.cpp @@ -50,7 +50,7 @@ static int SaveUserSessionName(MCONTACT *contacts, wchar_t *szUSessionName) pSession->save();
- while (g_arUserSessions.getCount() > g_ses_limit) {
+ while (g_arUserSessions.getCount() > g_plugin.iTrackCount) {
g_arUserSessions[0].remove();
g_arUserSessions.remove(int(0));
}
diff --git a/plugins/Sessions/Src/stdafx.h b/plugins/Sessions/Src/stdafx.h index 7271cd5f9e..d229bc3cca 100644 --- a/plugins/Sessions/Src/stdafx.h +++ b/plugins/Sessions/Src/stdafx.h @@ -53,6 +53,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. struct CMPlugin : public PLUGIN<CMPlugin>
{
CMOption<int> g_lastUserId, g_lastDateId;
+ CMOption<bool> bExclHidden, bWarnOnHidden, bOtherWarnings, bCrashRecovery;
+ CMOption<uint16_t> iTrackCount, iStartupDelay;
CMPlugin();
@@ -83,12 +85,11 @@ extern OBJLIST<CSession> g_arUserSessions, g_arDateSessions; /////////////////////////////////////////////////////////////////////////////////////////
int LoadSession(CSession *pSession);
-int SaveSessionHandles(MCONTACT *pSession, bool bNewSession);
void CALLBACK LaunchSessions();
INT_PTR CloseCurrentSession(WPARAM, LPARAM);
-INT_PTR LoadLastSession(WPARAM wparam, LPARAM lparam);
+INT_PTR LoadLastSession(WPARAM, LPARAM);
INT_PTR OpenSessionsManagerWindow(WPARAM, LPARAM);
INT_PTR SaveUserSessionHandles(WPARAM, LPARAM);
@@ -96,12 +97,7 @@ extern MCONTACT session_list_recovered[255]; extern MCONTACT session_list[255];
extern HWND g_hDlg, g_hSDlg;
-extern int g_ses_limit;
extern bool g_bLastSessionPresent;
-extern bool g_bExclHidden;
-extern bool g_bWarnOnHidden;
-extern bool g_bOtherWarnings;
-extern bool g_bCrashRecovery;
extern bool g_bIncompletedSave;
#define TIMERID_SHOW 11
diff --git a/plugins/Sessions/res/Sessions.rc b/plugins/Sessions/res/Sessions.rc index ccb6d1693b..707e4b7c52 100644 --- a/plugins/Sessions/res/Sessions.rc +++ b/plugins/Sessions/res/Sessions.rc @@ -74,7 +74,7 @@ BEGIN 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
+ EDITTEXT IDC_TRACK,224,70,27,12,ES_AUTOHSCROLL | ES_NUMBER
CONTROL "",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_TABSTOP,246,69,10,14
LTEXT "Save only last",IDC_EXSTATIC1,173,72,48,8
LTEXT "sessions",IDC_EXSTATIC2,253,72,28,8
|