diff options
Diffstat (limited to 'plugins/StatusManager/src/AdvancedAutoAway')
3 files changed, 18 insertions, 32 deletions
diff --git a/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp b/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp index f9b04fba79..ef10baf786 100644 --- a/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp +++ b/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp @@ -68,7 +68,7 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L break; } - settings = (AAMSGSETTING**)malloc(sizeof(AAMSGSETTING*)); + settings = (AAMSGSETTING**)mir_alloc(sizeof(AAMSGSETTING*)); count = 0; for (int i = 0; i < _countof(statusModeList); i++) { if (!(protoModeMsgFlags & Proto_Status2Flag(statusModeList[i]))) @@ -76,13 +76,13 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L int j = SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(statusModeList[i], 0)); SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETITEMDATA, j, statusModeList[i]); - settings = (AAMSGSETTING**)realloc(settings, (count + 1) * sizeof(AAMSGSETTING*)); - settings[count] = (AAMSGSETTING*)malloc(sizeof(AAMSGSETTING)); + settings = (AAMSGSETTING**)mir_realloc(settings, (count + 1) * sizeof(AAMSGSETTING*)); + settings[count] = (AAMSGSETTING*)mir_alloc(sizeof(AAMSGSETTING)); settings[count]->status = statusModeList[i]; DBVARIANT dbv; if (!db_get(0, AAAMODULENAME, StatusModeToDbSetting(statusModeList[i], SETTING_STATUSMSG), &dbv)) { - settings[count]->msg = (char*)malloc(mir_strlen(dbv.pszVal) + 1); + settings[count]->msg = (char*)mir_alloc(mir_strlen(dbv.pszVal) + 1); mir_strcpy(settings[count]->msg, dbv.pszVal); db_free(&dbv); } @@ -121,9 +121,9 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L int len = SendDlgItemMessage(hwndDlg, IDC_STATUSMSG, WM_GETTEXTLENGTH, 0, 0); if (last != -1) { if (settings[last]->msg == nullptr) - settings[last]->msg = (char*)malloc(len + 1); + settings[last]->msg = (char*)mir_alloc(len + 1); else - settings[last]->msg = (char*)realloc(settings[last]->msg, len + 1); + settings[last]->msg = (char*)mir_realloc(settings[last]->msg, len + 1); GetDlgItemTextA(hwndDlg, IDC_STATUSMSG, settings[last]->msg, (len + 1)); } @@ -173,10 +173,10 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L case WM_DESTROY: for (int i = 0; i < count; i++) { - free(settings[i]->msg); - free(settings[i]); + mir_free(settings[i]->msg); + mir_free(settings[i]); } - free(settings); + mir_free(settings); break; } diff --git a/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp b/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp index 9e979e1230..db1fc2fea2 100644 --- a/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp +++ b/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp @@ -119,12 +119,7 @@ static void SetDialogStatus(HWND hwndDlg, SMProto *sameSetting) ///////////////////////////////////////////////////////////////////////////////////////// // Rules dialog window procedure -int AAACompareSettings(const SMProto *p1, const SMProto *p2) -{ - return mir_strcmp(p1->m_szName, p2->m_szName); -} - -static TProtoSettings optionSettings(10, AAACompareSettings); +static TProtoSettings optionSettings; static INT_PTR CALLBACK DlgProcAutoAwayRulesOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -140,7 +135,7 @@ static INT_PTR CALLBACK DlgProcAutoAwayRulesOpts(HWND hwndDlg, UINT msg, WPARAM // copy the settings optionSettings = protoList; - sameSetting = (SMProto*)malloc(sizeof(SMProto)); + sameSetting = (SMProto*)mir_alloc(sizeof(SMProto)); LoadAutoAwaySetting(*sameSetting, SETTING_ALL); // fill list from currentProtoSettings @@ -348,7 +343,7 @@ static INT_PTR CALLBACK DlgProcAutoAwayRulesOpts(HWND hwndDlg, UINT msg, WPARAM case WM_DESTROY: optionSettings.destroy(); - free(sameSetting); + mir_free(sameSetting); break; } return FALSE; diff --git a/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp index b37830b90f..64eb4c3f30 100644 --- a/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp +++ b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp @@ -187,20 +187,15 @@ static int changeState(SMProto &setting, STATES newState) if (setting.curState != SET_ORGSTATUS && setting.curState != ACTIVE && setting.statusChanged) { /* change the awaymessage */ if (setting.m_szMsg != nullptr) { - free(setting.m_szMsg); + mir_free(setting.m_szMsg); setting.m_szMsg = nullptr; } - if (db_get_b(0, AAAMODULENAME, StatusModeToDbSetting(setting.m_status, SETTING_MSGCUSTOM), FALSE)) { - DBVARIANT dbv; - if (!db_get_ws(0, AAAMODULENAME, StatusModeToDbSetting(setting.m_status, SETTING_STATUSMSG), &dbv)) { - setting.m_szMsg = wcsdup(dbv.ptszVal); - db_free(&dbv); - } - } + if (db_get_b(0, AAAMODULENAME, StatusModeToDbSetting(setting.m_status, SETTING_MSGCUSTOM), FALSE)) + setting.m_szMsg = db_get_wsa(0, AAAMODULENAME, StatusModeToDbSetting(setting.m_status, SETTING_STATUSMSG)); } else if (setting.m_szMsg != nullptr) { - free(setting.m_szMsg); + mir_free(setting.m_szMsg); setting.m_szMsg = nullptr; } @@ -324,14 +319,10 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD) } if (confirm || statusChanged) { - TProtoSettings ps = protoList; - for (int i = 0; i < ps.getCount(); i++) { - if (ps[i].m_szMsg) - ps[i].m_szMsg = wcsdup(ps[i].m_szMsg); - + TProtoSettings ps(protoList); + for (int i = 0; i < ps.getCount(); i++) if (ps[i].m_status == ID_STATUS_DISABLED) ps[i].m_szName = ""; - } if (confirm) confirmDialog = ShowConfirmDialogEx(&ps, db_get_w(0, AAAMODULENAME, SETTING_CONFIRMDELAY, 5)); |