summaryrefslogtreecommitdiff
path: root/plugins/StatusManager
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-02-02 13:50:02 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-02-02 13:50:02 +0300
commitcfca10ee7adbf42b70183aedfe5bd16f7b09b44f (patch)
tree21f300279611a628c7de2b7ad216cc4e13add204 /plugins/StatusManager
parenta7a6991d945a508d0f21ab34fd2f76ca15b95248 (diff)
fixes #1132 (KeepStatus doesn't work)
Diffstat (limited to 'plugins/StatusManager')
-rw-r--r--plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp4
-rw-r--r--plugins/StatusManager/src/StartupStatus/ss_options.cpp2
-rw-r--r--plugins/StatusManager/src/StartupStatus/ss_profiles.cpp47
-rw-r--r--plugins/StatusManager/src/StartupStatus/startupstatus.h7
4 files changed, 25 insertions, 35 deletions
diff --git a/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp
index 64eb4c3f30..6e63df6d32 100644
--- a/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp
+++ b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp
@@ -310,7 +310,7 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD)
/* SET_ORGSTATUS to ACTIVE */
aas.m_lastStatus = CallProtoService(aas.m_szName, PS_GETSTATUS, 0, 0);
aas.m_status = aas.originalStatusMode;
- confirm = (aas.optionFlags&FLAG_CONFIRM) ? TRUE : confirm;
+ confirm = (aas.optionFlags & FLAG_CONFIRM) ? TRUE : confirm;
aas.statusChanged = statusChanged = TRUE;
changeState(aas, ACTIVE);
aas.sts1setTimer = 0;
@@ -319,7 +319,7 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD)
}
if (confirm || statusChanged) {
- TProtoSettings ps(protoList);
+ TProtoSettings ps = protoList;
for (int i = 0; i < ps.getCount(); i++)
if (ps[i].m_status == ID_STATUS_DISABLED)
ps[i].m_szName = "";
diff --git a/plugins/StatusManager/src/StartupStatus/ss_options.cpp b/plugins/StatusManager/src/StartupStatus/ss_options.cpp
index 569aef54e2..338839197d 100644
--- a/plugins/StatusManager/src/StartupStatus/ss_options.cpp
+++ b/plugins/StatusManager/src/StartupStatus/ss_options.cpp
@@ -397,7 +397,7 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w
int defProfile = (int)SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_GETITEMDATA,
SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0), 0);
- TProtoSettings ps(protoList);
+ TProtoSettings ps = protoList;
GetProfile(defProfile, ps);
CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CMDLOPTIONS), hwndDlg, CmdlOptionsDlgProc, (LPARAM)&ps);
diff --git a/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp b/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp
index d8251c28f2..872139fc83 100644
--- a/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp
+++ b/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp
@@ -21,15 +21,20 @@
#define MAX_MMITEMS 6
-extern HINSTANCE hInst;
+struct PROFILECE
+{
+ int profile;
+ ptrA szProto;
+ ptrW msg;
+};
+
+static OBJLIST<PROFILECE> arProfiles(1);
+
extern int protoCount;
static int menuprofiles[MAX_MMITEMS];
static int mcount = 0;
-static PROFILECE *pce = nullptr;
-static int pceCount = 0;
-
static UINT_PTR releaseTtbTimerId = 0;
static HANDLE hTBModuleLoadedHook;
@@ -128,23 +133,21 @@ wchar_t* GetStatusMessage(int profile, const char *szProto)
char dbSetting[80];
mir_snprintf(dbSetting, "%d_%s_%s", profile, szProto, SETTING_PROFILE_STSMSG);
- for (int i = 0; i < pceCount; i++) {
- if ((pce[i].profile == profile) && (!mir_strcmp(pce[i].szProto, szProto))) {
- replaceStrW(pce[i].msg, db_get_wsa(0, SSMODULENAME, dbSetting));
- return pce[i].msg;
+ for (int i = 0; i < arProfiles.getCount(); i++) {
+ auto &p = arProfiles[i];
+ if (p.profile == profile && !mir_strcmp(p.szProto, szProto)) {
+ p.msg = db_get_wsa(0, SSMODULENAME, dbSetting);
+ return p.msg;
}
}
- pce = (PROFILECE*)mir_realloc(pce, (pceCount + 1)*sizeof(PROFILECE));
- if (pce == nullptr)
- return nullptr;
-
- pce[pceCount].profile = profile;
- pce[pceCount].szProto = _strdup(szProto);
- pce[pceCount].msg = db_get_wsa(0, SSMODULENAME, dbSetting);
- pceCount++;
+ PROFILECE *pce = new PROFILECE;
+ pce->profile = profile;
+ pce->szProto = mir_strdup(szProto);
+ pce->msg = db_get_wsa(0, SSMODULENAME, dbSetting);
+ arProfiles.insert(pce);
- return pce[pceCount - 1].msg;
+ return pce->msg;
}
void FillStatus(SMProto &ps, int profile)
@@ -195,7 +198,7 @@ INT_PTR LoadAndSetProfile(WPARAM iProfileNo, LPARAM)
{
// wParam == profile no.
int profile = (int)iProfileNo;
- TProtoSettings profileSettings(protoList);
+ TProtoSettings profileSettings = protoList;
if (!GetProfile(profile, profileSettings)) {
profile = (profile >= 0) ? profile : db_get_w(0, SSMODULENAME, SETTING_DEFAULTPROFILE, 0);
@@ -322,13 +325,7 @@ int InitProfileModule()
int DeinitProfilesModule()
{
- if (pce) {
- for (int i = 0; i < pceCount; i++)
- mir_free(pce[i].szProto);
- mir_free(pce);
- pce = nullptr;
- }
- pceCount = 0;
+ arProfiles.destroy();
UnregisterHotKeys();
RemoveTopToolbarButtons();
diff --git a/plugins/StatusManager/src/StartupStatus/startupstatus.h b/plugins/StatusManager/src/StartupStatus/startupstatus.h
index 47d6bd3d0e..5d16d50843 100644
--- a/plugins/StatusManager/src/StartupStatus/startupstatus.h
+++ b/plugins/StatusManager/src/StartupStatus/startupstatus.h
@@ -21,13 +21,6 @@
#define SSMODULENAME "StartupStatus"
-struct PROFILECE
-{
- int profile;
- char *szProto;
- wchar_t *msg;
-};
-
struct PROFILEOPTIONS : public MZeroedObject
{
__inline PROFILEOPTIONS() :