diff options
Diffstat (limited to 'plugins/SimpleStatusMsg')
-rw-r--r-- | plugins/SimpleStatusMsg/src/main.cpp | 354 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/src/msgbox.cpp | 967 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/src/options.cpp | 567 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/src/version.h | 2 |
4 files changed, 828 insertions, 1062 deletions
diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp index 92575882db..b2216a2846 100644 --- a/plugins/SimpleStatusMsg/src/main.cpp +++ b/plugins/SimpleStatusMsg/src/main.cpp @@ -88,7 +88,7 @@ void log2file(const char *fmt, ...) }
#endif
-static wchar_t *GetWinampSong(void)
+static wchar_t* GetWinampSong(void)
{
wchar_t *szTitle, *pstr, *res = nullptr;
HWND hwndWinamp = FindWindow(L"STUDIO", nullptr);
@@ -105,25 +105,21 @@ static wchar_t *GetWinampSong(void) if (szTitle == nullptr)
return nullptr;
- if (GetWindowText(hwndWinamp, szTitle, iTitleLen + 1) == 0)
- {
+ if (GetWindowText(hwndWinamp, szTitle, iTitleLen + 1) == 0) {
mir_free(szTitle);
return nullptr;
}
pstr = wcsstr(szTitle, L" - Winamp");
- if (pstr == nullptr)
- {
+ if (pstr == nullptr) {
mir_free(szTitle);
return nullptr;
}
- if (pstr < szTitle + (iTitleLen / 2))
- {
+ if (pstr < szTitle + (iTitleLen / 2)) {
memmove(szTitle, pstr + 9, mir_wstrlen(pstr + 9) * sizeof(wchar_t));
pstr = wcsstr(pstr + 1, L" - Winamp");
- if (pstr == nullptr)
- {
+ if (pstr == nullptr) {
mir_free(szTitle);
return nullptr;
}
@@ -131,8 +127,7 @@ static wchar_t *GetWinampSong(void) *pstr = 0;
pstr = wcschr(szTitle, '.');
- if (pstr == nullptr)
- {
+ if (pstr == nullptr) {
mir_free(szTitle);
return nullptr;
}
@@ -146,25 +141,22 @@ static wchar_t *GetWinampSong(void) wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int)
{
- int i, count = 0, len;
+ if (in == nullptr)
+ return nullptr;
+
+ int count = 0;
wchar_t substituteStr[1024], *msg = mir_wstrdup(in);
- for (i = 0; msg[i]; i++)
- {
- if (msg[i] == 0x0D && db_get_b(NULL, "SimpleStatusMsg", "RemoveCR", 0))
- {
+ for (int i = 0; msg[i]; i++) {
+ if (msg[i] == 0x0D && db_get_b(NULL, "SimpleStatusMsg", "RemoveCR", 0)) {
wchar_t *p = msg + i;
- if (i + 1 <= 1024 && msg[i + 1])
- {
- if (msg[i + 1] == 0x0A)
- {
- if (i + 2 <= 1024 && msg[i + 2])
- {
+ if (i + 1 <= 1024 && msg[i + 1]) {
+ if (msg[i + 1] == 0x0A) {
+ if (i + 2 <= 1024 && msg[i + 2]) {
count++;
memmove(p, p + 1, (mir_wstrlen(p) - 1) * sizeof(wchar_t));
}
- else
- {
+ else {
msg[i + 1] = 0;
msg[i] = 0x0A;
}
@@ -175,18 +167,15 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int) if (msg[i] != '%')
continue;
- if (!wcsnicmp(msg+i, L"%winampsong%", 12))
- {
+ if (!wcsnicmp(msg + i, L"%winampsong%", 12)) {
wchar_t *ptszWinampTitle = GetWinampSong();
- if (ptszWinampTitle != nullptr)
- {
+ if (ptszWinampTitle != nullptr) {
mir_free(g_ptszWinampSong);
g_ptszWinampSong = mir_wstrdup(ptszWinampTitle);
}
else if (g_ptszWinampSong && mir_wstrcmp(g_ptszWinampSong, L"SimpleStatusMsg")
- && db_get_b(NULL, "SimpleStatusMsg", "AmpLeaveTitle", 1))
- {
+ && db_get_b(NULL, "SimpleStatusMsg", "AmpLeaveTitle", 1)) {
ptszWinampTitle = mir_wstrdup(g_ptszWinampSong);
}
else
@@ -200,21 +189,17 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int) mir_free(ptszWinampTitle);
}
- else if (!wcsnicmp(msg + i, L"%time%", 6))
- {
+ else if (!wcsnicmp(msg + i, L"%time%", 6)) {
MIRANDA_IDLE_INFO mii;
Idle_GetInfo(mii);
- if (mii.idleType)
- {
+ if (mii.idleType) {
int mm;
SYSTEMTIME t;
GetLocalTime(&t);
- if ((mm = g_iIdleTime) == -1)
- {
+ if ((mm = g_iIdleTime) == -1) {
mm = t.wMinute + t.wHour * 60;
- if (mii.idleType == 1)
- {
+ if (mii.idleType == 1) {
mm -= mii.idleTime;
if (mm < 0) mm += 60 * 24;
}
@@ -232,8 +217,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int) memmove(msg + i + mir_wstrlen(substituteStr), msg + i + 6, (mir_wstrlen(msg) - i - 5) * sizeof(wchar_t));
memcpy(msg + i, substituteStr, mir_wstrlen(substituteStr) * sizeof(wchar_t));
}
- else if (!wcsnicmp(msg + i, L"%date%", 6))
- {
+ else if (!wcsnicmp(msg + i, L"%date%", 6)) {
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, nullptr, nullptr, substituteStr, _countof(substituteStr));
if (mir_wstrlen(substituteStr) > 6)
@@ -242,8 +226,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int) memmove(msg + i + mir_wstrlen(substituteStr), msg + i + 6, (mir_wstrlen(msg) - i - 5) * sizeof(wchar_t));
memcpy(msg + i, substituteStr, mir_wstrlen(substituteStr) * sizeof(wchar_t));
}
- else if (!wcsnicmp(msg+i, L"%rand(", 6))
- {
+ else if (!wcsnicmp(msg + i, L"%rand(", 6)) {
wchar_t *temp, *token;
int ran_from, ran_to, k;
@@ -253,8 +236,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int) token = wcstok(nullptr, L",)%%");
ran_to = _wtoi(token);
- if (ran_to > ran_from)
- {
+ if (ran_to > ran_from) {
mir_snwprintf(substituteStr, L"%d", GetRandom(ran_from, ran_to));
for (k = i + 1; msg[k]; k++) if (msg[k] == '%') { k++; break; }
@@ -266,8 +248,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int) }
mir_free(temp);
}
- else if (!wcsnicmp(msg+i, L"%randmsg%", 9))
- {
+ else if (!wcsnicmp(msg + i, L"%randmsg%", 9)) {
char buff[16];
int k, k2 = 0;
BOOL rmark[25];
@@ -276,8 +257,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int) int maxk = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10);
if (maxk == 0) rmark[0] = TRUE;
- while (!rmark[0])
- {
+ while (!rmark[0]) {
k = GetRandom(1, maxk);
if (rmark[k]) continue;
rmark[k] = TRUE;
@@ -296,8 +276,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int) if (!mir_wstrlen(substituteStr))
continue;
- if (wcsstr(substituteStr, L"%randmsg%") != nullptr || wcsstr(substituteStr, L"%randdefmsg%") != nullptr)
- {
+ if (wcsstr(substituteStr, L"%randmsg%") != nullptr || wcsstr(substituteStr, L"%randdefmsg%") != nullptr) {
if (k == maxk) maxk--;
}
else rmark[0] = TRUE;
@@ -311,8 +290,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int) memmove(msg + i + mir_wstrlen(substituteStr), msg + i + 9, (mir_wstrlen(msg) - i - 8) * sizeof(wchar_t));
memcpy(msg + i, substituteStr, mir_wstrlen(substituteStr) * sizeof(wchar_t));
}
- else if (!wcsnicmp(msg+i, L"%randdefmsg%", 12))
- {
+ else if (!wcsnicmp(msg + i, L"%randdefmsg%", 12)) {
char buff[16];
int k, k2 = 0;
BOOL rmark[25];
@@ -321,8 +299,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int) int maxk = db_get_w(NULL, "SimpleStatusMsg", "DefMsgCount", 0);
if (maxk == 0) rmark[0] = TRUE;
- while (!rmark[0])
- {
+ while (!rmark[0]) {
k = GetRandom(1, maxk);
if (rmark[k]) continue;
rmark[k] = TRUE;
@@ -341,8 +318,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int) if (!mir_wstrlen(substituteStr))
continue;
- if (wcsstr(substituteStr, L"%randmsg%") != nullptr || wcsstr(substituteStr, L"%randdefmsg%") != nullptr)
- {
+ if (wcsstr(substituteStr, L"%randmsg%") != nullptr || wcsstr(substituteStr, L"%randdefmsg%") != nullptr) {
if (k == maxk) maxk--;
}
else rmark[0] = TRUE;
@@ -351,22 +327,21 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int) if (k2 == maxk || k2 > maxk) mir_wstrcpy(substituteStr, L"");
if (mir_wstrlen(substituteStr) > 12)
- msg = (wchar_t *)mir_realloc(msg, (mir_wstrlen(msg)+1+mir_wstrlen(substituteStr)-12) * sizeof(wchar_t));
+ msg = (wchar_t *)mir_realloc(msg, (mir_wstrlen(msg) + 1 + mir_wstrlen(substituteStr) - 12) * sizeof(wchar_t));
memmove(msg + i + mir_wstrlen(substituteStr), msg + i + 12, (mir_wstrlen(msg) - i - 11) * sizeof(wchar_t));
memcpy(msg + i, substituteStr, mir_wstrlen(substituteStr) * sizeof(wchar_t));
}
}
- if (count) msg[mir_wstrlen(msg) - count] = 0;
+ if (count)
+ msg[mir_wstrlen(msg) - count] = 0;
- if (szProto)
- {
+ if (szProto) {
char szSetting[80];
mir_snprintf(szSetting, "Proto%sMaxLen", szProto);
- len = db_get_w(NULL, "SimpleStatusMsg", szSetting, 1024);
- if (len < mir_wstrlen(msg))
- {
+ size_t len = db_get_w(NULL, "SimpleStatusMsg", szSetting, 1024);
+ if (len < mir_wstrlen(msg)) {
msg = (wchar_t *)mir_realloc(msg, len * sizeof(wchar_t));
msg[len] = 0;
}
@@ -375,13 +350,11 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int) return msg;
}
-wchar_t *InsertVarsIntoMsg(wchar_t *tszMsg, const char *szProto, int iStatus, MCONTACT hContact)
+wchar_t* InsertVarsIntoMsg(wchar_t *tszMsg, const char *szProto, int iStatus, MCONTACT hContact)
{
- if (ServiceExists(MS_VARS_FORMATSTRING) && db_get_b(NULL, "SimpleStatusMsg", "EnableVariables", 1))
- {
+ if (ServiceExists(MS_VARS_FORMATSTRING) && db_get_b(NULL, "SimpleStatusMsg", "EnableVariables", 1)) {
wchar_t *tszVarsMsg = variables_parse(tszMsg, nullptr, hContact);
- if (tszVarsMsg != nullptr)
- {
+ if (tszVarsMsg != nullptr) {
wchar_t *format = InsertBuiltinVarsIntoMsg(tszVarsMsg, szProto, iStatus);
mir_free(tszVarsMsg);
return format;
@@ -391,7 +364,7 @@ wchar_t *InsertVarsIntoMsg(wchar_t *tszMsg, const char *szProto, int iStatus, MC return InsertBuiltinVarsIntoMsg(tszMsg, szProto, iStatus);
}
-static wchar_t *GetAwayMessageFormat(int iStatus, const char *szProto)
+static wchar_t* GetAwayMessageFormat(int iStatus, const char *szProto)
{
char szSetting[80];
wchar_t *format;
@@ -399,12 +372,10 @@ static wchar_t *GetAwayMessageFormat(int iStatus, const char *szProto) mir_snprintf(szSetting, "%sFlags", szProto ? szProto : "");
int flags = db_get_b(NULL, "SimpleStatusMsg", StatusModeToDbSetting(iStatus, szSetting), STATUS_DEFAULT);
- if (flags & STATUS_EMPTY_MSG)
- {
+ if (flags & STATUS_EMPTY_MSG) {
return mir_wstrdup(L"");
}
- else if (flags & STATUS_LAST_STATUS_MSG)
- {
+ else if (flags & STATUS_LAST_STATUS_MSG) {
if (szProto)
mir_snprintf(szSetting, "%sMsg", szProto);
else
@@ -412,8 +383,7 @@ static wchar_t *GetAwayMessageFormat(int iStatus, const char *szProto) format = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(iStatus, szSetting));
}
- else if (flags & STATUS_LAST_MSG)
- {
+ else if (flags & STATUS_LAST_MSG) {
if (szProto)
mir_snprintf(szSetting, "Last%sMsg", szProto);
else
@@ -426,8 +396,7 @@ static wchar_t *GetAwayMessageFormat(int iStatus, const char *szProto) format = db_get_wsa(NULL, "SimpleStatusMsg", szLastMsg);
mir_free(szLastMsg);
}
- else if (flags & STATUS_THIS_MSG)
- {
+ else if (flags & STATUS_THIS_MSG) {
if (szProto)
mir_snprintf(szSetting, "%sDefault", szProto);
else
@@ -455,10 +424,8 @@ void SaveMessageToDB(const char *szProto, wchar_t *tszMsg, BOOL bIsFormat) {
char szSetting[80];
- if (!szProto)
- {
- for (int i = 0; i < accounts->count; ++i)
- {
+ if (!szProto) {
+ for (int i = 0; i < accounts->count; ++i) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled())
continue;
@@ -479,8 +446,7 @@ void SaveMessageToDB(const char *szProto, wchar_t *tszMsg, BOOL bIsFormat) #endif
}
}
- else
- {
+ else {
if (!(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
return;
@@ -507,13 +473,11 @@ static wchar_t *GetAwayMessage(int iStatus, const char *szProto, BOOL bInsertVar wchar_t *format;
char szSetting[80];
- if ((!iStatus || iStatus == ID_STATUS_CURRENT) && szProto)
- {
+ if ((!iStatus || iStatus == ID_STATUS_CURRENT) && szProto) {
mir_snprintf(szSetting, "FCur%sMsg", szProto);
format = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
}
- else
- {
+ else {
if (!iStatus || iStatus == ID_STATUS_CURRENT)
iStatus = GetCurrentStatus(szProto);
@@ -528,15 +492,13 @@ static wchar_t *GetAwayMessage(int iStatus, const char *szProto, BOOL bInsertVar // format = mir_wstrdup(L"");
//}
//else
- if (flags & PROTO_THIS_MSG)
- {
+ if (flags & PROTO_THIS_MSG) {
mir_snprintf(szSetting, "Proto%sDefault", szProto);
format = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
if (format == nullptr)
format = mir_wstrdup(L"");
}
- else if (flags & PROTO_NOCHANGE && szProto)
- {
+ else if (flags & PROTO_NOCHANGE && szProto) {
mir_snprintf(szSetting, "FCur%sMsg", szProto);
format = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
}
@@ -549,8 +511,7 @@ static wchar_t *GetAwayMessage(int iStatus, const char *szProto, BOOL bInsertVar log2file("GetAwayMessage(): %s has %s status and \"%S\" status message.", szProto, StatusModeToDbSetting(iStatus, ""), format);
#endif
- if (bInsertVars && format != nullptr)
- {
+ if (bInsertVars && format != nullptr) {
wchar_t *tszVarsMsg = InsertVarsIntoMsg(format, szProto, iStatus, hContact); // TODO random values not the same!
mir_free(format);
return tszVarsMsg;
@@ -565,17 +526,15 @@ int CheckProtoSettings(const char *szProto, int iInitialStatus) if (iSetting != -1)
return iSetting ? iSetting : iInitialStatus;
iSetting = db_get_w(NULL, szProto, "OfflineMessageOption", -1); //TLEN settings
- if (iSetting != -1)
- {
- switch (iSetting)
- {
- case 1: return ID_STATUS_ONLINE;
- case 2: return ID_STATUS_AWAY;
- case 3: return ID_STATUS_NA;
- case 4: return ID_STATUS_DND;
- case 5: return ID_STATUS_FREECHAT;
- case 6: return ID_STATUS_INVISIBLE;
- default: return iInitialStatus;
+ if (iSetting != -1) {
+ switch (iSetting) {
+ case 1: return ID_STATUS_ONLINE;
+ case 2: return ID_STATUS_AWAY;
+ case 3: return ID_STATUS_NA;
+ case 4: return ID_STATUS_DND;
+ case 5: return ID_STATUS_FREECHAT;
+ case 6: return ID_STATUS_INVISIBLE;
+ default: return iInitialStatus;
}
}
return iInitialStatus;
@@ -589,11 +548,9 @@ static void Proto_SetAwayMsgT(const char *szProto, int iStatus, wchar_t *tszMsg) static void Proto_SetStatus(const char *szProto, int iInitialStatus, int iStatus, wchar_t *tszMsg)
{
- if (iStatus == ID_STATUS_OFFLINE && iStatus != iInitialStatus)
- {
+ if (iStatus == ID_STATUS_OFFLINE && iStatus != iInitialStatus) {
// ugly hack to set offline status message
- if (!(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_INDIVMODEMSG))
- {
+ if (!(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_INDIVMODEMSG)) {
int iMsgStatus = CheckProtoSettings(szProto, iInitialStatus);
CallProtoService(szProto, PS_SETAWAYMSG, (WPARAM)iMsgStatus, (LPARAM)tszMsg);
CallProtoService(szProto, PS_SETSTATUS, (WPARAM)iMsgStatus, 0);
@@ -615,19 +572,16 @@ int HasProtoStaticStatusMsg(const char *szProto, int iInitialStatus, int iStatus mir_snprintf(szSetting, "Proto%sFlags", szProto);
int flags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT);
- if (flags & PROTO_NO_MSG)
- {
+ if (flags & PROTO_NO_MSG) {
Proto_SetStatus(szProto, iInitialStatus, iStatus, nullptr);
SaveMessageToDB(szProto, nullptr, TRUE);
SaveMessageToDB(szProto, nullptr, FALSE);
return 1;
}
- else if (flags & PROTO_THIS_MSG)
- {
+ else if (flags & PROTO_THIS_MSG) {
mir_snprintf(szSetting, "Proto%sDefault", szProto);
wchar_t *szSimpleStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
- if (szSimpleStatusMsg != nullptr)
- {
+ if (szSimpleStatusMsg != nullptr) {
SaveMessageToDB(szProto, szSimpleStatusMsg, TRUE);
wchar_t *msg = InsertVarsIntoMsg(szSimpleStatusMsg, szProto, iStatus, NULL);
mir_free(szSimpleStatusMsg);
@@ -635,8 +589,7 @@ int HasProtoStaticStatusMsg(const char *szProto, int iInitialStatus, int iStatus SaveMessageToDB(szProto, msg, FALSE);
mir_free(msg);
}
- else
- {
+ else {
Proto_SetStatus(szProto, iInitialStatus, iStatus, L"");
SaveMessageToDB(szProto, L"", TRUE);
SaveMessageToDB(szProto, L"", FALSE);
@@ -653,13 +606,12 @@ INT_PTR SetStatusModeFromExtern(WPARAM wParam, LPARAM lParam) int newStatus = (int)wParam;
- for (int i = 0; i < accounts->count; ++i)
- {
+ for (int i = 0; i < accounts->count; ++i) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled())
continue;
- if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) &~ CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)))
+ if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) &~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)))
continue;
if (db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0))
@@ -668,16 +620,14 @@ INT_PTR SetStatusModeFromExtern(WPARAM wParam, LPARAM lParam) if (wParam == ID_STATUS_CURRENT || wParam == 0)
newStatus = GetCurrentStatus(pa->szModuleName);
- if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
- {
+ if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) {
CallProtoService(pa->szModuleName, PS_SETSTATUS, newStatus, 0);
continue;
}
int status_modes_msg = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
- if ((Proto_Status2Flag(newStatus) & status_modes_msg) || (newStatus == ID_STATUS_OFFLINE && (Proto_Status2Flag(ID_STATUS_INVISIBLE) & status_modes_msg)))
- {
+ if ((Proto_Status2Flag(newStatus) & status_modes_msg) || (newStatus == ID_STATUS_OFFLINE && (Proto_Status2Flag(ID_STATUS_INVISIBLE) & status_modes_msg))) {
wchar_t *msg = nullptr;
if (HasProtoStaticStatusMsg(pa->szModuleName, GetCurrentStatus(pa->szModuleName), newStatus))
@@ -706,13 +656,11 @@ void SetStatusMessage(const char *szProto, int iInitialStatus, int iStatus, wcha #ifdef _DEBUG
log2file("SetStatusMessage(\"%s\", %d, %d, \"%S\", %d)", szProto, iInitialStatus, iStatus, message, bOnStartup);
#endif
- if (szProto)
- {
+ if (szProto) {
if (bOnStartup && accounts->statusCount > 1) // TODO not only at startup?
{
int status;
- for (int i = 0; i < accounts->count; ++i)
- {
+ for (int i = 0; i < accounts->count; ++i) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled())
continue;
@@ -723,8 +671,7 @@ void SetStatusMessage(const char *szProto, int iInitialStatus, int iStatus, wcha status = iStatus == ID_STATUS_CURRENT ? GetStartupStatus(pa->szModuleName) : iStatus;
if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) ||
- !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
- {
+ !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) {
if (!(bOnStartup && status == ID_STATUS_OFFLINE) && GetCurrentStatus(pa->szModuleName) != status)
CallProtoService(pa->szModuleName, PS_SETSTATUS, (WPARAM)status, 0);
}
@@ -743,14 +690,12 @@ void SetStatusMessage(const char *szProto, int iInitialStatus, int iStatus, wcha Proto_SetStatus(szProto, iInitialStatus, iStatus, msg);
mir_free(msg);
}
- else
- {
+ else {
int iProfileStatus = iStatus > ID_STATUS_CURRENT ? iStatus : 0;
BOOL bIsStatusCurrent = iStatus == ID_STATUS_CURRENT;
BOOL bIsInitialStatusCurrent = iInitialStatus == ID_STATUS_CURRENT;
- for (int i = 0; i < accounts->count; ++i)
- {
+ for (int i = 0; i < accounts->count; ++i) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled())
continue;
@@ -761,8 +706,7 @@ void SetStatusMessage(const char *szProto, int iInitialStatus, int iStatus, wcha if (!bOnStartup && db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0))
continue;
- if (iProfileStatus)
- {
+ if (iProfileStatus) {
int iProfileNumber = iStatus - 40083;
char szSetting[128];
mir_snprintf(szSetting, "%d_%s", iProfileNumber, pa->szModuleName);
@@ -783,10 +727,8 @@ void SetStatusMessage(const char *szProto, int iInitialStatus, int iStatus, wcha iInitialStatus = bOnStartup ? ID_STATUS_OFFLINE : GetCurrentStatus(pa->szModuleName);
if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(iStatus)) ||
- !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
- {
- if (!(bOnStartup && iStatus == ID_STATUS_OFFLINE) && GetCurrentStatus(pa->szModuleName) != iStatus && iStatus != iInitialStatus)
- {
+ !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) {
+ if (!(bOnStartup && iStatus == ID_STATUS_OFFLINE) && GetCurrentStatus(pa->szModuleName) != iStatus && iStatus != iInitialStatus) {
CallProtoService(pa->szModuleName, PS_SETSTATUS, (WPARAM)iStatus, 0);
#ifdef _DEBUG
log2file("SetStatusMessage(): Set %s status for %s.", StatusModeToDbSetting(iStatus, ""), pa->szModuleName);
@@ -808,8 +750,7 @@ void SetStatusMessage(const char *szProto, int iInitialStatus, int iStatus, wcha mir_free(msg);
}
- if (GetCurrentStatus(nullptr) != iStatus && !bIsStatusCurrent && !iProfileStatus)
- {
+ if (GetCurrentStatus(nullptr) != iStatus && !bIsStatusCurrent && !iProfileStatus) {
// not so nice...
UnhookEvent(h_statusmodechange);
Clist_SetStatusMode(iStatus);
@@ -823,7 +764,8 @@ INT_PTR ShowStatusMessageDialogInternal(WPARAM, LPARAM lParam) struct MsgBoxInitData *box_data;
BOOL idvstatusmsg = FALSE;
- if (Miranda_IsTerminated()) return 0;
+ if (Miranda_IsTerminated())
+ return 0;
if (hTTBButton) {
CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTTBButton, (LPARAM)0);
@@ -832,10 +774,8 @@ INT_PTR ShowStatusMessageDialogInternal(WPARAM, LPARAM lParam) box_data = (struct MsgBoxInitData *)mir_alloc(sizeof(struct MsgBoxInitData));
- if (accounts->statusMsgCount == 1)
- {
- for (int i = 0; i < accounts->count; ++i)
- {
+ if (accounts->statusMsgCount == 1) {
+ for (int i = 0; i < accounts->count; ++i) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled())
continue;
@@ -852,10 +792,8 @@ INT_PTR ShowStatusMessageDialogInternal(WPARAM, LPARAM lParam) break;
}
}
- else
- {
- for (int i = 0; i < accounts->count; ++i)
- {
+ else {
+ for (int i = 0; i < accounts->count; ++i) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled())
continue;
@@ -869,8 +807,7 @@ INT_PTR ShowStatusMessageDialogInternal(WPARAM, LPARAM lParam) if (!pa->bIsVisible)
continue;
- if (hProtoStatusMenuItem[i] == (HANDLE)lParam)
- {
+ if (hProtoStatusMenuItem[i] == (HANDLE)lParam) {
box_data->m_szProto = pa->szModuleName;
box_data->m_iStatusModes = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0);
box_data->m_iStatusMsgModes = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
@@ -879,8 +816,7 @@ INT_PTR ShowStatusMessageDialogInternal(WPARAM, LPARAM lParam) break;
}
}
- if (!idvstatusmsg)
- {
+ if (!idvstatusmsg) {
box_data->m_szProto = nullptr;
box_data->m_iStatusModes = accounts->statusFlags;
box_data->m_iStatusMsgModes = accounts->statusMsgFlags;
@@ -905,8 +841,7 @@ INT_PTR ShowStatusMessageDialog(WPARAM, LPARAM lParam) box_data = (struct MsgBoxInitData *)mir_alloc(sizeof(struct MsgBoxInitData));
- for (int i = 0; i < accounts->count; ++i)
- {
+ for (int i = 0; i < accounts->count; ++i) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled())
continue;
@@ -920,8 +855,7 @@ INT_PTR ShowStatusMessageDialog(WPARAM, LPARAM lParam) if (!pa->bIsVisible)
continue;
- if (!mir_strcmp(pa->szModuleName, (char *)lParam))
- {
+ if (!mir_strcmp(pa->szModuleName, (char *)lParam)) {
box_data->m_szProto = pa->szModuleName;
box_data->m_iStatusModes = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0);
box_data->m_iStatusMsgModes = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
@@ -930,8 +864,7 @@ INT_PTR ShowStatusMessageDialog(WPARAM, LPARAM lParam) break;
}
}
- if (!idvstatusmsg)
- {
+ if (!idvstatusmsg) {
box_data->m_szProto = nullptr;
box_data->m_iStatusModes = accounts->statusFlags;
box_data->m_iStatusMsgModes = accounts->statusMsgFlags;
@@ -1096,7 +1029,7 @@ int ChangeStatusMessage(WPARAM wParam, LPARAM lParam) return 1;
}
- MsgBoxInitData *box_data = (MsgBoxInitData*)mir_alloc( sizeof(MsgBoxInitData));
+ MsgBoxInitData *box_data = (MsgBoxInitData*)mir_alloc(sizeof(MsgBoxInitData));
box_data->m_szProto = nullptr;
box_data->m_iStatus = iStatus;
box_data->m_iStatusModes = accounts->statusFlags;
@@ -1117,7 +1050,7 @@ static INT_PTR ChangeStatusMsg(WPARAM wParam, LPARAM lParam) return 0;
}
-static int ProcessProtoAck(WPARAM , LPARAM lParam)
+static int ProcessProtoAck(WPARAM, LPARAM lParam)
{
ACKDATA *ack = (ACKDATA *)lParam;
if (!ack || !ack->szModule)
@@ -1149,23 +1082,20 @@ int SetStartupStatus(int i) return -1;
if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) ||
- !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
- {
+ !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) {
CallProtoService(pa->szModuleName, PS_SETSTATUS, (WPARAM)iStatus, 0);
return -1;
}
mir_snprintf(szSetting, "Proto%sFlags", pa->szModuleName);
int flags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT);
- if (flags & PROTO_NO_MSG || flags & PROTO_THIS_MSG)
- {
+ if (flags & PROTO_NO_MSG || flags & PROTO_THIS_MSG) {
if (HasProtoStaticStatusMsg(pa->szModuleName, ID_STATUS_OFFLINE, iStatus))
return 0;
else
fmsg = nullptr;
}
- else if (flags & PROTO_NOCHANGE)
- {
+ else if (flags & PROTO_NOCHANGE) {
mir_snprintf(szSetting, "FCur%sMsg", pa->szModuleName);
fmsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
}
@@ -1199,8 +1129,7 @@ VOID CALLBACK SetStartupStatusGlobal(HWND hwnd, UINT, UINT_PTR idEvent, DWORD) KillTimer(hwnd, idEvent);
// is global status mode going to be set?
- for (int i = 0; i < accounts->count; ++i)
- {
+ for (int i = 0; i < accounts->count; ++i) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled())
continue;
@@ -1213,8 +1142,7 @@ VOID CALLBACK SetStartupStatusGlobal(HWND hwnd, UINT, UINT_PTR idEvent, DWORD) if (status_mode != ID_STATUS_OFFLINE)
temp_status_mode = status_mode;
- if (status_mode != prev_status_mode && prev_status_mode != -1)
- {
+ if (status_mode != prev_status_mode && prev_status_mode != -1) {
globalstatus = false;
break;
}
@@ -1223,8 +1151,7 @@ VOID CALLBACK SetStartupStatusGlobal(HWND hwnd, UINT, UINT_PTR idEvent, DWORD) }
// popup status msg dialog at startup?
- if (db_get_b(NULL, "SimpleStatusMsg", "StartupPopupDlg", 1) && accounts->statusMsgFlags)
- {
+ if (db_get_b(NULL, "SimpleStatusMsg", "StartupPopupDlg", 1) && accounts->statusMsgFlags) {
if (globalstatus)
ChangeStatusMessage(status_mode, (LPARAM)"SimpleStatusMsgGlobalStartupStatus");
else {
@@ -1235,8 +1162,7 @@ VOID CALLBACK SetStartupStatusGlobal(HWND hwnd, UINT, UINT_PTR idEvent, DWORD) return;
}
- for (int i = 0; i < accounts->count; ++i)
- {
+ for (int i = 0; i < accounts->count; ++i) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled())
continue;
@@ -1253,8 +1179,7 @@ VOID CALLBACK SetStartupStatusProc(HWND hwnd, UINT, UINT_PTR idEvent, DWORD) bool found = false;
int i = 0;
- for (; i < accounts->count; ++i)
- {
+ for (; i < accounts->count; ++i) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled())
continue;
@@ -1262,8 +1187,7 @@ VOID CALLBACK SetStartupStatusProc(HWND hwnd, UINT, UINT_PTR idEvent, DWORD) if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)))
continue;
- if (g_uSetStatusTimer[i] == idEvent)
- {
+ if (g_uSetStatusTimer[i] == idEvent) {
KillTimer(nullptr, g_uSetStatusTimer[i]);
found = true;
break;
@@ -1284,14 +1208,12 @@ VOID CALLBACK UpdateMsgTimerProc(HWND, UINT, UINT_PTR, DWORD) if (db_get_b(NULL, "SimpleStatusMsg", "NoUpdateOnIdle", 1) && mii.idleType)
return;
- if (!hwndSAMsgDialog)
- {
+ if (!hwndSAMsgDialog) {
char szBuffer[64];
wchar_t *tszMsg;
int iCurrentStatus;
- for (int i = 0; i < accounts->count; ++i)
- {
+ for (int i = 0; i < accounts->count; ++i) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled())
continue;
@@ -1317,8 +1239,7 @@ VOID CALLBACK UpdateMsgTimerProc(HWND, UINT, UINT_PTR, DWORD) mir_snprintf(szBuffer, "Cur%sMsg", pa->szModuleName);
tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szBuffer);
- if ((tszMsg && tszStatusMsg && !mir_wstrcmp(tszMsg, tszStatusMsg)) || (!tszMsg && !tszStatusMsg))
- {
+ if ((tszMsg && tszStatusMsg && !mir_wstrcmp(tszMsg, tszStatusMsg)) || (!tszMsg && !tszStatusMsg)) {
mir_free(tszStatusMsg);
mir_free(tszMsg);
continue;
@@ -1326,8 +1247,7 @@ VOID CALLBACK UpdateMsgTimerProc(HWND, UINT, UINT_PTR, DWORD) else
mir_free(tszStatusMsg);
- if (tszMsg && mir_wstrlen(tszMsg))
- {
+ if (tszMsg && mir_wstrlen(tszMsg)) {
#ifdef _DEBUG
log2file("UpdateMsgTimerProc(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iCurrentStatus, ""), tszMsg, pa->szModuleName);
#endif
@@ -1371,7 +1291,7 @@ static int ChangeStatusMsgPrebuild(WPARAM, LPARAM) auto &accs = Accounts();
hProtoStatusMenuItem = (HANDLE *)mir_realloc(hProtoStatusMenuItem, sizeof(HANDLE) * accs.getCount());
- for (auto &pa : accs) {
+ for (auto &pa : accs) {
if (!pa->IsEnabled())
continue;
@@ -1426,7 +1346,7 @@ static int ChangeStatusMsgPrebuild(WPARAM, LPARAM) mi.root = Menu_CreateRoot(MO_STATUS, szBuffer, mi.position);
}
else mi.root = Menu_CreateRoot(MO_STATUS, pa->tszAccountName, mi.position);
-
+
hProtoStatusMenuItem[i++] = Menu_AddStatusMenuItem(&mi);
}
@@ -1443,17 +1363,15 @@ static int OnIdleChanged(WPARAM, LPARAM lParam) MIRANDA_IDLE_INFO mii;
Idle_GetInfo(mii);
-
- if (mii.aaStatus == 0)
- {
+
+ if (mii.aaStatus == 0) {
#ifdef _DEBUG
log2file("OnIdleChanged(): AutoAway disabled");
#endif
return 0;
}
- for (int i = 0; i < accounts->count; ++i)
- {
+ for (int i = 0; i < accounts->count; ++i) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled())
continue;
@@ -1463,8 +1381,7 @@ static int OnIdleChanged(WPARAM, LPARAM lParam) int iStatusBits = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
int iStatus = mii.aaStatus;
- if (!(iStatusBits & Proto_Status2Flag(iStatus)))
- {
+ if (!(iStatusBits & Proto_Status2Flag(iStatus))) {
if (iStatusBits & Proto_Status2Flag(ID_STATUS_AWAY))
iStatus = ID_STATUS_AWAY;
else
@@ -1477,8 +1394,7 @@ static int OnIdleChanged(WPARAM, LPARAM lParam) if ((lParam & IDF_ISIDLE && (db_get_b(NULL, "AutoAway", pa->szModuleName, 0) ||
iCurrentStatus == ID_STATUS_ONLINE || iCurrentStatus == ID_STATUS_FREECHAT)) ||
- (!(lParam & IDF_ISIDLE) && !mii.aaLock))
- {
+ (!(lParam & IDF_ISIDLE) && !mii.aaLock)) {
if (!(lParam & IDF_ISIDLE))
iStatus = ID_STATUS_ONLINE;
wchar_t *tszMsg = GetAwayMessage(iStatus, pa->szModuleName, FALSE, NULL);
@@ -1503,8 +1419,7 @@ static int CSStatusChange(WPARAM wParam, LPARAM) if (ps == nullptr) return -1;
CSProtoCount = CallService(MS_CS_GETPROTOCOUNT, 0, 0);
- for (int i = 0; i < CSProtoCount; ++i)
- {
+ for (int i = 0; i < CSProtoCount; ++i) {
if (ps[i]->m_szName == nullptr || !*ps[i]->m_szName) continue;
if (ps[i]->m_status == ID_STATUS_IDLE)
status_mode = ps[i]->m_lastStatus;
@@ -1519,8 +1434,7 @@ static int CSStatusChange(WPARAM wParam, LPARAM) #endif
// TODO SaveMessageToDB also when NULL?
- if (ps[i]->m_szMsg)
- {
+ if (ps[i]->m_szMsg) {
char buff[80];
bool found = false;
wchar_t *szMsgW = mir_wstrdup(ps[i]->m_szMsg);
@@ -1529,14 +1443,11 @@ static int CSStatusChange(WPARAM wParam, LPARAM) log2file("CSStatusChange(): Set \"%s\" status message for %s.", ps[i]->m_szMsg, ps[i]->m_szName);
#endif
int max_hist_msgs = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10);
- for (int j = 1; j <= max_hist_msgs; j++)
- {
+ for (int j = 1; j <= max_hist_msgs; j++) {
mir_snprintf(buff, "SMsg%d", j);
wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", buff);
- if (tszStatusMsg != nullptr)
- {
- if (!mir_wstrcmp(tszStatusMsg, szMsgW))
- {
+ if (tszStatusMsg != nullptr) {
+ if (!mir_wstrcmp(tszStatusMsg, szMsgW)) {
found = true;
mir_snprintf(szSetting, "Last%sMsg", ps[i]->m_szName);
db_set_s(NULL, "SimpleStatusMsg", szSetting, buff);
@@ -1548,8 +1459,7 @@ static int CSStatusChange(WPARAM wParam, LPARAM) }
}
- if (!found)
- {
+ if (!found) {
mir_snprintf(buff, "FCur%sMsg", ps[i]->m_szName);
mir_snprintf(szSetting, "Last%sMsg", ps[i]->m_szName);
db_set_s(NULL, "SimpleStatusMsg", szSetting, buff);
@@ -1593,7 +1503,7 @@ static wchar_t *ParseDate(ARGUMENTSINFO *ai) if (ai->argc != 1)
return nullptr;
- wchar_t szStr[128] = {0};
+ wchar_t szStr[128] = { 0 };
ai->flags |= AIF_DONTPARSE;
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, nullptr, nullptr, szStr, _countof(szStr));
@@ -1603,13 +1513,13 @@ static wchar_t *ParseDate(ARGUMENTSINFO *ai) int ICQMsgTypeToStatus(int iMsgType)
{
switch (iMsgType) {
- case MTYPE_AUTOONLINE: return ID_STATUS_ONLINE;
- case MTYPE_AUTOAWAY: return ID_STATUS_AWAY;
- case MTYPE_AUTOBUSY: return ID_STATUS_OCCUPIED;
- case MTYPE_AUTONA: return ID_STATUS_NA;
- case MTYPE_AUTODND: return ID_STATUS_DND;
- case MTYPE_AUTOFFC: return ID_STATUS_FREECHAT;
- default: return ID_STATUS_OFFLINE;
+ case MTYPE_AUTOONLINE: return ID_STATUS_ONLINE;
+ case MTYPE_AUTOAWAY: return ID_STATUS_AWAY;
+ case MTYPE_AUTOBUSY: return ID_STATUS_OCCUPIED;
+ case MTYPE_AUTONA: return ID_STATUS_NA;
+ case MTYPE_AUTODND: return ID_STATUS_DND;
+ case MTYPE_AUTOFFC: return ID_STATUS_FREECHAT;
+ default: return ID_STATUS_OFFLINE;
}
}
@@ -1670,7 +1580,7 @@ static int OnAccListChanged(WPARAM, LPARAM) if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
continue;
- accounts->statusMsgFlags |= CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3,0);
+ accounts->statusMsgFlags |= CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0))
continue;
@@ -1703,7 +1613,7 @@ static int OnModulesLoaded(WPARAM, LPARAM) ChangeStatusMsgPrebuild(0, 0);
if (ServiceExists(MS_VARS_REGISTERTOKEN)) {
- TOKENREGISTER tr = {0};
+ TOKENREGISTER tr = { 0 };
tr.cbSize = sizeof(TOKENREGISTER);
tr.memType = TR_MEM_MIRANDA;
tr.flags = TRF_FREEMEM | TRF_FIELD | TRF_TCHAR | TRF_PARSEFUNC;
@@ -1719,7 +1629,7 @@ static int OnModulesLoaded(WPARAM, LPARAM) CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
}
}
-
+
g_ptszWinampSong = db_get_wsa(NULL, "SimpleStatusMsg", "AmpLastTitle");
if (g_ptszWinampSong == nullptr)
g_ptszWinampSong = mir_wstrdup(L"SimpleStatusMsg");
diff --git a/plugins/SimpleStatusMsg/src/msgbox.cpp b/plugins/SimpleStatusMsg/src/msgbox.cpp index 77c4c7d66f..9d02ca54c3 100644 --- a/plugins/SimpleStatusMsg/src/msgbox.cpp +++ b/plugins/SimpleStatusMsg/src/msgbox.cpp @@ -105,10 +105,10 @@ HWND WINAPI CreateStatusComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) return nullptr; HWND handle = CreateWindowEx(0, WC_COMBOBOXEX, nullptr, - WS_TABSTOP | CBS_NOINTEGRALHEIGHT | WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST, - 0, 0, 0, 240, hwndDlg, nullptr, g_hInst, nullptr); + WS_TABSTOP | CBS_NOINTEGRALHEIGHT | WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST, + 0, 0, 0, 240, hwndDlg, nullptr, g_hInst, nullptr); - COMBOBOXEXITEM cbei = {0}; + COMBOBOXEXITEM cbei = { 0 }; if (!(data->m_iDlgFlags & DLG_SHOW_STATUS_ICONS)) cbei.mask = CBEIF_LPARAM | CBEIF_TEXT; else @@ -183,7 +183,7 @@ HWND WINAPI CreateStatusComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) cbei.iImage = statusicon_nr[k]; cbei.iSelectedImage = statusicon_nr[k]; } - cbei.lParam = (LPARAM)40083 + i; + cbei.lParam = (LPARAM)40083 + i; mir_free(status_desc); @@ -220,10 +220,10 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) wchar_t text[128]; HWND handle = CreateWindowEx(0, WC_COMBOBOXEX, nullptr, - WS_TABSTOP | CBS_NOINTEGRALHEIGHT | WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST, - 0, 0, 0, 300, hwndDlg, nullptr, g_hInst, nullptr); + WS_TABSTOP | CBS_NOINTEGRALHEIGHT | WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST, + 0, 0, 0, 300, hwndDlg, nullptr, g_hInst, nullptr); - COMBOBOXEXITEM cbei = {0}; + COMBOBOXEXITEM cbei = { 0 }; if (!(data->m_iDlgFlags & DLG_SHOW_LIST_ICONS)) cbei.mask = CBEIF_LPARAM | CBEIF_TEXT | CBEIF_INDENT; else @@ -419,74 +419,74 @@ VOID APIENTRY HandlePopupMenu(HWND hwnd, POINT pt, HWND edit_control) int m_selection = TrackPopupMenu(hmenuTrackPopup, TPM_LEFTALIGN | TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, nullptr); switch (m_selection) { - case IDM_COPY: - SendMessage(edit_control, WM_COPY, 0, 0); - break; + case IDM_COPY: + SendMessage(edit_control, WM_COPY, 0, 0); + break; - case IDM_CUT: - SendMessage(edit_control, WM_CUT, 0, 0); - break; + case IDM_CUT: + SendMessage(edit_control, WM_CUT, 0, 0); + break; - case IDM_PASTE: - SendMessage(edit_control, WM_PASTE, 0, 0); - break; + case IDM_PASTE: + SendMessage(edit_control, WM_PASTE, 0, 0); + break; - case IDM_SELECTALL: - SendMessage(edit_control, EM_SETSEL, 0, -1); - break; + case IDM_SELECTALL: + SendMessage(edit_control, EM_SETSEL, 0, -1); + break; - case IDM_DELETE: - SetWindowText(edit_control, L""); - SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_EDIT1, EN_CHANGE), (LPARAM)edit_control); - break; + case IDM_DELETE: + SetWindowText(edit_control, L""); + SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(IDC_EDIT1, EN_CHANGE), (LPARAM)edit_control); + break; - case ID__FORTUNEAWAYMSG: - Utils_OpenUrl("https://miranda-ng.org/"); - break; + case ID__FORTUNEAWAYMSG: + Utils_OpenUrl("https://miranda-ng.org/"); + break; - case ID__VARIABLES: - Utils_OpenUrl("https://miranda-ng.org/"); - break; + case ID__VARIABLES: + Utils_OpenUrl("https://miranda-ng.org/"); + break; - case ID__VARIABLES_MOREVARIABLES: - { - VARHELPINFO vhi = {0}; - vhi.cbSize = sizeof(vhi); - vhi.flags = VHF_FULLDLG | VHF_SETLASTSUBJECT; - vhi.hwndCtrl = edit_control; - vhi.szSubjectDesc = nullptr; - vhi.szExtraTextDesc = nullptr; - CallService(MS_VARS_SHOWHELPEX, (WPARAM)hwnd, (LPARAM)&vhi); - } - break; + case ID__VARIABLES_MOREVARIABLES: + { + VARHELPINFO vhi = { 0 }; + vhi.cbSize = sizeof(vhi); + vhi.flags = VHF_FULLDLG | VHF_SETLASTSUBJECT; + vhi.hwndCtrl = edit_control; + vhi.szSubjectDesc = nullptr; + vhi.szExtraTextDesc = nullptr; + CallService(MS_VARS_SHOWHELPEX, (WPARAM)hwnd, (LPARAM)&vhi); + } + break; - default: - if (!OpenClipboard(GetParent(hwnd))) - break; + default: + if (!OpenClipboard(GetParent(hwnd))) + break; - if (EmptyClipboard()) { - wchar_t item_string[128]; - GetMenuString(hmenu, m_selection, (LPTSTR)&item_string, 128, MF_BYCOMMAND); - - int len = (int)mir_wstrlen(item_string); - if (len) { - LPTSTR lptstrCopy; - HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(wchar_t)); - if (hglbCopy == nullptr) { - CloseClipboard(); - break; - } - lptstrCopy = (LPTSTR)GlobalLock(hglbCopy); - memcpy(lptstrCopy, item_string, len * sizeof(wchar_t)); - lptstrCopy[len] = (wchar_t)0; - GlobalUnlock(hglbCopy); + if (EmptyClipboard()) { + wchar_t item_string[128]; + GetMenuString(hmenu, m_selection, (LPTSTR)&item_string, 128, MF_BYCOMMAND); - SetClipboardData(CF_UNICODETEXT, hglbCopy); + int len = (int)mir_wstrlen(item_string); + if (len) { + LPTSTR lptstrCopy; + HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(wchar_t)); + if (hglbCopy == nullptr) { + CloseClipboard(); + break; } + lptstrCopy = (LPTSTR)GlobalLock(hglbCopy); + memcpy(lptstrCopy, item_string, len * sizeof(wchar_t)); + lptstrCopy[len] = (wchar_t)0; + GlobalUnlock(hglbCopy); + + SetClipboardData(CF_UNICODETEXT, hglbCopy); } - CloseClipboard(); - SendMessage(edit_control, WM_PASTE, 0, 0); - break; + } + CloseClipboard(); + SendMessage(edit_control, WM_PASTE, 0, 0); + break; } DestroyMenu(hmenu); } @@ -517,7 +517,7 @@ static LRESULT CALLBACK EditBoxSubProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L } case WM_CHAR: - if (wParam=='\n' && GetKeyState(VK_CONTROL) & 0x8000) { + if (wParam == '\n' && GetKeyState(VK_CONTROL) & 0x8000) { PostMessage(GetParent(hwndDlg), WM_COMMAND, IDC_OK, 0); return 0; } @@ -591,7 +591,7 @@ static LRESULT CALLBACK EditBoxSubProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L int AddToPredefined(HWND hwndDlg, struct MsgBoxData *data) { - COMBOBOXEXITEM newitem = {0}; + COMBOBOXEXITEM newitem = { 0 }; int len = 0, num_items; wchar_t msg[1024], text[1024]; @@ -634,7 +634,7 @@ int AddToPredefined(HWND hwndDlg, struct MsgBoxData *data) void ClearHistory(struct MsgBoxData *data, int cur_sel) { - COMBOBOXEXITEM histitem = {0}; + COMBOBOXEXITEM histitem = { 0 }; int i, num_items; char text[16], buff2[80]; @@ -809,8 +809,7 @@ void ChangeDlgStatus(HWND hwndDlg, struct MsgBoxData *msgbox_data, int iStatus) Window_SetProtoIcon_IcoLib(hwndDlg, msgbox_data->m_szProto, iStatus); if (!bDisabled && ((Proto_Status2Flag(iStatus) & msgbox_data->m_iStatusMsgModes) - || (iStatus == ID_STATUS_OFFLINE && (Proto_Status2Flag(ID_STATUS_INVISIBLE) & msgbox_data->m_iStatusMsgModes)))) - { + || (iStatus == ID_STATUS_OFFLINE && (Proto_Status2Flag(ID_STATUS_INVISIBLE) & msgbox_data->m_iStatusMsgModes)))) { int num_items = SendMessage(msgbox_data->recent_cbex, CB_GETCOUNT, 0, 0); int fcursel = CB_ERR, num_start = num_items - msgbox_data->num_def_msgs - 1; wchar_t msg[1024]; @@ -842,7 +841,7 @@ void ChangeDlgStatus(HWND hwndDlg, struct MsgBoxData *msgbox_data, int iStatus) EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE); } else { - COMBOBOXEXITEM cbitem = {0}; + COMBOBOXEXITEM cbitem = { 0 }; cbitem.mask = CBEIF_LPARAM | CBEIF_TEXT; cbitem.iItem = msgbox_data->curr_sel_msg; cbitem.cchTextMax = _countof(msg); @@ -860,7 +859,7 @@ void ChangeDlgStatus(HWND hwndDlg, struct MsgBoxData *msgbox_data, int iStatus) } if (msgbox_data->m_bIsMsgHistory && !IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BCLEAR))) - EnableWindow(GetDlgItem(hwndDlg, IDC_BCLEAR), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BCLEAR), TRUE); } } } @@ -889,12 +888,12 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA struct MsgBoxData *msgbox_data = (struct MsgBoxData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (uMsg) { - case WM_INITDIALOG: + case WM_INITDIALOG: { wchar_t szTitle[256], szFormat[256], szProtoName[128]; struct MsgBoxInitData *init_data; struct MsgBoxData *copy_init_data; - INITCOMMONCONTROLSEX icex = {0}; + INITCOMMONCONTROLSEX icex = { 0 }; BOOL bCurrentStatus = FALSE, bDisabled = FALSE; InitCommonControls(); @@ -1008,7 +1007,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE); } else { - COMBOBOXEXITEM cbitem = {0}; + COMBOBOXEXITEM cbitem = { 0 }; cbitem.mask = CBEIF_LPARAM | CBEIF_TEXT; cbitem.iItem = copy_init_data->curr_sel_msg; cbitem.cchTextMax = _countof(msg); @@ -1030,8 +1029,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA bDisabled = TRUE; if (!(((Proto_Status2Flag(copy_init_data->m_iStatus) & copy_init_data->m_iStatusMsgModes) - || (copy_init_data->m_iStatus == ID_STATUS_OFFLINE && (Proto_Status2Flag(ID_STATUS_INVISIBLE) & copy_init_data->m_iStatusMsgModes))) && !bDisabled)) - { + || (copy_init_data->m_iStatus == ID_STATUS_OFFLINE && (Proto_Status2Flag(ID_STATUS_INVISIBLE) & copy_init_data->m_iStatusMsgModes))) && !bDisabled)) { if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1))) EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT1), FALSE); if (IsWindowEnabled(copy_init_data->recent_cbex)) @@ -1060,7 +1058,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (bCurrentStatus) copy_init_data->m_iStatus = ID_STATUS_CURRENT; - mir_subclassWindow( GetDlgItem(hwndDlg, IDC_EDIT1), EditBoxSubProc); + mir_subclassWindow(GetDlgItem(hwndDlg, IDC_EDIT1), EditBoxSubProc); if (!init_data->m_bOnEvent && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1))) { SetFocus(GetDlgItem(hwndDlg, IDC_EDIT1)); SendDlgItemMessage(hwndDlg, IDC_EDIT1, EM_SETSEL, 0, -1); @@ -1080,7 +1078,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA x = (int)db_get_dw(NULL, "SimpleStatusMsg", "Winx", -1); y = (int)db_get_dw(NULL, "SimpleStatusMsg", "Winy", -1); - if (x !=- 1) { + if (x != -1) { OffsetRect(&wp.rcNormalPosition, x - wp.rcNormalPosition.left, y - wp.rcNormalPosition.top); wp.flags = 0; SetWindowPlacement(hwndDlg, &wp); @@ -1089,53 +1087,153 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA return FALSE; } - case WM_TIMER: - if (msgbox_data->m_iCountdown == -1) { - SendMessage(hwndDlg, WM_COMMAND, (WPARAM)IDC_OK, 0); - msgbox_data->m_iCountdown = -2; - DisplayCharsCount(msgbox_data, hwndDlg); - break; - } - else { - wchar_t str[64]; - mir_snwprintf(str, TranslateT("Closing in %d"), msgbox_data->m_iCountdown); - SetDlgItemText(hwndDlg, IDC_OK, str); - } - msgbox_data->m_iCountdown--; + case WM_TIMER: + if (msgbox_data->m_iCountdown == -1) { + SendMessage(hwndDlg, WM_COMMAND, (WPARAM)IDC_OK, 0); + msgbox_data->m_iCountdown = -2; + DisplayCharsCount(msgbox_data, hwndDlg); break; + } + else { + wchar_t str[64]; + mir_snwprintf(str, TranslateT("Closing in %d"), msgbox_data->m_iCountdown); + SetDlgItemText(hwndDlg, IDC_OK, str); + } + msgbox_data->m_iCountdown--; + break; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_OK: - { - wchar_t tszMsg[1024]; - int iStatus, iMsgLen = 0, iProfileStatus = 0; - BOOL bCurrentStatus = FALSE; - - if (msgbox_data->m_iStatus == ID_STATUS_CURRENT) { - msgbox_data->m_iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(msgbox_data->m_szProto) : GetCurrentStatus(msgbox_data->m_szProto); - if (msgbox_data->m_szProto == nullptr) - bCurrentStatus = TRUE; + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDC_OK: + { + wchar_t tszMsg[1024]; + int iStatus, iMsgLen = 0, iProfileStatus = 0; + BOOL bCurrentStatus = FALSE; + + if (msgbox_data->m_iStatus == ID_STATUS_CURRENT) { + msgbox_data->m_iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(msgbox_data->m_szProto) : GetCurrentStatus(msgbox_data->m_szProto); + if (msgbox_data->m_szProto == nullptr) + bCurrentStatus = TRUE; + } + else if (msgbox_data->m_iStatus >= ID_STATUS_CURRENT) { + iProfileStatus = msgbox_data->m_iStatus; + msgbox_data->m_iStatus = GetCurrentStatus(nullptr); + } + + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1))) + iMsgLen = GetDlgItemText(hwndDlg, IDC_EDIT1, tszMsg, _countof(tszMsg)); + + if (iMsgLen == 0) { + char szSetting[80]; + if (msgbox_data->m_szProto) { + mir_snprintf(szSetting, "Last%sMsg", msgbox_data->m_szProto); + db_set_s(NULL, "SimpleStatusMsg", szSetting, ""); + + mir_snprintf(szSetting, "%sMsg", msgbox_data->m_szProto); + db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, szSetting), L""); + } + else { + db_set_s(NULL, "SimpleStatusMsg", "LastMsg", ""); + for (int j = 0; j < accounts->count; j++) { + auto *pa = accounts->pa[j]; + if (!pa->IsEnabled()) + continue; + + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) + continue; + + if (db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0)) + continue; + + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + continue; + + mir_snprintf(szSetting, "Last%sMsg", pa->szModuleName); + db_set_s(NULL, "SimpleStatusMsg", szSetting, ""); + + mir_snprintf(szSetting, "%sMsg", pa->szModuleName); + iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(pa->szModuleName) : GetCurrentStatus(pa->szModuleName); + db_set_ws(NULL, "SRAway", StatusModeToDbSetting(iStatus, szSetting), L""); + } + + db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, "Msg"), L""); // for compatibility with some plugins } - else if (msgbox_data->m_iStatus >= ID_STATUS_CURRENT) { - iProfileStatus = msgbox_data->m_iStatus; - msgbox_data->m_iStatus = GetCurrentStatus(nullptr); + + if (bCurrentStatus) + SetStatusMessage(msgbox_data->m_szProto, msgbox_data->m_iInitialStatus, ID_STATUS_CURRENT, nullptr, msgbox_data->m_bOnStartup); + else if (iProfileStatus != 0) + SetStatusMessage(msgbox_data->m_szProto, msgbox_data->m_iInitialStatus, iProfileStatus, nullptr, FALSE); + else + SetStatusMessage(msgbox_data->m_szProto, msgbox_data->m_iInitialStatus, msgbox_data->m_iStatus, nullptr, msgbox_data->m_bOnStartup); + } + else { + char buff[64], buff2[80]; + bool found = false; + + for (int i = 1; i <= msgbox_data->max_hist_msgs; i++) { + mir_snprintf(buff, "SMsg%d", i); + wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", buff); + if (tszStatusMsg != nullptr) { + if (!mir_wstrcmp(tszStatusMsg, tszMsg)) { + found = true; + if (msgbox_data->m_szProto) { + mir_snprintf(buff2, "Last%sMsg", msgbox_data->m_szProto); + db_set_s(NULL, "SimpleStatusMsg", buff2, buff); + + mir_snprintf(buff2, "%sMsg", msgbox_data->m_szProto); + db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, buff2), tszMsg); + } + else { + db_set_s(NULL, "SimpleStatusMsg", "LastMsg", buff); + for (int j = 0; j < accounts->count; j++) { + auto *pa = accounts->pa[j]; + if (!pa->IsEnabled()) + continue; + + if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) + continue; + + if (db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0)) + continue; + + if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) + continue; + + mir_snprintf(buff2, "Last%sMsg", pa->szModuleName); + db_set_s(NULL, "SimpleStatusMsg", buff2, buff); + + mir_snprintf(buff2, "%sMsg", pa->szModuleName); + iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(pa->szModuleName) : GetCurrentStatus(pa->szModuleName); + db_set_ws(NULL, "SRAway", StatusModeToDbSetting(iStatus, buff2), tszMsg); + } + } + mir_free(tszStatusMsg); + break; + } + mir_free(tszStatusMsg); + } } - if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1))) - iMsgLen = GetDlgItemText(hwndDlg, IDC_EDIT1, tszMsg, _countof(tszMsg)); + if (!found) { + int last_modified_msg = db_get_w(NULL, "SimpleStatusMsg", "LMMsg", msgbox_data->max_hist_msgs); + + if (last_modified_msg == msgbox_data->max_hist_msgs) + last_modified_msg = 1; + else + last_modified_msg++; + + mir_snprintf(buff, "SMsg%d", last_modified_msg); + db_set_ws(NULL, "SimpleStatusMsg", buff, tszMsg); - if (iMsgLen == 0) { - char szSetting[80]; if (msgbox_data->m_szProto) { - mir_snprintf(szSetting, "Last%sMsg", msgbox_data->m_szProto); - db_set_s(NULL, "SimpleStatusMsg", szSetting, ""); + mir_snprintf(buff2, "Last%sMsg", msgbox_data->m_szProto); + db_set_s(NULL, "SimpleStatusMsg", buff2, buff); - mir_snprintf(szSetting, "%sMsg", msgbox_data->m_szProto); - db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, szSetting), L""); + mir_snprintf(buff2, "%sMsg", msgbox_data->m_szProto); + db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, buff2), tszMsg); } else { - db_set_s(NULL, "SimpleStatusMsg", "LastMsg", ""); + db_set_s(NULL, "SimpleStatusMsg", "LastMsg", buff); for (int j = 0; j < accounts->count; j++) { auto *pa = accounts->pa[j]; if (!pa->IsEnabled()) @@ -1150,433 +1248,324 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) continue; - mir_snprintf(szSetting, "Last%sMsg", pa->szModuleName); - db_set_s(NULL, "SimpleStatusMsg", szSetting, ""); + mir_snprintf(buff2, "Last%sMsg", pa->szModuleName); + db_set_s(NULL, "SimpleStatusMsg", buff2, buff); - mir_snprintf(szSetting, "%sMsg", pa->szModuleName); + mir_snprintf(buff2, "%sMsg", pa->szModuleName); iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(pa->szModuleName) : GetCurrentStatus(pa->szModuleName); - db_set_ws(NULL, "SRAway", StatusModeToDbSetting(iStatus, szSetting), L""); + db_set_ws(NULL, "SRAway", StatusModeToDbSetting(iStatus, buff2), tszMsg); } - - db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, "Msg"), L""); // for compatibility with some plugins } - - if (bCurrentStatus) - SetStatusMessage(msgbox_data->m_szProto, msgbox_data->m_iInitialStatus, ID_STATUS_CURRENT, nullptr, msgbox_data->m_bOnStartup); - else if (iProfileStatus != 0) - SetStatusMessage(msgbox_data->m_szProto, msgbox_data->m_iInitialStatus, iProfileStatus, nullptr, FALSE); - else - SetStatusMessage(msgbox_data->m_szProto, msgbox_data->m_iInitialStatus, msgbox_data->m_iStatus, nullptr, msgbox_data->m_bOnStartup); + db_set_w(NULL, "SimpleStatusMsg", "LMMsg", (WORD)last_modified_msg); } - else { - char buff[64], buff2[80]; - bool found = false; - - for (int i = 1; i <= msgbox_data->max_hist_msgs; i++) { - mir_snprintf(buff, "SMsg%d", i); - wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", buff); - if (tszStatusMsg != nullptr) { - if (!mir_wstrcmp(tszStatusMsg, tszMsg)) { - found = true; - if (msgbox_data->m_szProto) { - mir_snprintf(buff2, "Last%sMsg", msgbox_data->m_szProto); - db_set_s(NULL, "SimpleStatusMsg", buff2, buff); - - mir_snprintf(buff2, "%sMsg", msgbox_data->m_szProto); - db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, buff2), tszMsg); - } - else { - db_set_s(NULL, "SimpleStatusMsg", "LastMsg", buff); - for (int j = 0; j < accounts->count; j++) { - auto *pa = accounts->pa[j]; - if (!pa->IsEnabled()) - continue; - if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) - continue; + if (!msgbox_data->m_szProto) + db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, "Msg"), tszMsg); // for compatibility with some plugins - if (db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0)) - continue; - - if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) - continue; - - mir_snprintf(buff2, "Last%sMsg", pa->szModuleName); - db_set_s(NULL, "SimpleStatusMsg", buff2, buff); + if (bCurrentStatus) + SetStatusMessage(msgbox_data->m_szProto, msgbox_data->m_iInitialStatus, ID_STATUS_CURRENT, tszMsg, msgbox_data->m_bOnStartup); + else if (iProfileStatus != 0) + SetStatusMessage(msgbox_data->m_szProto, msgbox_data->m_iInitialStatus, iProfileStatus, tszMsg, FALSE); + else + SetStatusMessage(msgbox_data->m_szProto, msgbox_data->m_iInitialStatus, msgbox_data->m_iStatus, tszMsg, msgbox_data->m_bOnStartup); + } + } + __fallthrough; - mir_snprintf(buff2, "%sMsg", pa->szModuleName); - iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(pa->szModuleName) : GetCurrentStatus(pa->szModuleName); - db_set_ws(NULL, "SRAway", StatusModeToDbSetting(iStatus, buff2), tszMsg); - } - } - mir_free(tszStatusMsg); - break; - } - mir_free(tszStatusMsg); - } - } + case IDCANCEL: + case IDC_CANCEL: + DestroyWindow(hwndDlg); + return TRUE; - if (!found) { - int last_modified_msg = db_get_w(NULL, "SimpleStatusMsg", "LMMsg", msgbox_data->max_hist_msgs); + case IDC_EDIT1: // Notification from the edit control + if (msgbox_data->m_iCountdown > -2) { + KillTimer(hwndDlg, 1); + msgbox_data->m_iCountdown = -2; + DisplayCharsCount(msgbox_data, hwndDlg); + } + + switch (HIWORD(wParam)) { + case EN_CHANGE: + DisplayCharsCount(msgbox_data, hwndDlg); + SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, -1, 0); + if ((msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) { + wchar_t msg[1024]; - if (last_modified_msg == msgbox_data->max_hist_msgs) - last_modified_msg = 1; - else - last_modified_msg++; + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BDEL))) + EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE); - mir_snprintf(buff, "SMsg%d", last_modified_msg); - db_set_ws(NULL, "SimpleStatusMsg", buff, tszMsg); + if (!GetDlgItemText(hwndDlg, IDC_EDIT1, msg, _countof(msg))) { + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD))) + EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE); + } + else if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD))) + EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), TRUE); + } + break; + } + break; + } - if (msgbox_data->m_szProto) { - mir_snprintf(buff2, "Last%sMsg", msgbox_data->m_szProto); - db_set_s(NULL, "SimpleStatusMsg", buff2, buff); + if ((HWND)lParam == msgbox_data->status_cbex) { + if (msgbox_data->m_iCountdown > -2) { + KillTimer(hwndDlg, 1); + msgbox_data->m_iCountdown = -2; + DisplayCharsCount(msgbox_data, hwndDlg); + } + + switch (HIWORD(wParam)) { + case CBN_SELENDOK: + case CBN_SELCHANGE: + COMBOBOXEXITEM cbitem = { 0 }; - mir_snprintf(buff2, "%sMsg", msgbox_data->m_szProto); - db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, buff2), tszMsg); - } - else { - db_set_s(NULL, "SimpleStatusMsg", "LastMsg", buff); - for (int j = 0; j < accounts->count; j++) { - auto *pa = accounts->pa[j]; - if (!pa->IsEnabled()) - continue; + cbitem.mask = CBEIF_LPARAM; + cbitem.iItem = SendMessage(msgbox_data->status_cbex, CB_GETCURSEL, 0, 0); + SendMessage(msgbox_data->status_cbex, CBEM_GETITEM, 0, (LPARAM)&cbitem); - if (!CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)) - continue; + msgbox_data->m_iStatus = cbitem.lParam; + ChangeDlgStatus(hwndDlg, msgbox_data, (int)cbitem.lParam); - if (db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0)) - continue; + if (HIWORD(wParam) == CBN_SELENDOK && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1))) + SetFocus(GetDlgItem(hwndDlg, IDC_EDIT1)); + break; + } + } - if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) - continue; + if ((HWND)lParam == msgbox_data->recent_cbex) { + if (msgbox_data->m_iCountdown > -2) { + KillTimer(hwndDlg, 1); + msgbox_data->m_iCountdown = -2; + DisplayCharsCount(msgbox_data, hwndDlg); + } + switch (HIWORD(wParam)) { + case CBN_SELENDOK: + wchar_t text[1024]; + int cur_sel = SendMessage(msgbox_data->recent_cbex, CB_GETCURSEL, 0, 0); + COMBOBOXEXITEM cbitem = { 0 }; - mir_snprintf(buff2, "Last%sMsg", pa->szModuleName); - db_set_s(NULL, "SimpleStatusMsg", buff2, buff); + cbitem.mask = CBEIF_LPARAM | CBEIF_TEXT; + cbitem.iItem = cur_sel; + cbitem.cchTextMax = _countof(text); + cbitem.pszText = text; - mir_snprintf(buff2, "%sMsg", pa->szModuleName); - iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(pa->szModuleName) : GetCurrentStatus(pa->szModuleName); - db_set_ws(NULL, "SRAway", StatusModeToDbSetting(iStatus, buff2), tszMsg); - } - } - db_set_w(NULL, "SimpleStatusMsg", "LMMsg", (WORD)last_modified_msg); + SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&cbitem); + if (LOWORD(cbitem.lParam) == HISTORY_MSG || LOWORD(cbitem.lParam) == PREDEFINED_MSG || LOWORD(cbitem.lParam) == DEFAULT_MSG) { + SetDlgItemText(hwndDlg, IDC_EDIT1, text); + DisplayCharsCount(msgbox_data, hwndDlg); + if ((msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) { + if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BDEL))) + EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), TRUE); + if (LOWORD(cbitem.lParam) == PREDEFINED_MSG) { + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD))) + EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE); } + else if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD))) + EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), TRUE); + } + } + else if (LOWORD(cbitem.lParam) == CLEAR_HISTORY) { + if (MessageBox(nullptr, TranslateT("Are you sure you want to clear status message history?"), TranslateT("Confirm clearing history"), MB_ICONQUESTION | MB_YESNO) == IDYES) + ClearHistory(msgbox_data, cur_sel); + else if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1))) { + wchar_t msg[1024]; + int fcursel = CB_ERR, num_start; + num_start = SendMessage(msgbox_data->recent_cbex, CB_GETCOUNT, 0, 0); + num_start -= msgbox_data->num_def_msgs + 1; + GetDlgItemText(hwndDlg, IDC_EDIT1, msg, _countof(msg)); + fcursel = SendMessage(msgbox_data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)msg); + SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, fcursel, 0); + } + } + else if (LOWORD(cbitem.lParam) == DELETE_SELECTED) { + COMBOBOXEXITEM histitem = { 0 }; + BOOL scursel = FALSE; + + histitem.mask = CBEIF_LPARAM; + histitem.iItem = msgbox_data->curr_sel_msg; + SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&histitem); + + if (LOWORD(histitem.lParam) == HISTORY_MSG) { + char szSetting[16]; + mir_snprintf(szSetting, "SMsg%d", (int)HIWORD(histitem.lParam)); + db_set_ws(NULL, "SimpleStatusMsg", szSetting, L""); + SendMessage(msgbox_data->recent_cbex, CBEM_DELETEITEM, (WPARAM)msgbox_data->curr_sel_msg, 0); + } + if (LOWORD(histitem.lParam) == PREDEFINED_MSG) { + msgbox_data->m_bPredefChanged = TRUE; + SendMessage(msgbox_data->recent_cbex, CBEM_DELETEITEM, (WPARAM)msgbox_data->curr_sel_msg, 0); + } - if (!msgbox_data->m_szProto) - db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, "Msg"), tszMsg); // for compatibility with some plugins + cur_sel = msgbox_data->curr_sel_msg; + while (!scursel) { + if (cur_sel - 1 >= 0) + cur_sel--; + else { + scursel = TRUE; + break; + } + histitem.mask = CBEIF_LPARAM; + histitem.iItem = cur_sel; + SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&histitem); - if (bCurrentStatus) - SetStatusMessage(msgbox_data->m_szProto, msgbox_data->m_iInitialStatus, ID_STATUS_CURRENT, tszMsg, msgbox_data->m_bOnStartup); - else if (iProfileStatus != 0) - SetStatusMessage(msgbox_data->m_szProto, msgbox_data->m_iInitialStatus, iProfileStatus, tszMsg, FALSE); - else - SetStatusMessage(msgbox_data->m_szProto, msgbox_data->m_iInitialStatus, msgbox_data->m_iStatus, tszMsg, msgbox_data->m_bOnStartup); + if ((LOWORD(histitem.lParam) != CLEAR_HISTORY) && (LOWORD(histitem.lParam) != DELETE_SELECTED) && (LOWORD(histitem.lParam) != ADD_MSG)) + scursel = TRUE; } - } // fallthrough + msgbox_data->curr_sel_msg = cur_sel; + SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, (WPARAM)cur_sel, 0); - case IDCANCEL: - case IDC_CANCEL: - DestroyWindow(hwndDlg); - return TRUE; + histitem.mask = CBEIF_LPARAM | CBEIF_TEXT; + histitem.iItem = cur_sel; + histitem.cchTextMax = _countof(text); + histitem.pszText = text; - case IDC_EDIT1: // Notification from the edit control - if (msgbox_data->m_iCountdown > -2) { - KillTimer(hwndDlg, 1); - msgbox_data->m_iCountdown = -2; + SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&histitem); + if (LOWORD(histitem.lParam) == HISTORY_MSG || LOWORD(histitem.lParam) == PREDEFINED_MSG || LOWORD(histitem.lParam) == DEFAULT_MSG) { + SetDlgItemText(hwndDlg, IDC_EDIT1, text); DisplayCharsCount(msgbox_data, hwndDlg); } - switch (HIWORD(wParam)) { - case EN_CHANGE: - DisplayCharsCount(msgbox_data, hwndDlg); - SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, -1, 0); - if ((msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) { - wchar_t msg[1024]; - - if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BDEL))) - EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE); - - if (!GetDlgItemText(hwndDlg, IDC_EDIT1, msg, _countof(msg))) { - if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD))) - EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE); - } - else if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD))) - EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), TRUE); - } - break; - } - break; - } - - if ((HWND)lParam == msgbox_data->status_cbex) { - if (msgbox_data->m_iCountdown > -2) { - KillTimer(hwndDlg, 1); - msgbox_data->m_iCountdown = -2; - DisplayCharsCount(msgbox_data, hwndDlg); } - switch (HIWORD(wParam)) { - case CBN_SELENDOK: - case CBN_SELCHANGE: - { - COMBOBOXEXITEM cbitem = {0}; - - cbitem.mask = CBEIF_LPARAM; - cbitem.iItem = SendMessage(msgbox_data->status_cbex, CB_GETCURSEL, 0, 0); - SendMessage(msgbox_data->status_cbex, CBEM_GETITEM, 0, (LPARAM)&cbitem); - - msgbox_data->m_iStatus = cbitem.lParam; - ChangeDlgStatus(hwndDlg, msgbox_data, (int)cbitem.lParam); - - if (HIWORD(wParam) == CBN_SELENDOK && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1))) - SetFocus(GetDlgItem(hwndDlg, IDC_EDIT1)); - break; + else if (LOWORD(cbitem.lParam) == ADD_MSG) { + int sel = AddToPredefined(hwndDlg, msgbox_data); + if (sel != -1) { + SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, (WPARAM)sel, 0); + msgbox_data->curr_sel_msg = sel; } + else + SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, (WPARAM)msgbox_data->curr_sel_msg, 0); + break; } - } + msgbox_data->curr_sel_msg = cur_sel; - if ((HWND)lParam == msgbox_data->recent_cbex) { - if (msgbox_data->m_iCountdown > -2) { - KillTimer(hwndDlg, 1); - msgbox_data->m_iCountdown = -2; - DisplayCharsCount(msgbox_data, hwndDlg); + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1))) { + SetFocus(GetDlgItem(hwndDlg, IDC_EDIT1)); + SendDlgItemMessage(hwndDlg, IDC_EDIT1, EM_SETSEL, 0, -1); } - switch (HIWORD(wParam)) { - case CBN_SELENDOK: - { - wchar_t text[1024]; - int cur_sel = SendMessage(msgbox_data->recent_cbex, CB_GETCURSEL, 0, 0); - COMBOBOXEXITEM cbitem = {0}; - - cbitem.mask = CBEIF_LPARAM | CBEIF_TEXT; - cbitem.iItem = cur_sel; - cbitem.cchTextMax = _countof(text); - cbitem.pszText = text; - - SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&cbitem); - if (LOWORD(cbitem.lParam) == HISTORY_MSG || LOWORD(cbitem.lParam) == PREDEFINED_MSG || LOWORD(cbitem.lParam) == DEFAULT_MSG) - { - SetDlgItemText(hwndDlg, IDC_EDIT1, text); - DisplayCharsCount(msgbox_data, hwndDlg); - if ((msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) { - if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BDEL))) - EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), TRUE); - if (LOWORD(cbitem.lParam) == PREDEFINED_MSG) { - if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD))) - EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE); - } - else if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD))) - EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), TRUE); - } - } - else if (LOWORD(cbitem.lParam) == CLEAR_HISTORY) { - if (MessageBox(nullptr, TranslateT("Are you sure you want to clear status message history?"), TranslateT("Confirm clearing history"), MB_ICONQUESTION | MB_YESNO) == IDYES) - ClearHistory(msgbox_data, cur_sel); - else if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1))) { - wchar_t msg[1024]; - int fcursel = CB_ERR, num_start; - num_start = SendMessage(msgbox_data->recent_cbex, CB_GETCOUNT, 0, 0); - num_start -= msgbox_data->num_def_msgs + 1; - GetDlgItemText(hwndDlg, IDC_EDIT1, msg, _countof(msg)); - fcursel = SendMessage(msgbox_data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)msg); - SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, fcursel, 0); - } - } - else if (LOWORD(cbitem.lParam) == DELETE_SELECTED) { - COMBOBOXEXITEM histitem = {0}; - BOOL scursel = FALSE; - - histitem.mask = CBEIF_LPARAM; - histitem.iItem = msgbox_data->curr_sel_msg; - SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&histitem); - - if (LOWORD(histitem.lParam) == HISTORY_MSG) { - char szSetting[16]; - mir_snprintf(szSetting, "SMsg%d", (int)HIWORD(histitem.lParam)); - db_set_ws(NULL, "SimpleStatusMsg", szSetting, L""); - SendMessage(msgbox_data->recent_cbex, CBEM_DELETEITEM, (WPARAM)msgbox_data->curr_sel_msg, 0); - } - if (LOWORD(histitem.lParam) == PREDEFINED_MSG) { - msgbox_data->m_bPredefChanged = TRUE; - SendMessage(msgbox_data->recent_cbex, CBEM_DELETEITEM, (WPARAM)msgbox_data->curr_sel_msg, 0); - } - - cur_sel = msgbox_data->curr_sel_msg; - while (!scursel) { - if (cur_sel - 1 >= 0) - cur_sel--; - else { - scursel = TRUE; - break; - } - histitem.mask = CBEIF_LPARAM; - histitem.iItem = cur_sel; - SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&histitem); + break; + } + } - if ((LOWORD(histitem.lParam) != CLEAR_HISTORY) && (LOWORD(histitem.lParam) != DELETE_SELECTED) && (LOWORD(histitem.lParam) != ADD_MSG)) - scursel = TRUE; - } - msgbox_data->curr_sel_msg = cur_sel; - SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, (WPARAM)cur_sel, 0); - - histitem.mask = CBEIF_LPARAM | CBEIF_TEXT; - histitem.iItem = cur_sel; - histitem.cchTextMax = _countof(text); - histitem.pszText = text; - - SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&histitem); - if (LOWORD(histitem.lParam) == HISTORY_MSG || LOWORD(histitem.lParam) == PREDEFINED_MSG || LOWORD(histitem.lParam) == DEFAULT_MSG) - { - SetDlgItemText(hwndDlg, IDC_EDIT1, text); - DisplayCharsCount(msgbox_data, hwndDlg); - } - } - else if (LOWORD(cbitem.lParam) == ADD_MSG) { - int sel = AddToPredefined(hwndDlg, msgbox_data); - if (sel != -1) { - SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, (WPARAM)sel, 0); - msgbox_data->curr_sel_msg = sel; - } - else - SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, (WPARAM)msgbox_data->curr_sel_msg, 0); - break; - } - msgbox_data->curr_sel_msg = cur_sel; + if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_BADD)) { + switch (HIWORD(wParam)) { + case BN_CLICKED: + int sel = AddToPredefined(hwndDlg, msgbox_data); + if (sel != -1) { + if (!IsWindowEnabled(msgbox_data->recent_cbex)) + EnableWindow(msgbox_data->recent_cbex, TRUE); + if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BDEL))) + EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), TRUE); + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD))) + EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE); - if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1))) { - SetFocus(GetDlgItem(hwndDlg, IDC_EDIT1)); - SendDlgItemMessage(hwndDlg, IDC_EDIT1, EM_SETSEL, 0, -1); - } - break; - } + SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, (WPARAM)sel, 0); + msgbox_data->curr_sel_msg = sel; } + break; } + } - if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_BADD)) { - switch (HIWORD(wParam)) { - case BN_CLICKED: - { - int sel = AddToPredefined(hwndDlg, msgbox_data); - if (sel != -1) { - if (!IsWindowEnabled(msgbox_data->recent_cbex)) - EnableWindow(msgbox_data->recent_cbex, TRUE); - if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BDEL))) - EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), TRUE); - if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD))) - EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE); + if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_BCLEAR)) { + switch (HIWORD(wParam)) { + case BN_CLICKED: + if (MessageBox(nullptr, TranslateT("Are you sure you want to clear status message history?"), TranslateT("Confirm clearing history"), MB_ICONQUESTION | MB_YESNO) == IDYES) { + ClearHistory(msgbox_data, 0); - SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, (WPARAM)sel, 0); - msgbox_data->curr_sel_msg = sel; + int num_items = SendMessage(msgbox_data->recent_cbex, CB_GETCOUNT, 0, 0); + if (!num_items) { + if (IsWindowEnabled(msgbox_data->recent_cbex)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE); + EnableWindow(msgbox_data->recent_cbex, FALSE); } - break; } + EnableWindow(GetDlgItem(hwndDlg, IDC_BCLEAR), FALSE); } + break; } + } - if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_BCLEAR)) { - switch (HIWORD(wParam)) { - case BN_CLICKED: - if (MessageBox(nullptr, TranslateT("Are you sure you want to clear status message history?"), TranslateT("Confirm clearing history"), MB_ICONQUESTION | MB_YESNO) == IDYES) - { - ClearHistory(msgbox_data, 0); - - int num_items = SendMessage(msgbox_data->recent_cbex, CB_GETCOUNT, 0, 0); - if (!num_items) { - if (IsWindowEnabled(msgbox_data->recent_cbex)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE); - EnableWindow(msgbox_data->recent_cbex, FALSE); - } - } - EnableWindow(GetDlgItem(hwndDlg, IDC_BCLEAR), FALSE); - } - break; - } - } + if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_BDEL)) { + switch (HIWORD(wParam)) { + case BN_CLICKED: + int cur_sel; + char buff[16]; + int left_items = 0; + COMBOBOXEXITEM histitem = { 0 }; - if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_BDEL)) { - switch (HIWORD(wParam)) { - case BN_CLICKED: - { - int cur_sel; - char buff[16]; - int left_items = 0; - COMBOBOXEXITEM histitem = {0}; + cur_sel = SendMessage(msgbox_data->recent_cbex, CB_GETCURSEL, 0, 0); - cur_sel = SendMessage(msgbox_data->recent_cbex, CB_GETCURSEL, 0, 0); + histitem.mask = CBEIF_LPARAM; + histitem.iItem = msgbox_data->curr_sel_msg; - histitem.mask = CBEIF_LPARAM; - histitem.iItem = msgbox_data->curr_sel_msg; + SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&histitem); - SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&histitem); + if (LOWORD(histitem.lParam) == HISTORY_MSG) { + mir_snprintf(buff, "SMsg%d", (int)HIWORD(histitem.lParam)); + db_set_ws(NULL, "SimpleStatusMsg", buff, L""); + } + else if (LOWORD(histitem.lParam) == PREDEFINED_MSG) + msgbox_data->m_bPredefChanged = TRUE; + left_items = SendMessage(msgbox_data->recent_cbex, CBEM_DELETEITEM, (WPARAM)msgbox_data->curr_sel_msg, 0); - if (LOWORD(histitem.lParam) == HISTORY_MSG) { - mir_snprintf(buff, "SMsg%d", (int)HIWORD(histitem.lParam)); - db_set_ws(NULL, "SimpleStatusMsg", buff, L""); - } - else if (LOWORD(histitem.lParam) == PREDEFINED_MSG) - msgbox_data->m_bPredefChanged = TRUE; - left_items = SendMessage(msgbox_data->recent_cbex, CBEM_DELETEITEM, (WPARAM)msgbox_data->curr_sel_msg, 0); - - if (!left_items) { - if (IsWindowEnabled(msgbox_data->recent_cbex)) - EnableWindow(msgbox_data->recent_cbex, FALSE); - if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BCLEAR))) - EnableWindow(GetDlgItem(hwndDlg, IDC_BCLEAR), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE); - } - else { - wchar_t text[1024]; - - if (cur_sel - 1 >= 0) - cur_sel--; - msgbox_data->curr_sel_msg = cur_sel; - SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, (WPARAM)cur_sel, 0); - - histitem.mask = CBEIF_LPARAM | CBEIF_TEXT; - histitem.iItem = cur_sel; - histitem.cchTextMax = _countof(text); - histitem.pszText = text; - - SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&histitem); - if (LOWORD(histitem.lParam) == HISTORY_MSG || LOWORD(histitem.lParam) == PREDEFINED_MSG || LOWORD(histitem.lParam) == DEFAULT_MSG) - { - SetDlgItemText(hwndDlg, IDC_EDIT1, text); - DisplayCharsCount(msgbox_data, hwndDlg); - EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), LOWORD(histitem.lParam) == PREDEFINED_MSG ? FALSE : TRUE); - } - } - break; + if (!left_items) { + if (IsWindowEnabled(msgbox_data->recent_cbex)) + EnableWindow(msgbox_data->recent_cbex, FALSE); + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BCLEAR))) + EnableWindow(GetDlgItem(hwndDlg, IDC_BCLEAR), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE); + } + else { + wchar_t text[1024]; + + if (cur_sel - 1 >= 0) + cur_sel--; + msgbox_data->curr_sel_msg = cur_sel; + SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, (WPARAM)cur_sel, 0); + + histitem.mask = CBEIF_LPARAM | CBEIF_TEXT; + histitem.iItem = cur_sel; + histitem.cchTextMax = _countof(text); + histitem.pszText = text; + + SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&histitem); + if (LOWORD(histitem.lParam) == HISTORY_MSG || LOWORD(histitem.lParam) == PREDEFINED_MSG || LOWORD(histitem.lParam) == DEFAULT_MSG) { + SetDlgItemText(hwndDlg, IDC_EDIT1, text); + DisplayCharsCount(msgbox_data, hwndDlg); + EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), LOWORD(histitem.lParam) == PREDEFINED_MSG ? FALSE : TRUE); } } + break; } - break; + } + break; - case DM_SIMPAWAY_SHUTDOWN: - DestroyWindow(hwndDlg); - break; + case DM_SIMPAWAY_SHUTDOWN: + DestroyWindow(hwndDlg); + break; - case DM_SIMPAWAY_CHANGEICONS: - ReleaseIconEx("cross"); - ReleaseIconEx("recent"); - ReleaseIconEx("predef"); - ReleaseIconEx("add"); - ReleaseIconEx("clear"); - msgbox_data->icon[I_ICON_DEL] = LoadIconEx("cross"); - msgbox_data->icon[I_ICON_HIST] = LoadIconEx("recent"); - msgbox_data->icon[I_ICON_MSG] = LoadIconEx("predef"); - msgbox_data->icon[I_ICON_ADD] = LoadIconEx("add"); - msgbox_data->icon[I_ICON_CLEAR] = LoadIconEx("clear"); - if (msgbox_data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) { - for (int i = 0; i < 5; ++i) - ImageList_ReplaceIcon(msgbox_data->other_icons, i, msgbox_data->icon[i]); - } - if ((msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) { - SendDlgItemMessage(hwndDlg, IDC_BADD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)msgbox_data->icon[I_ICON_ADD]); - SendDlgItemMessage(hwndDlg, IDC_BCLEAR, BM_SETIMAGE, IMAGE_ICON, (LPARAM)msgbox_data->icon[I_ICON_CLEAR]); - SendDlgItemMessage(hwndDlg, IDC_BDEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)msgbox_data->icon[I_ICON_DEL]); - } - break; + case DM_SIMPAWAY_CHANGEICONS: + ReleaseIconEx("cross"); + ReleaseIconEx("recent"); + ReleaseIconEx("predef"); + ReleaseIconEx("add"); + ReleaseIconEx("clear"); + msgbox_data->icon[I_ICON_DEL] = LoadIconEx("cross"); + msgbox_data->icon[I_ICON_HIST] = LoadIconEx("recent"); + msgbox_data->icon[I_ICON_MSG] = LoadIconEx("predef"); + msgbox_data->icon[I_ICON_ADD] = LoadIconEx("add"); + msgbox_data->icon[I_ICON_CLEAR] = LoadIconEx("clear"); + if (msgbox_data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) + for (int i = 0; i < 5; ++i) + ImageList_ReplaceIcon(msgbox_data->other_icons, i, msgbox_data->icon[i]); - case WM_DESTROY: - if (msgbox_data == nullptr) - break; + if ((msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) { + SendDlgItemMessage(hwndDlg, IDC_BADD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)msgbox_data->icon[I_ICON_ADD]); + SendDlgItemMessage(hwndDlg, IDC_BCLEAR, BM_SETIMAGE, IMAGE_ICON, (LPARAM)msgbox_data->icon[I_ICON_CLEAR]); + SendDlgItemMessage(hwndDlg, IDC_BDEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)msgbox_data->icon[I_ICON_DEL]); + } + break; + + case WM_DESTROY: + if (msgbox_data == nullptr) + break; { WINDOWPLACEMENT wp; wp.length = sizeof(wp); @@ -1586,7 +1575,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (msgbox_data->m_bPredefChanged) { int i, num_items, new_num_def_msgs = 0; - COMBOBOXEXITEM cbitem = {0}; + COMBOBOXEXITEM cbitem = { 0 }; wchar_t text[1024]; char buff[64]; diff --git a/plugins/SimpleStatusMsg/src/options.cpp b/plugins/SimpleStatusMsg/src/options.cpp index 7ccffc1750..e83297dcad 100644 --- a/plugins/SimpleStatusMsg/src/options.cpp +++ b/plugins/SimpleStatusMsg/src/options.cpp @@ -34,11 +34,9 @@ static LRESULT CALLBACK OptEditBoxSubProc(HWND hwndDlg, UINT uMsg, WPARAM wParam RECT rc;
GetClientRect(hwndDlg, &rc);
- if (pt.x == -1 && pt.y == -1)
- {
+ if (pt.x == -1 && pt.y == -1) {
GetCursorPos(&pt);
- if (!PtInRect(&rc, pt))
- {
+ if (!PtInRect(&rc, pt)) {
pt.x = rc.left + (rc.right - rc.left) / 2;
pt.y = rc.top + (rc.bottom - rc.top) / 2;
}
@@ -46,7 +44,7 @@ static LRESULT CALLBACK OptEditBoxSubProc(HWND hwndDlg, UINT uMsg, WPARAM wParam else
ScreenToClient(hwndDlg, &pt);
- if (PtInRect(&rc, pt))
+ if (PtInRect(&rc, pt))
HandlePopupMenu(hwndDlg, pt, GetDlgItem(GetParent(hwndDlg), IDC_OPTEDIT1));
return 0;
@@ -124,13 +122,10 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l data->status_msg = (struct SingleStatusMsg *)mir_alloc(sizeof(struct SingleStatusMsg)*(accounts->count + 1));
- for (i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
- {
- if (accounts->statusMsgFlags & Proto_Status2Flag(i))
- {
+ for (i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
+ if (accounts->statusMsgFlags & Proto_Status2Flag(i)) {
index = SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_INSERTSTRING, -1, (LPARAM)Clist_GetStatusModeDescription(i, 0));
- if (index != CB_ERR && index != CB_ERRSPACE)
- {
+ if (index != CB_ERR && index != CB_ERRSPACE) {
int j;
char setting[80];
@@ -138,18 +133,17 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l val = db_get_b(NULL, "SimpleStatusMsg", (char *)StatusModeToDbSetting(i, "Flags"), STATUS_DEFAULT);
data->status_msg[0].flags[i - ID_STATUS_ONLINE] = val;
- ptrW text( db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(i, "Default")));
+ ptrW text(db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(i, "Default")));
mir_wstrncpy(data->status_msg[0].msg[i - ID_STATUS_ONLINE], (text == NULL) ? GetDefaultMessage(i) : text, 1024);
- for (j = 0; j < accounts->count; j++)
- {
+ for (j = 0; j < accounts->count; j++) {
auto *pa = accounts->pa[j];
if (!pa->IsEnabled() || !CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) || !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
continue;
mir_snprintf(setting, "%sFlags", pa->szModuleName);
val = db_get_b(NULL, "SimpleStatusMsg", (char *)StatusModeToDbSetting(i, setting), STATUS_DEFAULT);
- data->status_msg[j+1].flags[i-ID_STATUS_ONLINE] = val;
+ data->status_msg[j + 1].flags[i - ID_STATUS_ONLINE] = val;
mir_snprintf(setting, "%sDefault", pa->szModuleName);
text = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(i, setting));
mir_wstrncpy(data->status_msg[j + 1].msg[i - ID_STATUS_ONLINE], (text == NULL) ? GetDefaultMessage(i) : text, 1024);
@@ -160,8 +154,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_SETCURSEL, 0, 0);
data->proto_msg = (struct SingleProtoMsg *)mir_alloc(sizeof(struct SingleProtoMsg)*(accounts->count + 1));
- if (!data->proto_msg)
- {
+ if (!data->proto_msg) {
// TODO not really needed?
EnableWindow(GetDlgItem(hwndDlg, IDC_CBOPTPROTO), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_BOPTPROTO), FALSE);
@@ -171,16 +164,14 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_ROPTPROTO4), FALSE);
data->proto_ok = FALSE;
}
- else
- {
+ else {
char setting[64];
data->proto_ok = TRUE;
index = SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_ADDSTRING, 0, (LPARAM)TranslateT("Global status change"));
- if (index != CB_ERR && index != CB_ERRSPACE)
- {
+ if (index != CB_ERR && index != CB_ERRSPACE) {
data->proto_msg[0].msg = nullptr;
val = db_get_b(NULL, "SimpleStatusMsg", "ProtoFlags", PROTO_DEFAULT);
@@ -189,37 +180,33 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_SETITEMDATA, (WPARAM)index, 0);
}
- for (i = 0; i < accounts->count; ++i)
- {
+ for (i = 0; i < accounts->count; ++i) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled()
|| !CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0)
- || !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
- {
- data->proto_msg[i+1].msg = nullptr;
+ || !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) {
+ data->proto_msg[i + 1].msg = nullptr;
continue;
}
index = SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_ADDSTRING, 0, (LPARAM)pa->tszAccountName);
// SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_SETITEMDATA, index, (LPARAM)i + 1);
- if (index != CB_ERR && index != CB_ERRSPACE)
- {
+ if (index != CB_ERR && index != CB_ERRSPACE) {
mir_snprintf(setting, "Proto%sDefault", pa->szModuleName);
- data->proto_msg[i+1].msg = db_get_wsa(NULL, "SimpleStatusMsg", setting);
+ data->proto_msg[i + 1].msg = db_get_wsa(NULL, "SimpleStatusMsg", setting);
mir_snprintf(setting, "Proto%sFlags", pa->szModuleName);
val = db_get_b(NULL, "SimpleStatusMsg", setting, PROTO_DEFAULT);
- data->proto_msg[i+1].flags = val;
+ data->proto_msg[i + 1].flags = val;
mir_snprintf(setting, "Proto%sMaxLen", pa->szModuleName);
val = db_get_w(NULL, "SimpleStatusMsg", setting, 1024);
- data->proto_msg[i+1].max_length = val;
+ data->proto_msg[i + 1].max_length = val;
SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_SETITEMDATA, (WPARAM)index, (LPARAM)i + 1);
}
}
- if (accounts->statusMsgCount == 1)
- {
+ if (accounts->statusMsgCount == 1) {
EnableWindow(GetDlgItem(hwndDlg, IDC_BOPTPROTO), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CBOPTPROTO), FALSE);
SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_SETCURSEL, 1, 0);
@@ -232,13 +219,11 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l if (db_get_b(NULL, "SimpleStatusMsg", "PutDefInList", 0))
CheckDlgButton(hwndDlg, IDC_COPTMSG2, BST_CHECKED);
- if (ServiceExists(MS_VARS_FORMATSTRING))
- {
- HICON hIcon=nullptr;
- char *szTipInfo=nullptr;
+ if (ServiceExists(MS_VARS_FORMATSTRING)) {
+ HICON hIcon = nullptr;
+ char *szTipInfo = nullptr;
- if (ServiceExists(MS_VARS_GETSKINITEM))
- {
+ if (ServiceExists(MS_VARS_GETSKINITEM)) {
hIcon = (HICON)CallService(MS_VARS_GETSKINITEM, 0, VSI_HELPICON);
szTipInfo = (char *)CallService(MS_VARS_GETSKINITEM, 0, VSI_HELPTIPTEXT);
}
@@ -261,8 +246,8 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l }
case WM_COMMAND:
- if ( ( (HIWORD(wParam) == BN_CLICKED) || /*(HIWORD(wParam) == EN_KILLFOCUS) ||*/ (HIWORD(wParam) == EN_CHANGE)
- || ( (HIWORD(wParam) == CBN_SELCHANGE) && (LOWORD(wParam) != IDC_CBOPTPROTO) && (LOWORD(wParam) != IDC_CBOPTSTATUS))
+ if (((HIWORD(wParam) == BN_CLICKED) || /*(HIWORD(wParam) == EN_KILLFOCUS) ||*/ (HIWORD(wParam) == EN_CHANGE)
+ || ((HIWORD(wParam) == CBN_SELCHANGE) && (LOWORD(wParam) != IDC_CBOPTPROTO) && (LOWORD(wParam) != IDC_CBOPTSTATUS))
) && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
switch (LOWORD(wParam)) {
@@ -288,8 +273,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l break;
case IDC_CBOPTPROTO:
- switch (HIWORD(wParam))
- {
+ switch (HIWORD(wParam)) {
case CBN_SELCHANGE:
case CBN_SELENDOK:
{
@@ -297,8 +281,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l int i = SendMessage((HWND)lParam, CB_GETITEMDATA, (WPARAM)SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0), 0);
- if (i == 0)
- {
+ if (i == 0) {
EnableWindow(GetDlgItem(hwndDlg, IDC_MAXLENGTH), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_EMAXLENGTH), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_SMAXLENGTH), FALSE);
@@ -311,8 +294,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l else if (data->proto_msg[i].flags & PROTO_NOCHANGE)
CheckRadioButton(hwndDlg, IDC_ROPTPROTO1, IDC_ROPTPROTO4, IDC_ROPTPROTO2);
}
- else
- {
+ else {
EnableWindow(GetDlgItem(hwndDlg, IDC_MAXLENGTH), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_EMAXLENGTH), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_SMAXLENGTH), TRUE);
@@ -331,8 +313,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l }
if (data->proto_msg[i].flags & PROTO_NO_MSG || data->proto_msg[i].flags & PROTO_THIS_MSG
- || data->proto_msg[i].flags & PROTO_NOCHANGE)
- {
+ || data->proto_msg[i].flags & PROTO_NOCHANGE) {
EnableWindow(GetDlgItem(hwndDlg, IDC_CBOPTSTATUS), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_BOPTSTATUS), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_COPTMSG1), FALSE);
@@ -342,14 +323,12 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_ROPTMSG3), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_ROPTMSG5), FALSE);
- if (data->proto_msg[i].flags & PROTO_NO_MSG || data->proto_msg[i].flags & PROTO_NOCHANGE)
- {
+ if (data->proto_msg[i].flags & PROTO_NO_MSG || data->proto_msg[i].flags & PROTO_NOCHANGE) {
EnableWindow(GetDlgItem(hwndDlg, IDC_ROPTMSG4), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
}
- else
- {
+ else {
EnableWindow(GetDlgItem(hwndDlg, IDC_ROPTMSG4), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), TRUE);
@@ -357,8 +336,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_COPTMSG2), FALSE);
}
- else
- {
+ else {
EnableWindow(GetDlgItem(hwndDlg, IDC_CBOPTSTATUS), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_BOPTSTATUS), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_COPTMSG1), TRUE);
@@ -375,13 +353,11 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_COPTMSG2), TRUE);
}
- if (i)
- {
+ if (i) {
k = i - 1;
status_modes = CallProtoService(accounts->pa[k]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
}
- else
- {
+ else {
k = 0;
status_modes = accounts->statusMsgFlags;
}
@@ -389,23 +365,19 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l int j = SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETCURSEL, 0, 0), 0);
SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_RESETCONTENT, 0, 0);
- for (l=ID_STATUS_ONLINE; l<=ID_STATUS_OUTTOLUNCH; l++)
- {
+ for (l = ID_STATUS_ONLINE; l <= ID_STATUS_OUTTOLUNCH; l++) {
int index;
- if (status_modes & Proto_Status2Flag(l))
- {
+ if (status_modes & Proto_Status2Flag(l)) {
index = SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_INSERTSTRING, -1, (LPARAM)Clist_GetStatusModeDescription(l, 0));
- if (index != CB_ERR && index != CB_ERRSPACE)
- {
+ if (index != CB_ERR && index != CB_ERRSPACE) {
SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_SETITEMDATA, (WPARAM)index, (LPARAM)l - ID_STATUS_ONLINE);
- if (j == l-ID_STATUS_ONLINE)
- newindex=index;
+ if (j == l - ID_STATUS_ONLINE)
+ newindex = index;
}
}
}
- if (!newindex)
- {
+ if (!newindex) {
SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_SETCURSEL, 0, 0);
j = SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETCURSEL, 0, 0), 0);
}
@@ -417,32 +389,27 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l else
CheckDlgButton(hwndDlg, IDC_COPTMSG1, BST_UNCHECKED);
- if (data->proto_msg[i].flags & PROTO_THIS_MSG)
- {
+ if (data->proto_msg[i].flags & PROTO_THIS_MSG) {
CheckRadioButton(hwndDlg, IDC_ROPTMSG1, IDC_ROPTMSG5, IDC_ROPTMSG4);
if (data->proto_msg[i].msg)
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, data->proto_msg[i].msg);
else
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
}
- else
- {
- if (data->status_msg[i].flags[j] & STATUS_EMPTY_MSG)
- {
+ else {
+ if (data->status_msg[i].flags[j] & STATUS_EMPTY_MSG) {
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
CheckRadioButton(hwndDlg, IDC_ROPTMSG1, IDC_ROPTMSG5, IDC_ROPTMSG1);
}
- else if (data->status_msg[i].flags[j] & STATUS_DEFAULT_MSG)
- {
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, GetDefaultMessage(j+ID_STATUS_ONLINE));
+ else if (data->status_msg[i].flags[j] & STATUS_DEFAULT_MSG) {
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, GetDefaultMessage(j + ID_STATUS_ONLINE));
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
CheckRadioButton(hwndDlg, IDC_ROPTMSG1, IDC_ROPTMSG5, IDC_ROPTMSG2);
}
- else if (data->status_msg[i].flags[j] & STATUS_LAST_MSG)
- {
+ else if (data->status_msg[i].flags[j] & STATUS_LAST_MSG) {
char setting[80];
if (i)
mir_snprintf(setting, "Last%sMsg", accounts->pa[k]->szModuleName);
@@ -451,11 +418,9 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
char *szSetting = db_get_sa(NULL, "SimpleStatusMsg", setting);
- if (szSetting)
- {
+ if (szSetting) {
wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
- if (tszStatusMsg && mir_wstrlen(tszStatusMsg))
- {
+ if (tszStatusMsg && mir_wstrlen(tszStatusMsg)) {
if (tszStatusMsg && mir_wstrlen(tszStatusMsg))
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
@@ -467,23 +432,19 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
CheckRadioButton(hwndDlg, IDC_ROPTMSG1, IDC_ROPTMSG5, IDC_ROPTMSG3);
}
- else if (data->status_msg[i].flags[j] & STATUS_THIS_MSG)
- {
- if (data->proto_msg[i].flags & PROTO_NO_MSG || data->proto_msg[i].flags & PROTO_NOCHANGE)
- {
+ else if (data->status_msg[i].flags[j] & STATUS_THIS_MSG) {
+ if (data->proto_msg[i].flags & PROTO_NO_MSG || data->proto_msg[i].flags & PROTO_NOCHANGE) {
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
}
- else
- {
+ else {
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), TRUE);
}
CheckRadioButton(hwndDlg, IDC_ROPTMSG1, IDC_ROPTMSG5, IDC_ROPTMSG4);
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, data->status_msg[i].msg[j]);
}
- else if (data->status_msg[i].flags[j] & STATUS_LAST_STATUS_MSG)
- {
+ else if (data->status_msg[i].flags[j] & STATUS_LAST_STATUS_MSG) {
char setting[80];
if (i)
@@ -492,8 +453,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l mir_snprintf(setting, "Msg");
wchar_t *tszStatusMsg = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(j + ID_STATUS_ONLINE, setting));
- if (tszStatusMsg)
- {
+ if (tszStatusMsg) {
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
mir_free(tszStatusMsg);
}
@@ -522,8 +482,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l data->proto_msg[i].flags = 0;
- if ((LOWORD(wParam) == IDC_ROPTPROTO2) || (LOWORD(wParam) == IDC_ROPTPROTO4))
- {
+ if ((LOWORD(wParam) == IDC_ROPTPROTO2) || (LOWORD(wParam) == IDC_ROPTPROTO4)) {
data->proto_msg[i].flags |= (LOWORD(wParam) == IDC_ROPTPROTO4) ? PROTO_NO_MSG : PROTO_NOCHANGE;
EnableWindow(GetDlgItem(hwndDlg, IDC_CBOPTSTATUS), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_BOPTSTATUS), FALSE);
@@ -537,8 +496,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_COPTMSG2), FALSE);
}
- else if (LOWORD(wParam) == IDC_ROPTPROTO3)
- {
+ else if (LOWORD(wParam) == IDC_ROPTPROTO3) {
data->proto_msg[i].flags |= PROTO_THIS_MSG;
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), TRUE);
@@ -559,8 +517,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_COPTMSG2), FALSE);
}
- else if (LOWORD(wParam) == IDC_ROPTPROTO1)
- {
+ else if (LOWORD(wParam) == IDC_ROPTPROTO1) {
data->proto_msg[i].flags |= PROTO_POPUPDLG;
EnableWindow(GetDlgItem(hwndDlg, IDC_CBOPTSTATUS), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_BOPTSTATUS), TRUE);
@@ -575,38 +532,32 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_COPTMSG2), TRUE);
}
- if (LOWORD(wParam) != IDC_ROPTPROTO3)
- {
- if (data->status_msg[i].flags[j] & STATUS_EMPTY_MSG)
- {
+ if (LOWORD(wParam) != IDC_ROPTPROTO3) {
+ if (data->status_msg[i].flags[j] & STATUS_EMPTY_MSG) {
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
CheckRadioButton(hwndDlg, IDC_ROPTMSG1, IDC_ROPTMSG5, IDC_ROPTMSG1);
}
- else if (data->status_msg[i].flags[j] & STATUS_DEFAULT_MSG)
- {
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, GetDefaultMessage(j+ID_STATUS_ONLINE));
+ else if (data->status_msg[i].flags[j] & STATUS_DEFAULT_MSG) {
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, GetDefaultMessage(j + ID_STATUS_ONLINE));
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
CheckRadioButton(hwndDlg, IDC_ROPTMSG1, IDC_ROPTMSG5, IDC_ROPTMSG2);
}
- else if (data->status_msg[i].flags[j] & STATUS_LAST_MSG)
- {
+ else if (data->status_msg[i].flags[j] & STATUS_LAST_MSG) {
char setting[80];
if (i)
- mir_snprintf(setting, "Last%sMsg", accounts->pa[i-1]->szModuleName);
+ mir_snprintf(setting, "Last%sMsg", accounts->pa[i - 1]->szModuleName);
else
mir_snprintf(setting, "LastMsg");
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
char *szSetting = db_get_sa(NULL, "SimpleStatusMsg", setting);
- if (szSetting != nullptr)
- {
+ if (szSetting != nullptr) {
wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
- if (tszStatusMsg)
- {
+ if (tszStatusMsg) {
if (tszStatusMsg[0])
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
mir_free(tszStatusMsg);
@@ -617,33 +568,28 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
CheckRadioButton(hwndDlg, IDC_ROPTMSG1, IDC_ROPTMSG5, IDC_ROPTMSG3);
}
- else if (data->status_msg[i].flags[j] & STATUS_THIS_MSG)
- {
- if ((LOWORD(wParam) == IDC_ROPTPROTO2) || (LOWORD(wParam) == IDC_ROPTPROTO4))
- {
+ else if (data->status_msg[i].flags[j] & STATUS_THIS_MSG) {
+ if ((LOWORD(wParam) == IDC_ROPTPROTO2) || (LOWORD(wParam) == IDC_ROPTPROTO4)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
}
- else
- {
+ else {
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), TRUE);
}
CheckRadioButton(hwndDlg, IDC_ROPTMSG1, IDC_ROPTMSG5, IDC_ROPTMSG4);
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, data->status_msg[i].msg[j]);
}
- else if (data->status_msg[i].flags[j] & STATUS_LAST_STATUS_MSG)
- {
+ else if (data->status_msg[i].flags[j] & STATUS_LAST_STATUS_MSG) {
char setting[80];
if (i)
- mir_snprintf(setting, "%sMsg", accounts->pa[i-1]->szModuleName);
+ mir_snprintf(setting, "%sMsg", accounts->pa[i - 1]->szModuleName);
else
mir_snprintf(setting, "Msg");
wchar_t *tszStatusMsg = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(j + ID_STATUS_ONLINE, setting));
- if (tszStatusMsg != nullptr)
- {
+ if (tszStatusMsg != nullptr) {
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
mir_free(tszStatusMsg);
}
@@ -673,35 +619,30 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l else
CheckDlgButton(hwndDlg, IDC_COPTMSG1, BST_UNCHECKED);
- if (data->status_msg[j].flags[i] & STATUS_EMPTY_MSG)
- {
+ if (data->status_msg[j].flags[i] & STATUS_EMPTY_MSG) {
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
CheckRadioButton(hwndDlg, IDC_ROPTMSG1, IDC_ROPTMSG5, IDC_ROPTMSG1);
}
- else if (data->status_msg[j].flags[i] & STATUS_DEFAULT_MSG)
- {
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, GetDefaultMessage(i+ID_STATUS_ONLINE));
+ else if (data->status_msg[j].flags[i] & STATUS_DEFAULT_MSG) {
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, GetDefaultMessage(i + ID_STATUS_ONLINE));
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
CheckRadioButton(hwndDlg, IDC_ROPTMSG1, IDC_ROPTMSG5, IDC_ROPTMSG2);
}
- else if (data->status_msg[j].flags[i] & STATUS_LAST_MSG)
- {
+ else if (data->status_msg[j].flags[i] & STATUS_LAST_MSG) {
char setting[80];
if (j)
- mir_snprintf(setting, "Last%sMsg", accounts->pa[j-1]->szModuleName);
+ mir_snprintf(setting, "Last%sMsg", accounts->pa[j - 1]->szModuleName);
else
mir_snprintf(setting, "LastMsg");
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
char *szSetting = db_get_sa(NULL, "SimpleStatusMsg", setting);
- if (szSetting != nullptr)
- {
+ if (szSetting != nullptr) {
wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
- if (tszStatusMsg)
- {
+ if (tszStatusMsg) {
if (tszStatusMsg[0])
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
mir_free(tszStatusMsg);
@@ -712,25 +653,22 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
CheckRadioButton(hwndDlg, IDC_ROPTMSG1, IDC_ROPTMSG5, IDC_ROPTMSG3);
}
- else if (data->status_msg[j].flags[i] & STATUS_THIS_MSG)
- {
+ else if (data->status_msg[j].flags[i] & STATUS_THIS_MSG) {
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), TRUE);
CheckRadioButton(hwndDlg, IDC_ROPTMSG1, IDC_ROPTMSG5, IDC_ROPTMSG4);
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, data->status_msg[j].msg[i]);
}
- else if (data->status_msg[j].flags[i] & STATUS_LAST_STATUS_MSG)
- {
+ else if (data->status_msg[j].flags[i] & STATUS_LAST_STATUS_MSG) {
char setting[80];
if (j)
- mir_snprintf(setting, "%sMsg", accounts->pa[j-1]->szModuleName);
+ mir_snprintf(setting, "%sMsg", accounts->pa[j - 1]->szModuleName);
else
mir_snprintf(setting, "Msg");
wchar_t *tszStatusMsg = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(j + ID_STATUS_ONLINE, setting));
- if (tszStatusMsg != nullptr)
- {
+ if (tszStatusMsg != nullptr) {
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
mir_free(tszStatusMsg);
}
@@ -780,26 +718,23 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l if (IsDlgButtonChecked(hwndDlg, IDC_COPTMSG1) == BST_CHECKED)
data->status_msg[j].flags[i] |= STATUS_SHOW_DLG;
- if (LOWORD(wParam) == IDC_ROPTMSG1)
- {
+ if (LOWORD(wParam) == IDC_ROPTMSG1) {
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
data->status_msg[j].flags[i] |= STATUS_EMPTY_MSG;
}
- else if (LOWORD(wParam) == IDC_ROPTMSG2)
- {
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, GetDefaultMessage(i+ID_STATUS_ONLINE));
+ else if (LOWORD(wParam) == IDC_ROPTMSG2) {
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, GetDefaultMessage(i + ID_STATUS_ONLINE));
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
data->status_msg[j].flags[i] |= STATUS_DEFAULT_MSG;
}
- else if (LOWORD(wParam) == IDC_ROPTMSG3)
- {
+ else if (LOWORD(wParam) == IDC_ROPTMSG3) {
char setting[80];
if (j)
- mir_snprintf(setting, "Last%sMsg", accounts->pa[j-1]->szModuleName);
+ mir_snprintf(setting, "Last%sMsg", accounts->pa[j - 1]->szModuleName);
else
mir_snprintf(setting, "LastMsg");
@@ -807,11 +742,9 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l char *szSetting = db_get_sa(NULL, "SimpleStatusMsg", setting);
- if (szSetting != nullptr)
- {
+ if (szSetting != nullptr) {
wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
- if (tszStatusMsg)
- {
+ if (tszStatusMsg) {
if (tszStatusMsg[0])
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
mir_free(tszStatusMsg);
@@ -823,25 +756,22 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
data->status_msg[j].flags[i] |= STATUS_LAST_MSG;
}
- else if (LOWORD(wParam) == IDC_ROPTMSG4)
- {
+ else if (LOWORD(wParam) == IDC_ROPTMSG4) {
data->status_msg[j].flags[i] |= STATUS_THIS_MSG;
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), TRUE);
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, data->status_msg[j].msg[i]);
}
- else if (LOWORD(wParam) == IDC_ROPTMSG5)
- {
+ else if (LOWORD(wParam) == IDC_ROPTMSG5) {
char setting[80];
if (j)
- mir_snprintf(setting, "%sMsg", accounts->pa[j-1]->szModuleName);
+ mir_snprintf(setting, "%sMsg", accounts->pa[j - 1]->szModuleName);
else
mir_snprintf(setting, "Msg");
wchar_t *tszStatusMsg = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(i + ID_STATUS_ONLINE, setting));
- if (tszStatusMsg != nullptr)
- {
+ if (tszStatusMsg != nullptr) {
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
mir_free(tszStatusMsg);
}
@@ -862,34 +792,27 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l int i = SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETCURSEL, 0, 0), 0);
int j = SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETCURSEL, 0, 0), 0);
- if (HIWORD(wParam) == EN_KILLFOCUS)
- {
+ if (HIWORD(wParam) == EN_KILLFOCUS) {
wchar_t msg[1024];
- if (data->proto_msg[j].flags & PROTO_THIS_MSG)
- {
+ if (data->proto_msg[j].flags & PROTO_THIS_MSG) {
int len = GetDlgItemText(hwndDlg, IDC_OPTEDIT1, msg, _countof(msg));
- if (len > 0)
- {
+ if (len > 0) {
if (data->proto_msg[j].msg == nullptr)
data->proto_msg[j].msg = mir_wstrdup(msg);
- else
- {
+ else {
mir_free(data->proto_msg[j].msg);
data->proto_msg[j].msg = mir_wstrdup(msg);
}
}
- else
- {
- if (data->proto_msg[j].msg != nullptr)
- {
+ else {
+ if (data->proto_msg[j].msg != nullptr) {
mir_free(data->proto_msg[j].msg);
data->proto_msg[j].msg = nullptr;
}
}
}
- else
- {
+ else {
GetDlgItemText(hwndDlg, IDC_OPTEDIT1, msg, _countof(msg));
mir_wstrcpy(data->status_msg[j].msg[i], msg);
}
@@ -898,66 +821,53 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l }
case IDC_VARSHELP:
- variables_showhelp(hwndDlg, IDC_OPTEDIT1, VHF_FULLDLG|VHF_SETLASTSUBJECT, nullptr, nullptr);
+ variables_showhelp(hwndDlg, IDC_OPTEDIT1, VHF_FULLDLG | VHF_SETLASTSUBJECT, nullptr, nullptr);
break;
case IDC_BOPTPROTO:
{
int j = SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETCURSEL, 0, 0), 0);
- if (j)
- {
- for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
- {
- if (accounts->statusMsgFlags & Proto_Status2Flag(i))
- {
- data->status_msg[0].flags[i-ID_STATUS_ONLINE] = data->status_msg[j].flags[i-ID_STATUS_ONLINE];
- if (data->status_msg[j].flags[i-ID_STATUS_ONLINE] & STATUS_THIS_MSG)
- mir_wstrcpy(data->status_msg[0].msg[i-ID_STATUS_ONLINE], data->status_msg[j].msg[i-ID_STATUS_ONLINE]);
+ if (j) {
+ for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
+ if (accounts->statusMsgFlags & Proto_Status2Flag(i)) {
+ data->status_msg[0].flags[i - ID_STATUS_ONLINE] = data->status_msg[j].flags[i - ID_STATUS_ONLINE];
+ if (data->status_msg[j].flags[i - ID_STATUS_ONLINE] & STATUS_THIS_MSG)
+ mir_wstrcpy(data->status_msg[0].msg[i - ID_STATUS_ONLINE], data->status_msg[j].msg[i - ID_STATUS_ONLINE]);
}
}
}
- for (int k = 0; k < accounts->count; k++)
- {
+ for (int k = 0; k < accounts->count; k++) {
auto *pa = accounts->pa[k];
if (!pa->IsEnabled() || !CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) || !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
continue;
- if (k != j - 1)
- {
- data->proto_msg[k+1].flags = data->proto_msg[j].flags;
+ if (k != j - 1) {
+ data->proto_msg[k + 1].flags = data->proto_msg[j].flags;
if (j)
- data->proto_msg[k+1].max_length = data->proto_msg[j].max_length;
+ data->proto_msg[k + 1].max_length = data->proto_msg[j].max_length;
- if (data->proto_msg[j].flags & PROTO_THIS_MSG)
- {
+ if (data->proto_msg[j].flags & PROTO_THIS_MSG) {
size_t len = mir_wstrlen(data->proto_msg[j].msg);
- if (len > 0)
- {
- if (data->proto_msg[k+1].msg == nullptr)
- data->proto_msg[k+1].msg = mir_wstrdup(data->proto_msg[j].msg);
- else
- {
- mir_free(data->proto_msg[k+1].msg);
- data->proto_msg[k+1].msg = mir_wstrdup(data->proto_msg[j].msg);
+ if (len > 0) {
+ if (data->proto_msg[k + 1].msg == nullptr)
+ data->proto_msg[k + 1].msg = mir_wstrdup(data->proto_msg[j].msg);
+ else {
+ mir_free(data->proto_msg[k + 1].msg);
+ data->proto_msg[k + 1].msg = mir_wstrdup(data->proto_msg[j].msg);
}
}
- else
- {
- if (data->proto_msg[k+1].msg != nullptr)
- {
- mir_free(data->proto_msg[k+1].msg);
- data->proto_msg[k+1].msg = nullptr;
+ else {
+ if (data->proto_msg[k + 1].msg != nullptr) {
+ mir_free(data->proto_msg[k + 1].msg);
+ data->proto_msg[k + 1].msg = nullptr;
}
}
}
- else if (data->proto_msg[j].flags & PROTO_POPUPDLG)
- {
- for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
- {
- if (CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(i))
- {
+ else if (data->proto_msg[j].flags & PROTO_POPUPDLG) {
+ for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
+ if (CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(i)) {
data->status_msg[k + 1].flags[i - ID_STATUS_ONLINE] = data->status_msg[j].flags[i - ID_STATUS_ONLINE];
if (data->status_msg[j].flags[i - ID_STATUS_ONLINE] & STATUS_THIS_MSG)
mir_wstrcpy(data->status_msg[k + 1].msg[i - ID_STATUS_ONLINE], data->status_msg[j].msg[i - ID_STATUS_ONLINE]);
@@ -976,14 +886,12 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l int status_modes;
if (j)
- status_modes = CallProtoService(accounts->pa[j-1]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
+ status_modes = CallProtoService(accounts->pa[j - 1]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
else
status_modes = accounts->statusMsgFlags;
- for (int k = ID_STATUS_ONLINE; k <= ID_STATUS_OUTTOLUNCH; k++)
- {
- if (k - ID_STATUS_ONLINE != i && status_modes & Proto_Status2Flag(k))
- {
+ for (int k = ID_STATUS_ONLINE; k <= ID_STATUS_OUTTOLUNCH; k++) {
+ if (k - ID_STATUS_ONLINE != i && status_modes & Proto_Status2Flag(k)) {
data->status_msg[j].flags[k - ID_STATUS_ONLINE] = data->status_msg[j].flags[i];
if (data->status_msg[j].flags[i] & STATUS_THIS_MSG)
mir_wstrcpy(data->status_msg[j].msg[k - ID_STATUS_ONLINE], data->status_msg[j].msg[i]);
@@ -995,18 +903,14 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l break;
case WM_NOTIFY:
- if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY)
- {
+ if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY) {
char szSetting[80];
- for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
- {
- if (accounts->statusMsgFlags & Proto_Status2Flag(i))
- {
+ for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
+ if (accounts->statusMsgFlags & Proto_Status2Flag(i)) {
db_set_ws(NULL, "SRAway", StatusModeToDbSetting(i, "Default"), data->status_msg[0].msg[i - ID_STATUS_ONLINE]);
db_set_b(NULL, "SimpleStatusMsg", StatusModeToDbSetting(i, "Flags"), (BYTE)data->status_msg[0].flags[i - ID_STATUS_ONLINE]);
- for (int j = 0; j < accounts->count; j++)
- {
+ for (int j = 0; j < accounts->count; j++) {
auto *pa = accounts->pa[j];
if (!pa->IsEnabled())
continue;
@@ -1014,8 +918,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
continue;
- if (CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(i))
- {
+ if (CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(i)) {
mir_snprintf(szSetting, "%sDefault", pa->szModuleName);
db_set_ws(NULL, "SRAway", StatusModeToDbSetting(i, szSetting), data->status_msg[j + 1].msg[i - ID_STATUS_ONLINE]);
@@ -1028,12 +931,10 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l db_set_b(NULL, "SimpleStatusMsg", "PutDefInList", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_COPTMSG2) == BST_CHECKED));
- if (data->proto_ok)
- {
+ if (data->proto_ok) {
db_set_b(NULL, "SimpleStatusMsg", "ProtoFlags", (BYTE)data->proto_msg[0].flags);
- for (int i = 0; i < accounts->count; i++)
- {
+ for (int i = 0; i < accounts->count; i++) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled())
continue;
@@ -1045,16 +946,16 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l continue;
mir_snprintf(szSetting, "Proto%sDefault", pa->szModuleName);
- if (data->proto_msg[i+1].msg && (data->proto_msg[i+1].flags & PROTO_THIS_MSG))
- db_set_ws(NULL, "SimpleStatusMsg", szSetting, data->proto_msg[i+1].msg);
+ if (data->proto_msg[i + 1].msg && (data->proto_msg[i + 1].flags & PROTO_THIS_MSG))
+ db_set_ws(NULL, "SimpleStatusMsg", szSetting, data->proto_msg[i + 1].msg);
// else
// db_unset(NULL, "SimpleStatusMsg", szSetting);
mir_snprintf(szSetting, "Proto%sMaxLen", pa->szModuleName);
- db_set_w(NULL, "SimpleStatusMsg", szSetting, (WORD)data->proto_msg[i+1].max_length);
+ db_set_w(NULL, "SimpleStatusMsg", szSetting, (WORD)data->proto_msg[i + 1].max_length);
mir_snprintf(szSetting, "Proto%sFlags", pa->szModuleName);
- db_set_b(NULL, "SimpleStatusMsg", szSetting, (BYTE)data->proto_msg[i+1].flags);
+ db_set_b(NULL, "SimpleStatusMsg", szSetting, (BYTE)data->proto_msg[i + 1].flags);
}
}
RebuildStatusMenu();
@@ -1063,10 +964,8 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l break;
case WM_DESTROY:
- if (data->proto_ok)
- {
- for (int i = 0; i < accounts->count + 1; ++i)
- {
+ if (data->proto_ok) {
+ for (int i = 0; i < accounts->count + 1; ++i) {
if (data->proto_msg[i].msg) // they want to be free, do they?
mir_free(data->proto_msg[i].msg);
}
@@ -1095,13 +994,11 @@ static INT_PTR CALLBACK DlgVariablesOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM CheckDlgButton(hwndDlg, IDC_CNOIDLE, db_get_b(NULL, "SimpleStatusMsg", "NoUpdateOnIdle", 1) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CNOICQREQ, db_get_b(NULL, "SimpleStatusMsg", "NoUpdateOnICQReq", 1) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CLEAVEWINAMP, db_get_b(NULL, "SimpleStatusMsg", "AmpLeaveTitle", 1) ? BST_CHECKED : BST_UNCHECKED);
- if (ServiceExists(MS_VARS_FORMATSTRING))
- {
+ if (ServiceExists(MS_VARS_FORMATSTRING)) {
CheckDlgButton(hwndDlg, IDC_CVARIABLES, db_get_b(NULL, "SimpleStatusMsg", "EnableVariables", 1) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CDATEPARSING, db_get_b(NULL, "SimpleStatusMsg", "ExclDateToken", 0) ? BST_CHECKED : BST_UNCHECKED);
}
- else
- {
+ else {
EnableWindow(GetDlgItem(hwndDlg, IDC_CVARIABLES), FALSE);
}
EnableWindow(GetDlgItem(hwndDlg, IDC_CDATEPARSING), IsDlgButtonChecked(hwndDlg, IDC_CVARIABLES) == BST_CHECKED);
@@ -1122,8 +1019,7 @@ static INT_PTR CALLBACK DlgVariablesOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM }
case WM_COMMAND:
- switch (LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
case IDC_ESECUPDTMSG:
{
if ((HWND)lParam != GetFocus() || HIWORD(wParam) != EN_CHANGE) return 0;
@@ -1145,29 +1041,25 @@ static INT_PTR CALLBACK DlgVariablesOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM break;
case WM_NOTIFY:
- if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY)
- {
+ if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY) {
if (g_uUpdateMsgTimer)
KillTimer(nullptr, g_uUpdateMsgTimer);
int val = SendDlgItemMessage(hwndDlg, IDC_SSECUPDTMSG, UDM_GETPOS, 0, 0);
db_set_w(NULL, "SimpleStatusMsg", "UpdateMsgInt", (WORD)val);
- if (IsDlgButtonChecked(hwndDlg, IDC_CUPDATEMSG) == BST_CHECKED && val)
- {
+ if (IsDlgButtonChecked(hwndDlg, IDC_CUPDATEMSG) == BST_CHECKED && val) {
db_set_b(NULL, "SimpleStatusMsg", "UpdateMsgOn", (BYTE)1);
g_uUpdateMsgTimer = SetTimer(nullptr, 0, val * 1000, (TIMERPROC)UpdateMsgTimerProc);
}
- else
- {
+ else {
db_set_b(NULL, "SimpleStatusMsg", "UpdateMsgOn", (BYTE)0);
}
db_set_b(NULL, "SimpleStatusMsg", "NoUpdateOnIdle", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CNOIDLE) == BST_CHECKED));
db_set_b(NULL, "SimpleStatusMsg", "NoUpdateOnICQReq", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CNOICQREQ) == BST_CHECKED));
db_set_b(NULL, "SimpleStatusMsg", "AmpLeaveTitle", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CLEAVEWINAMP) == BST_CHECKED));
- if (ServiceExists(MS_VARS_FORMATSTRING))
- {
+ if (ServiceExists(MS_VARS_FORMATSTRING)) {
db_set_b(NULL, "SimpleStatusMsg", "EnableVariables", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CVARIABLES) == BST_CHECKED));
db_set_b(NULL, "SimpleStatusMsg", "ExclDateToken", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CDATEPARSING) == BST_CHECKED));
}
@@ -1325,8 +1217,7 @@ static INT_PTR CALLBACK DlgAdvancedOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM w }
case IDC_BOPTHIST:
- if (MessageBox(nullptr, TranslateT("Are you sure you want to clear status message history?"), TranslateT("Confirm clearing history"), MB_ICONQUESTION | MB_YESNO) == IDYES)
- {
+ if (MessageBox(nullptr, TranslateT("Are you sure you want to clear status message history?"), TranslateT("Confirm clearing history"), MB_ICONQUESTION | MB_YESNO) == IDYES) {
if (hwndSAMsgDialog)
DestroyWindow(hwndSAMsgDialog);
@@ -1361,8 +1252,7 @@ static INT_PTR CALLBACK DlgAdvancedOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM w return 0;
case IDC_BOPTDEF:
- if (MessageBox(nullptr, TranslateT("Are you sure you want to clear predefined status messages?"), TranslateT("Confirm clearing predefined"), MB_ICONQUESTION | MB_YESNO) == IDYES)
- {
+ if (MessageBox(nullptr, TranslateT("Are you sure you want to clear predefined status messages?"), TranslateT("Confirm clearing predefined"), MB_ICONQUESTION | MB_YESNO) == IDYES) {
if (hwndSAMsgDialog)
DestroyWindow(hwndSAMsgDialog);
@@ -1429,79 +1319,69 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa switch (uMsg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
-
- data = (struct StatusOptDlgData *)mir_alloc(sizeof(struct StatusOptDlgData));
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)data);
-
- data->status = (int *)mir_alloc(sizeof(int) * accounts->count);
- data->setdelay = (int *)mir_alloc(sizeof(int) * accounts->count);
- for (int i = 0; i < accounts->count; ++i)
- {
- auto *pa = accounts->pa[i];
- if (!pa->IsEnabled() || !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) &~ CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)))
- continue;
-
- int index = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_ADDSTRING, 0, (LPARAM)pa->tszAccountName);
- if (index != LB_ERR && index != LB_ERRSPACE)
- {
- char setting[80];
- mir_snprintf(setting, "Startup%sStatus", pa->szModuleName);
- data->status[i] = db_get_w(NULL, "SimpleStatusMsg", setting, ID_STATUS_CURRENT);
- mir_snprintf(setting, "Set%sStatusDelay", pa->szModuleName);
- data->setdelay[i] = db_get_w(NULL, "SimpleStatusMsg", setting, 300);
- SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_SETITEMDATA, (WPARAM)index, (LPARAM)i);
- }
+ TranslateDialogDefault(hwndDlg);
+
+ data = (struct StatusOptDlgData *)mir_alloc(sizeof(struct StatusOptDlgData));
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)data);
+
+ data->status = (int *)mir_alloc(sizeof(int) * accounts->count);
+ data->setdelay = (int *)mir_alloc(sizeof(int) * accounts->count);
+ for (int i = 0; i < accounts->count; ++i) {
+ auto *pa = accounts->pa[i];
+ if (!pa->IsEnabled() || !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) &~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)))
+ continue;
+
+ int index = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_ADDSTRING, 0, (LPARAM)pa->tszAccountName);
+ if (index != LB_ERR && index != LB_ERRSPACE) {
+ char setting[80];
+ mir_snprintf(setting, "Startup%sStatus", pa->szModuleName);
+ data->status[i] = db_get_w(NULL, "SimpleStatusMsg", setting, ID_STATUS_CURRENT);
+ mir_snprintf(setting, "Set%sStatusDelay", pa->szModuleName);
+ data->setdelay[i] = db_get_w(NULL, "SimpleStatusMsg", setting, 300);
+ SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_SETITEMDATA, (WPARAM)index, (LPARAM)i);
}
- SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_SETCURSEL, 0, 0);
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_LISTPROTO, LBN_SELCHANGE), (LPARAM)GetDlgItem(hwndDlg, IDC_LISTPROTO));
+ }
+ SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_SETCURSEL, 0, 0);
+ SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_LISTPROTO, LBN_SELCHANGE), (LPARAM)GetDlgItem(hwndDlg, IDC_LISTPROTO));
- data->setglobaldelay = db_get_w(NULL, "SimpleStatusMsg", "SetStatusDelay", 300);
+ data->setglobaldelay = db_get_w(NULL, "SimpleStatusMsg", "SetStatusDelay", 300);
- SendDlgItemMessage(hwndDlg, IDC_SSETSTATUS, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_ESETSTATUS), 0);
- SendDlgItemMessage(hwndDlg, IDC_SSETSTATUS, UDM_SETRANGE32, 0, 9000);
- SendDlgItemMessage(hwndDlg, IDC_ESETSTATUS, EM_LIMITTEXT, 4, 0);
+ SendDlgItemMessage(hwndDlg, IDC_SSETSTATUS, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_ESETSTATUS), 0);
+ SendDlgItemMessage(hwndDlg, IDC_SSETSTATUS, UDM_SETRANGE32, 0, 9000);
+ SendDlgItemMessage(hwndDlg, IDC_ESETSTATUS, EM_LIMITTEXT, 4, 0);
- if (!db_get_b(NULL, "SimpleStatusMsg", "GlobalStatusDelay", 1))
- {
- CheckDlgButton(hwndDlg, IDC_SPECSET, BST_CHECKED);
- int i = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETCURSEL, 0, 0), 0);
- SetDlgItemInt(hwndDlg, IDC_ESETSTATUS, data->setdelay[i], FALSE);
- }
- else
- {
+ if (!db_get_b(NULL, "SimpleStatusMsg", "GlobalStatusDelay", 1)) {
+ CheckDlgButton(hwndDlg, IDC_SPECSET, BST_CHECKED);
+ int i = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETCURSEL, 0, 0), 0);
+ SetDlgItemInt(hwndDlg, IDC_ESETSTATUS, data->setdelay[i], FALSE);
+ }
+ else {
+ CheckDlgButton(hwndDlg, IDC_SPECSET, BST_UNCHECKED);
+ SetDlgItemInt(hwndDlg, IDC_ESETSTATUS, data->setglobaldelay, FALSE);
+ }
+
+ if (db_get_b(NULL, "SimpleStatusMsg", "StartupPopupDlg", 1)) {
+ CheckDlgButton(hwndDlg, IDC_POPUPDLG, BST_CHECKED);
+ if (IsDlgButtonChecked(hwndDlg, IDC_SPECSET) == BST_CHECKED) {
CheckDlgButton(hwndDlg, IDC_SPECSET, BST_UNCHECKED);
SetDlgItemInt(hwndDlg, IDC_ESETSTATUS, data->setglobaldelay, FALSE);
}
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SPECSET), FALSE);
+ }
+ else CheckDlgButton(hwndDlg, IDC_POPUPDLG, BST_UNCHECKED);
- if (db_get_b(NULL, "SimpleStatusMsg", "StartupPopupDlg", 1))
- {
- CheckDlgButton(hwndDlg, IDC_POPUPDLG, BST_CHECKED);
- if (IsDlgButtonChecked(hwndDlg, IDC_SPECSET) == BST_CHECKED)
- {
- CheckDlgButton(hwndDlg, IDC_SPECSET, BST_UNCHECKED);
- SetDlgItemInt(hwndDlg, IDC_ESETSTATUS, data->setglobaldelay, FALSE);
- }
- EnableWindow(GetDlgItem(hwndDlg, IDC_SPECSET), FALSE);
- }
- else
- CheckDlgButton(hwndDlg, IDC_POPUPDLG, BST_UNCHECKED);
-
- if (accounts->statusCount == 1 && accounts->statusMsgCount == 1)
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_SPECSET), FALSE);
- CheckDlgButton(hwndDlg, IDC_SPECSET, BST_UNCHECKED); //should work like when checked, but should not be checked
- int i = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETCURSEL, 0, 0), 0);
- SetDlgItemInt(hwndDlg, IDC_ESETSTATUS, data->setdelay[i], FALSE);
- }
-
- return TRUE;
+ if (accounts->statusCount == 1 && accounts->statusMsgCount == 1) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SPECSET), FALSE);
+ CheckDlgButton(hwndDlg, IDC_SPECSET, BST_UNCHECKED); //should work like when checked, but should not be checked
+ int i = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETCURSEL, 0, 0), 0);
+ SetDlgItemInt(hwndDlg, IDC_ESETSTATUS, data->setdelay[i], FALSE);
}
+ return TRUE;
+
case WM_COMMAND:
- if ( ( (HIWORD(wParam) == BN_CLICKED) || /*(HIWORD(wParam) == EN_KILLFOCUS) ||*/ (HIWORD(wParam) == EN_CHANGE)
- || ( (HIWORD(wParam) == LBN_SELCHANGE) && (LOWORD(wParam) != IDC_LISTPROTO))
+ if (((HIWORD(wParam) == BN_CLICKED) || (HIWORD(wParam) == EN_CHANGE)
+ || ((HIWORD(wParam) == LBN_SELCHANGE) && (LOWORD(wParam) != IDC_LISTPROTO))
) && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
switch (LOWORD(wParam)) {
@@ -1517,8 +1397,7 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa SetDlgItemInt(hwndDlg, IDC_ESETSTATUS, 0, FALSE);
val = GetDlgItemInt(hwndDlg, IDC_ESETSTATUS, &translated, FALSE);
- if (IsDlgButtonChecked(hwndDlg, IDC_SPECSET) == BST_CHECKED || (accounts->statusCount == 1 && accounts->statusMsgCount == 1))
- {
+ if (IsDlgButtonChecked(hwndDlg, IDC_SPECSET) == BST_CHECKED || (accounts->statusCount == 1 && accounts->statusMsgCount == 1)) {
int i = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETCURSEL, 0, 0), 0);
data->setdelay[i] = val;
}
@@ -1530,11 +1409,9 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa break;
case IDC_SPECSET:
- switch (HIWORD(wParam))
- {
+ switch (HIWORD(wParam)) {
case BN_CLICKED:
- if (SendMessage((HWND)lParam, BM_GETCHECK, 0, 0) == BST_CHECKED || (accounts->statusCount == 1 && accounts->statusMsgCount == 1))
- {
+ if (SendMessage((HWND)lParam, BM_GETCHECK, 0, 0) == BST_CHECKED || (accounts->statusCount == 1 && accounts->statusMsgCount == 1)) {
int i = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETCURSEL, 0, 0), 0);
SetDlgItemInt(hwndDlg, IDC_ESETSTATUS, data->setdelay[i], FALSE);
}
@@ -1550,10 +1427,8 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa if (accounts->statusCount == 1 && accounts->statusMsgCount == 1)
break;
- if (SendMessage((HWND)lParam, BM_GETCHECK, 0, 0) == BST_CHECKED)
- {
- if (IsDlgButtonChecked(hwndDlg, IDC_SPECSET) == BST_CHECKED)
- {
+ if (SendMessage((HWND)lParam, BM_GETCHECK, 0, 0) == BST_CHECKED) {
+ if (IsDlgButtonChecked(hwndDlg, IDC_SPECSET) == BST_CHECKED) {
CheckDlgButton(hwndDlg, IDC_SPECSET, BST_UNCHECKED);
SetDlgItemInt(hwndDlg, IDC_ESETSTATUS, data->setglobaldelay, FALSE);
}
@@ -1576,13 +1451,10 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa int status_modes = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0);
SendDlgItemMessage(hwndDlg, IDC_LISTSTATUS, LB_RESETCONTENT, 0, 0);
- for (int l = ID_STATUS_OFFLINE; l <= ID_STATUS_OUTTOLUNCH; l++)
- {
- if (status_modes & Proto_Status2Flag(l) || l == ID_STATUS_OFFLINE)
- {
+ for (int l = ID_STATUS_OFFLINE; l <= ID_STATUS_OUTTOLUNCH; l++) {
+ if (status_modes & Proto_Status2Flag(l) || l == ID_STATUS_OFFLINE) {
int index = SendDlgItemMessage(hwndDlg, IDC_LISTSTATUS, LB_INSERTSTRING, -1, (LPARAM)Clist_GetStatusModeDescription(l, 0));
- if (index != LB_ERR && index != LB_ERRSPACE)
- {
+ if (index != LB_ERR && index != LB_ERRSPACE) {
SendDlgItemMessage(hwndDlg, IDC_LISTSTATUS, LB_SETITEMDATA, (WPARAM)index, (LPARAM)l - ID_STATUS_OFFLINE);
if (data->status[i] == l)
newindex = index;
@@ -1591,8 +1463,7 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa }
int index = SendDlgItemMessage(hwndDlg, IDC_LISTSTATUS, LB_INSERTSTRING, -1, (LPARAM)TranslateT("<last status>"));
- if (index != LB_ERR && index != LB_ERRSPACE)
- {
+ if (index != LB_ERR && index != LB_ERRSPACE) {
SendDlgItemMessage(hwndDlg, IDC_LISTSTATUS, LB_SETITEMDATA, (WPARAM)index, (LPARAM)ID_STATUS_CURRENT - ID_STATUS_OFFLINE);
if (data->status[i] == ID_STATUS_CURRENT)
newindex = index;
@@ -1610,22 +1481,18 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa case IDC_LISTSTATUS:
switch (HIWORD(wParam)) {
case LBN_SELCHANGE:
- {
- int i = SendMessage((HWND)lParam, LB_GETITEMDATA, (WPARAM)SendMessage((HWND)lParam, LB_GETCURSEL, 0, 0), 0);
- int j = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETCURSEL, 0, 0), 0);
- data->status[j] = i + ID_STATUS_OFFLINE;
- break;
- }
+ int i = SendMessage((HWND)lParam, LB_GETITEMDATA, (WPARAM)SendMessage((HWND)lParam, LB_GETCURSEL, 0, 0), 0);
+ int j = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETCURSEL, 0, 0), 0);
+ data->status[j] = i + ID_STATUS_OFFLINE;
+ break;
}
break;
}
break;
case WM_NOTIFY:
- if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY)
- {
- for (int i = 0; i < accounts->count; i++)
- {
+ if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY) {
+ for (int i = 0; i < accounts->count; i++) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled() || !(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)))
continue;
diff --git a/plugins/SimpleStatusMsg/src/version.h b/plugins/SimpleStatusMsg/src/version.h index 2b0c1c8398..10aad3945c 100644 --- a/plugins/SimpleStatusMsg/src/version.h +++ b/plugins/SimpleStatusMsg/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 1 #define __MINOR_VERSION 9 #define __RELEASE_NUM 0 -#define __BUILD_NUM 6 +#define __BUILD_NUM 7 #include <stdver.h> |