summaryrefslogtreecommitdiff
path: root/plugins/SimpleStatusMsg
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2016-05-06 22:59:15 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2016-05-06 22:59:15 +0000
commit3f350883e214aaa6c2941ade516468ed7bf1f449 (patch)
tree0b82056956855ffc8cb8aca59f7de02e06d011e7 /plugins/SimpleStatusMsg
parentf11a71a26ce00c5fc5cdd4350b1303ed7bed9ad5 (diff)
SimpleStatusMsg: -some cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@16810 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SimpleStatusMsg')
-rw-r--r--plugins/SimpleStatusMsg/src/main.cpp273
-rw-r--r--plugins/SimpleStatusMsg/src/msgbox.cpp93
-rw-r--r--plugins/SimpleStatusMsg/src/options.cpp224
3 files changed, 249 insertions, 341 deletions
diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp
index 3032ecf36c..6e89652e1f 100644
--- a/plugins/SimpleStatusMsg/src/main.cpp
+++ b/plugins/SimpleStatusMsg/src/main.cpp
@@ -272,12 +272,11 @@ TCHAR* InsertBuiltinVarsIntoMsg(TCHAR *in, const char *szProto, int)
else if (!_tcsnicmp(msg+i, _T("%randmsg%"), 9))
{
char buff[16];
- int k, maxk, k2 = 0;
- DBVARIANT dbv;
+ int k, k2 = 0;
BOOL rmark[25];
for (k = 0; k < _countof(rmark); k++) rmark[k] = FALSE;
- maxk = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10);
+ int maxk = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10);
if (maxk == 0) rmark[0] = TRUE;
while (!rmark[0])
@@ -289,19 +288,17 @@ TCHAR* InsertBuiltinVarsIntoMsg(TCHAR *in, const char *szProto, int)
if (k2 == maxk || k2 > maxk) rmark[0] = TRUE;
mir_snprintf(buff, "SMsg%d", k);
- if (!db_get_ts(NULL, "SimpleStatusMsg", buff, &dbv))
- {
- if (dbv.ptszVal == NULL)
- {
- db_free(&dbv);
- continue;
- }
- mir_tstrcpy(substituteStr, dbv.ptszVal);
- db_free(&dbv);
- }
- else continue;
- if (!mir_tstrlen(substituteStr)) continue;
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SimpleStatusMsg", buff);
+ if (tszStatusMsg == NULL)
+ continue;
+
+ mir_tstrcpy(substituteStr, tszStatusMsg);
+ mir_free(tszStatusMsg);
+
+ if (!mir_tstrlen(substituteStr))
+ continue;
+
if (_tcsstr(substituteStr, _T("%randmsg%")) != NULL || _tcsstr(substituteStr, _T("%randdefmsg%")) != NULL)
{
if (k == maxk) maxk--;
@@ -320,12 +317,11 @@ TCHAR* InsertBuiltinVarsIntoMsg(TCHAR *in, const char *szProto, int)
else if (!_tcsnicmp(msg+i, _T("%randdefmsg%"), 12))
{
char buff[16];
- int k, maxk, k2 = 0;
- DBVARIANT dbv;
+ int k, k2 = 0;
BOOL rmark[25];
for (k = 0; k < _countof(rmark); k++) rmark[k] = FALSE;
- maxk = db_get_w(NULL, "SimpleStatusMsg", "DefMsgCount", 0);
+ int maxk = db_get_w(NULL, "SimpleStatusMsg", "DefMsgCount", 0);
if (maxk == 0) rmark[0] = TRUE;
while (!rmark[0])
@@ -337,19 +333,17 @@ TCHAR* InsertBuiltinVarsIntoMsg(TCHAR *in, const char *szProto, int)
if (k2 == maxk || k2 > maxk) rmark[0] = TRUE;
mir_snprintf(buff, "DefMsg%d", k);
- if (!db_get_ts(NULL, "SimpleStatusMsg", buff, &dbv))
- {
- if (dbv.ptszVal == NULL)
- {
- db_free(&dbv);
- continue;
- }
- mir_tstrcpy(substituteStr, dbv.ptszVal);
- db_free(&dbv);
- }
- else continue;
- if (!mir_tstrlen(substituteStr)) continue;
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SimpleStatusMsg", buff);
+ if (tszStatusMsg == NULL)
+ continue;
+
+ mir_tstrcpy(substituteStr, tszStatusMsg);
+ mir_free(tszStatusMsg);
+
+ if (!mir_tstrlen(substituteStr))
+ continue;
+
if (_tcsstr(substituteStr, _T("%randmsg%")) != NULL || _tcsstr(substituteStr, _T("%randdefmsg%")) != NULL)
{
if (k == maxk) maxk--;
@@ -402,29 +396,24 @@ TCHAR *InsertVarsIntoMsg(TCHAR *tszMsg, const char *szProto, int iStatus, MCONTA
static TCHAR *GetAwayMessageFormat(int iStatus, const char *szProto)
{
- DBVARIANT dbv, dbv2;
- int flags;
char szSetting[80];
TCHAR *format;
mir_snprintf(szSetting, "%sFlags", szProto ? szProto : "");
- flags = db_get_b(NULL, "SimpleStatusMsg", (char *)StatusModeToDbSetting(iStatus, szSetting), STATUS_DEFAULT);
+ int flags = db_get_b(NULL, "SimpleStatusMsg", StatusModeToDbSetting(iStatus, szSetting), STATUS_DEFAULT);
if (flags & STATUS_EMPTY_MSG)
+ {
return mir_tstrdup(_T(""));
-
- if (flags & STATUS_LAST_STATUS_MSG)
+ }
+ else if (flags & STATUS_LAST_STATUS_MSG)
{
if (szProto)
mir_snprintf(szSetting, "%sMsg", szProto);
else
mir_snprintf(szSetting, "Msg");
- if (db_get_ts(NULL, "SRAway", StatusModeToDbSetting(iStatus, szSetting), &dbv))
- return NULL; //mir_tstrdup(_T(""));
-
- format = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
+ format = db_get_tsa(NULL, "SRAway", StatusModeToDbSetting(iStatus, szSetting));
}
else if (flags & STATUS_LAST_MSG)
{
@@ -433,18 +422,12 @@ static TCHAR *GetAwayMessageFormat(int iStatus, const char *szProto)
else
mir_snprintf(szSetting, "LastMsg");
- if (db_get(NULL, "SimpleStatusMsg", szSetting, &dbv2))
+ char *szLastMsg = db_get_sa(NULL, "SimpleStatusMsg", szSetting);
+ if (szLastMsg == NULL)
return NULL; //mir_tstrdup(_T(""));
- if (db_get_ts(NULL, "SimpleStatusMsg", dbv2.pszVal, &dbv))
- {
- db_free(&dbv2);
- return NULL; //mir_tstrdup(_T(""));
- }
-
- format = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- db_free(&dbv2);
+ format = db_get_tsa(NULL, "SimpleStatusMsg", szLastMsg);
+ mir_free(szLastMsg);
}
else if (flags & STATUS_THIS_MSG)
{
@@ -453,11 +436,9 @@ static TCHAR *GetAwayMessageFormat(int iStatus, const char *szProto)
else
mir_snprintf(szSetting, "Default");
- if (db_get_ts(NULL, "SRAway", StatusModeToDbSetting(iStatus, szSetting), &dbv))
- return mir_tstrdup(_T(""));
-
- format = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
+ format = db_get_tsa(NULL, "SRAway", StatusModeToDbSetting(iStatus, szSetting));
+ if (format == NULL)
+ format = mir_tstrdup(_T(""));
}
else
format = mir_tstrdup(GetDefaultMessage(iStatus));
@@ -525,25 +506,16 @@ void SaveStatusAsCurrent(const char *szProto, int iStatus)
static TCHAR *GetAwayMessage(int iStatus, const char *szProto, BOOL bInsertVars, MCONTACT hContact)
{
- TCHAR *format = NULL;
+ TCHAR *format;
char szSetting[80];
if ((!iStatus || iStatus == ID_STATUS_CURRENT) && szProto)
{
- DBVARIANT dbv;
mir_snprintf(szSetting, "FCur%sMsg", szProto);
- if (!db_get_ts(NULL, "SimpleStatusMsg", szSetting, &dbv))
- {
- format = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- //else
- // format = mir_tstrdup(_T(""));
+ format = db_get_tsa(NULL, "SimpleStatusMsg", szSetting);
}
else
{
- int flags;
-
if (!iStatus || iStatus == ID_STATUS_CURRENT)
iStatus = GetCurrentStatus(szProto);
@@ -551,7 +523,7 @@ static TCHAR *GetAwayMessage(int iStatus, const char *szProto, BOOL bInsertVars,
return NULL;
mir_snprintf(szSetting, "Proto%sFlags", szProto ? szProto : "");
- flags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT);
+ int flags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT);
//if (flags & PROTO_NO_MSG)
//{
@@ -560,30 +532,20 @@ static TCHAR *GetAwayMessage(int iStatus, const char *szProto, BOOL bInsertVars,
//else
if (flags & PROTO_THIS_MSG)
{
- DBVARIANT dbv;
mir_snprintf(szSetting, "Proto%sDefault", szProto);
- if (!db_get_ts(NULL, "SimpleStatusMsg", szSetting, &dbv))
- {
- format = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- else
+ format = db_get_tsa(NULL, "SimpleStatusMsg", szSetting);
+ if (format == NULL)
format = mir_tstrdup(_T(""));
}
else if (flags & PROTO_NOCHANGE && szProto)
{
- DBVARIANT dbv;
mir_snprintf(szSetting, "FCur%sMsg", szProto);
- if (!db_get_ts(NULL, "SimpleStatusMsg", szSetting, &dbv))
- {
- format = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- //else
- // format = mir_tstrdup(_T(""));
+ format = db_get_tsa(NULL, "SimpleStatusMsg", szSetting);
}
else if (flags & PROTO_POPUPDLG)
format = GetAwayMessageFormat(iStatus, szProto);
+ else
+ format = NULL;
}
#ifdef _DEBUG
log2file("GetAwayMessage(): %s has %s status and \"%S\" status message.", szProto, StatusModeToDbSetting(iStatus, ""), format);
@@ -652,10 +614,8 @@ static void Proto_SetStatus(const char *szProto, int iInitialStatus, int iStatus
int HasProtoStaticStatusMsg(const char *szProto, int iInitialStatus, int iStatus)
{
char szSetting[80];
- int flags;
-
mir_snprintf(szSetting, "Proto%sFlags", szProto);
- flags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT);
+ int flags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT);
if (flags & PROTO_NO_MSG)
{
@@ -666,15 +626,13 @@ int HasProtoStaticStatusMsg(const char *szProto, int iInitialStatus, int iStatus
}
else if (flags & PROTO_THIS_MSG)
{
- DBVARIANT dbv;
- TCHAR *msg;
-
mir_snprintf(szSetting, "Proto%sDefault", szProto);
- if (!db_get_ts(NULL, "SimpleStatusMsg", szSetting, &dbv))
+ TCHAR *szSimpleStatusMsg = db_get_tsa(NULL, "SimpleStatusMsg", szSetting);
+ if (szSimpleStatusMsg != NULL)
{
- SaveMessageToDB(szProto, dbv.ptszVal, TRUE);
- msg = InsertVarsIntoMsg(dbv.ptszVal, szProto, iStatus, NULL);
- db_free(&dbv);
+ SaveMessageToDB(szProto, szSimpleStatusMsg, TRUE);
+ TCHAR *msg = InsertVarsIntoMsg(szSimpleStatusMsg, szProto, iStatus, NULL);
+ mir_free(szSimpleStatusMsg);
Proto_SetStatus(szProto, iInitialStatus, iStatus, msg);
SaveMessageToDB(szProto, msg, FALSE);
mir_free(msg);
@@ -1053,17 +1011,9 @@ int ChangeStatusMessage(WPARAM wParam, LPARAM lParam)
return 1;
}
else if (iProtoFlags & PROTO_NOCHANGE && !bOnStartup) {
- DBVARIANT dbv;
- TCHAR *msg = NULL;
-
mir_snprintf(szSetting, "FCur%sMsg", szProto);
- if (!db_get_ts(NULL, "SimpleStatusMsg", szSetting, &dbv))
- {
- msg = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- //else
- // msg = mir_tstrdup(_T(""));
+ TCHAR *msg = db_get_tsa(NULL, "SimpleStatusMsg", szSetting);
+
#ifdef _DEBUG
log2file("ChangeStatusMessage(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iStatus, ""), msg, szProto);
#endif
@@ -1109,7 +1059,6 @@ int ChangeStatusMessage(WPARAM wParam, LPARAM lParam)
int iProtoFlags = db_get_b(NULL, "SimpleStatusMsg", "ProtoFlags", PROTO_DEFAULT);
if (!bShowDlg || bScreenSaverRunning || (iProtoFlags & PROTO_NOCHANGE && !bOnStartup)) {
- TCHAR *msg = NULL;
for (int i = 0; i < accounts->count; ++i) {
if (!Proto_IsAccountEnabled(accounts->pa[i]))
continue;
@@ -1124,16 +1073,10 @@ int ChangeStatusMessage(WPARAM wParam, LPARAM lParam)
!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
continue;
+ TCHAR *msg;
if (iProtoFlags & PROTO_NOCHANGE) {
- DBVARIANT dbv;
mir_snprintf(szSetting, "FCur%sMsg", accounts->pa[i]->szModuleName);
- if (!db_get_ts(NULL, "SimpleStatusMsg", szSetting, &dbv))
- {
- msg = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- //else
- // msg = mir_tstrdup(_T(""));
+ msg = db_get_tsa(NULL, "SimpleStatusMsg", szSetting);
}
else
msg = GetAwayMessageFormat(iStatus, NULL);
@@ -1141,7 +1084,8 @@ int ChangeStatusMessage(WPARAM wParam, LPARAM lParam)
log2file("ChangeStatusMessage(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iStatus, ""), msg, accounts->pa[i]->szModuleName);
#endif
SetStatusMessage(accounts->pa[i]->szModuleName, iStatus, iStatus, msg, FALSE);
- if (msg) { mir_free(msg); msg = NULL; }
+ if (msg)
+ mir_free(msg);
}
return 1;
}
@@ -1189,9 +1133,8 @@ static int ProcessProtoAck(WPARAM , LPARAM lParam)
int SetStartupStatus(int i)
{
- int flags;
char szSetting[80];
- TCHAR *fmsg = NULL, *msg = NULL;
+ TCHAR *fmsg, *msg = NULL;
int iStatus = GetStartupStatus(accounts->pa[i]->szModuleName);
if (iStatus == ID_STATUS_OFFLINE)
@@ -1205,23 +1148,18 @@ int SetStartupStatus(int i)
}
mir_snprintf(szSetting, "Proto%sFlags", accounts->pa[i]->szModuleName);
- flags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT);
+ int flags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT);
if (flags & PROTO_NO_MSG || flags & PROTO_THIS_MSG)
{
if (HasProtoStaticStatusMsg(accounts->pa[i]->szModuleName, ID_STATUS_OFFLINE, iStatus))
return 0;
+ else
+ fmsg = NULL;
}
else if (flags & PROTO_NOCHANGE)
{
- DBVARIANT dbv;
mir_snprintf(szSetting, "FCur%sMsg", accounts->pa[i]->szModuleName);
- if (!db_get_ts(NULL, "SimpleStatusMsg", szSetting, &dbv))
- {
- fmsg = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- //else
- // fmsg = mir_tstrdup(_T(""));
+ fmsg = db_get_tsa(NULL, "SimpleStatusMsg", szSetting);
}
else
fmsg = GetAwayMessageFormat(iStatus, accounts->pa[i]->szModuleName);
@@ -1247,13 +1185,13 @@ int SetStartupStatus(int i)
VOID CALLBACK SetStartupStatusGlobal(HWND hwnd, UINT, UINT_PTR idEvent, DWORD)
{
- int prev_status_mode = -1, status_mode, temp_status_mode = ID_STATUS_OFFLINE, i;
- BOOL globalstatus = TRUE;
+ int prev_status_mode = -1, status_mode = 0, temp_status_mode = ID_STATUS_OFFLINE;
+ bool globalstatus = true;
KillTimer(hwnd, idEvent);
// is global status mode going to be set?
- for (i = 0; i < accounts->count; ++i)
+ for (int i = 0; i < accounts->count; ++i)
{
if (!Proto_IsAccountEnabled(accounts->pa[i]))
continue;
@@ -1268,7 +1206,7 @@ VOID CALLBACK SetStartupStatusGlobal(HWND hwnd, UINT, UINT_PTR idEvent, DWORD)
if (status_mode != prev_status_mode && prev_status_mode != -1)
{
- globalstatus = FALSE;
+ globalstatus = false;
break;
}
@@ -1288,7 +1226,7 @@ VOID CALLBACK SetStartupStatusGlobal(HWND hwnd, UINT, UINT_PTR idEvent, DWORD)
return;
}
- for (i = 0; i < accounts->count; ++i)
+ for (int i = 0; i < accounts->count; ++i)
{
if (!Proto_IsAccountEnabled(accounts->pa[i]))
continue;
@@ -1302,10 +1240,10 @@ VOID CALLBACK SetStartupStatusGlobal(HWND hwnd, UINT, UINT_PTR idEvent, DWORD)
VOID CALLBACK SetStartupStatusProc(HWND hwnd, UINT, UINT_PTR idEvent, DWORD)
{
- BOOL found = FALSE;
- int i;
+ bool found = false;
+ int i = 0;
- for (i = 0; i < accounts->count; ++i)
+ for (; i < accounts->count; ++i)
{
if (!Proto_IsAccountEnabled(accounts->pa[i]))
continue;
@@ -1316,18 +1254,16 @@ VOID CALLBACK SetStartupStatusProc(HWND hwnd, UINT, UINT_PTR idEvent, DWORD)
if (g_uSetStatusTimer[i] == idEvent)
{
KillTimer(NULL, g_uSetStatusTimer[i]);
- found = TRUE;
+ found = true;
break;
}
}
- if (!found)
- {
+ if (found)
+ SetStartupStatus(i);
+ else
KillTimer(hwnd, idEvent);
- return;
- }
- SetStartupStatus(i);
}
VOID CALLBACK UpdateMsgTimerProc(HWND, UINT, UINT_PTR, DWORD)
@@ -1341,7 +1277,6 @@ VOID CALLBACK UpdateMsgTimerProc(HWND, UINT, UINT_PTR, DWORD)
if (!hwndSAMsgDialog)
{
char szBuffer[64];
- DBVARIANT dbv;
TCHAR *tszMsg;
int iCurrentStatus;
@@ -1361,23 +1296,24 @@ VOID CALLBACK UpdateMsgTimerProc(HWND, UINT, UINT_PTR, DWORD)
continue;
mir_snprintf(szBuffer, "FCur%sMsg", accounts->pa[i]->szModuleName);
- if (db_get_ts(NULL, "SimpleStatusMsg", szBuffer, &dbv))
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SimpleStatusMsg", szBuffer);
+ if (tszStatusMsg == NULL)
continue;
- tszMsg = InsertVarsIntoMsg(dbv.ptszVal, accounts->pa[i]->szModuleName, iCurrentStatus, NULL);
- db_free(&dbv);
+ tszMsg = InsertVarsIntoMsg(tszStatusMsg, accounts->pa[i]->szModuleName, iCurrentStatus, NULL);
+ mir_free(tszStatusMsg);
mir_snprintf(szBuffer, "Cur%sMsg", accounts->pa[i]->szModuleName);
- if (!db_get_ts(NULL, "SimpleStatusMsg", szBuffer, &dbv))
+
+ tszStatusMsg = db_get_tsa(NULL, "SimpleStatusMsg", szBuffer);
+ if ((tszMsg && tszStatusMsg && !mir_tstrcmp(tszMsg, tszStatusMsg)) || (!tszMsg && !tszStatusMsg))
{
- if (tszMsg && dbv.ptszVal && !mir_tstrcmp(tszMsg, dbv.ptszVal) || !tszMsg && !dbv.ptszVal)
- {
- db_free(&dbv);
- mir_free(tszMsg);
- continue;
- }
- db_free(&dbv);
+ mir_free(tszStatusMsg);
+ mir_free(tszMsg);
+ continue;
}
+ else
+ mir_free(tszStatusMsg);
if (tszMsg && mir_tstrlen(tszMsg))
{
@@ -1480,9 +1416,9 @@ static int ChangeStatusMsgPrebuild(WPARAM, LPARAM)
if (iProtoFlags & PROTO_NO_MSG || iProtoFlags & PROTO_THIS_MSG)
continue;
- TCHAR szBuffer[256];
if (Proto_IsAccountLocked(pa[i]))
{
+ TCHAR szBuffer[256];
mir_sntprintf(szBuffer, TranslateT("%s (locked)"), pa[i]->tszAccountName);
mi.root = Menu_CreateRoot(MO_STATUS, szBuffer, mi.position);
}
@@ -1581,10 +1517,8 @@ static int CSStatusChange(WPARAM wParam, LPARAM)
// TODO SaveMessageToDB also when NULL?
if (ps[i]->szMsg)
{
- int max_hist_msgs, j;
- DBVARIANT dbv;
char buff[80];
- BOOL found = FALSE;
+ bool found = false;
wchar_t *szMsgW = mir_t2u(ps[i]->szMsg);
@@ -1592,21 +1526,23 @@ static int CSStatusChange(WPARAM wParam, LPARAM)
#ifdef _DEBUG
log2file("CSStatusChange(): Set \"%s\" status message for %s.", ps[i]->szMsg, ps[i]->szName);
#endif
- max_hist_msgs = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10);
- for (j = 1; j <= max_hist_msgs; j++)
+ int max_hist_msgs = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10);
+ for (int j = 1; j <= max_hist_msgs; j++)
{
mir_snprintf(buff, "SMsg%d", j);
- if (!db_get_ts(NULL, "SimpleStatusMsg", buff, &dbv))
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SimpleStatusMsg", buff);
+ if (tszStatusMsg != NULL)
{
- if (!mir_tstrcmp(dbv.ptszVal, szMsgW))
+ if (!mir_tstrcmp(tszStatusMsg, szMsgW))
{
- found = TRUE;
+ found = true;
mir_snprintf(szSetting, "Last%sMsg", ps[i]->szName);
db_set_s(NULL, "SimpleStatusMsg", szSetting, buff);
- db_free(&dbv);
+ mir_free(tszStatusMsg);
break;
}
- db_free(&dbv);
+ else
+ mir_free(tszStatusMsg);
}
}
@@ -1781,19 +1717,10 @@ static int OnModulesLoaded(WPARAM, LPARAM)
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
}
}
-
-/* if (db_get_b(NULL, "SimpleStatusMsg", "AmpLeaveTitle", 1))*/ {
- DBVARIANT dbv;
-
- if (!db_get_ts(NULL, "SimpleStatusMsg", "AmpLastTitle", &dbv)) {
- g_ptszWinampSong = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- else
- g_ptszWinampSong = mir_tstrdup(_T("SimpleStatusMsg"));
- }
-/* else
- g_ptszWinampSong = mir_tstrdup(_T("SimpleStatusMsg"));*/
+
+ g_ptszWinampSong = db_get_tsa(NULL, "SimpleStatusMsg", "AmpLastTitle");
+ if (g_ptszWinampSong == NULL)
+ g_ptszWinampSong = mir_tstrdup(_T("SimpleStatusMsg"));
if (db_get_b(NULL, "SimpleStatusMsg", "UpdateMsgOn", 1))
g_uUpdateMsgTimer = SetTimer(NULL, 0, db_get_w(NULL, "SimpleStatusMsg", "UpdateMsgInt", 10) * 1000, UpdateMsgTimerProc);
diff --git a/plugins/SimpleStatusMsg/src/msgbox.cpp b/plugins/SimpleStatusMsg/src/msgbox.cpp
index 6680612052..2e92192c4b 100644
--- a/plugins/SimpleStatusMsg/src/msgbox.cpp
+++ b/plugins/SimpleStatusMsg/src/msgbox.cpp
@@ -69,9 +69,8 @@ int statusicon_nr[9];
HIMAGELIST AddStatusIconsToImageList(const char *szProto, int status_flags)
{
int num_icons = 1;
- int i;
- for (i = 0; i < 9; ++i)
+ for (int i = 0; i < 9; ++i)
if (Proto_Status2Flag(ID_STATUS_ONLINE + i) & status_flags)
num_icons++;
@@ -82,7 +81,7 @@ HIMAGELIST AddStatusIconsToImageList(const char *szProto, int status_flags)
statusicon_nr[0] = 0;
int j = 1;
- for (i = 0; i < 9; ++i) {
+ for (int i = 0; i < 9; ++i) {
if (Proto_Status2Flag(ID_STATUS_ONLINE + i) & status_flags) {
hicon = Skin_LoadProtoIcon(szProto, ID_STATUS_ONLINE + i);
ImageList_AddIcon(himlIcons, hicon);
@@ -216,10 +215,8 @@ HWND WINAPI CreateStatusComboBoxEx(HWND hwndDlg, struct MsgBoxData *data)
HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data)
{
- int i, j;
char buff[16];
BOOL found = FALSE;
- DBVARIANT dbv;
TCHAR text[128];
HWND handle = CreateWindowEx(0, WC_COMBOBOXEX, NULL,
@@ -232,19 +229,21 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data)
else
cbei.mask = CBEIF_LPARAM | CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
- j = db_get_w(NULL, "SimpleStatusMsg", "LMMsg", 1);
+ int j = db_get_w(NULL, "SimpleStatusMsg", "LMMsg", 1);
- for (i = 1; i <= data->max_hist_msgs; ++i) {
+ for (int i = 1; i <= data->max_hist_msgs; ++i) {
// history messages
if (j < 1)
j = data->max_hist_msgs;
mir_snprintf(buff, "SMsg%d", j);
j--;
- if (!db_get_ts(NULL, "SimpleStatusMsg", buff, &dbv)) {
- if (dbv.ptszVal != NULL && *dbv.ptszVal != '\0') {
+
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SimpleStatusMsg", buff);
+ if (tszStatusMsg != NULL) {
+ if (*tszStatusMsg != '\0') {
found = TRUE;
cbei.iItem = -1;
- cbei.pszText = (LPTSTR)dbv.ptszVal;
+ cbei.pszText = tszStatusMsg;
if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) {
cbei.iImage = I_ICON_HIST;
cbei.iSelectedImage = I_ICON_HIST;
@@ -254,11 +253,11 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data)
cbei.lParam = MAKELPARAM(HISTORY_MSG, j + 1);
if (SendMessage(handle, CBEM_INSERTITEM, 0, (LPARAM)&cbei) == -1) {
- db_free(&dbv);
+ mir_free(tszStatusMsg);
break;
}
}
- db_free(&dbv);
+ mir_free(tszStatusMsg);
}
}
@@ -330,18 +329,14 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data)
EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE);
}
- for (i = 1; i <= data->num_def_msgs; ++i) {
+ for (int i = 1; i <= data->num_def_msgs; ++i) {
// predefined messages
mir_snprintf(buff, "DefMsg%d", i);
- if (!db_get_ts(NULL, "SimpleStatusMsg", buff, &dbv)) {
- if (dbv.ptszVal) {
- if (!mir_tstrlen(dbv.ptszVal)) {
- db_free(&dbv);
- continue;
- }
-
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SimpleStatusMsg", buff);
+ if (tszStatusMsg != NULL) {
+ if (*tszStatusMsg != '\0') {
cbei.iItem = -1;
- cbei.pszText = (LPTSTR)dbv.ptszVal;
+ cbei.pszText = tszStatusMsg;
if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) {
cbei.iImage = I_ICON_MSG;
cbei.iSelectedImage = I_ICON_MSG;
@@ -353,7 +348,8 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data)
if (SendMessage(handle, CBEM_INSERTITEM, 0, (LPARAM)&cbei) == -1)
break;
}
- db_free(&dbv);
+
+ mir_free(tszStatusMsg);
}
}
@@ -703,7 +699,6 @@ void DisplayCharsCount(struct MsgBoxData *dlg_data, HWND hwndDlg)
void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus)
{
int flags, fcursel = CB_ERR, num_start;
- DBVARIANT dbv, dbv2;
char setting[80];
num_start = SendMessage(data->recent_cbex, CB_GETCOUNT, 0, 0);
@@ -718,19 +713,21 @@ void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus)
else
mir_snprintf(setting, "LastMsg");
- if (!db_get(NULL, "SimpleStatusMsg", setting, &dbv)) {
- if (dbv.pszVal && mir_strlen(dbv.pszVal)) {
- if (!db_get_ts(NULL, "SimpleStatusMsg", dbv.pszVal, &dbv2)) {
- if (dbv2.ptszVal && mir_tstrlen(dbv2.ptszVal)) {
- SetDlgItemText(hwndDlg, IDC_EDIT1, dbv2.ptszVal);
- fcursel = SendMessage(data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)dbv2.ptszVal);
+ char *szSetting = db_get_sa(NULL, "SimpleStatusMsg", setting);
+ if (szSetting != NULL) {
+ if (*szSetting != '\0') {
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SimpleStatusMsg", szSetting);
+ if (tszStatusMsg != NULL) {
+ if (*tszStatusMsg != '\0') {
+ SetDlgItemText(hwndDlg, IDC_EDIT1, tszStatusMsg);
+ fcursel = SendMessage(data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)tszStatusMsg);
if (fcursel != CB_ERR)
SendMessage(data->recent_cbex, CB_SETCURSEL, (WPARAM)fcursel, 0);
}
- db_free(&dbv2);
+ mir_free(tszStatusMsg);
}
}
- db_free(&dbv);
+ mir_free(szSetting);
}
}
else if (flags & STATUS_DEFAULT_MSG) {
@@ -748,12 +745,13 @@ void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus)
else
mir_snprintf(setting, "Default");
- if (!db_get_ts(NULL, "SRAway", StatusModeToDbSetting(iStatus, setting), &dbv)) {
- SetDlgItemText(hwndDlg, IDC_EDIT1, dbv.ptszVal);
- fcursel = SendMessage(data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)dbv.ptszVal);
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SRAway", StatusModeToDbSetting(iStatus, setting));
+ if (tszStatusMsg != NULL) {
+ SetDlgItemText(hwndDlg, IDC_EDIT1, tszStatusMsg);
+ fcursel = SendMessage(data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)tszStatusMsg);
if (fcursel != CB_ERR)
SendMessage(data->recent_cbex, CB_SETCURSEL, (WPARAM)fcursel, 0);
- db_free(&dbv);
+ mir_free(tszStatusMsg);
}
}
else if (flags & STATUS_LAST_STATUS_MSG) {
@@ -762,12 +760,13 @@ void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus)
else
mir_snprintf(setting, "Msg");
- if (!db_get_ts(NULL, "SRAway", StatusModeToDbSetting(iStatus, setting), &dbv)) {
- SetDlgItemText(hwndDlg, IDC_EDIT1, dbv.ptszVal);
- fcursel = SendMessage(data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)dbv.ptszVal);
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SRAway", StatusModeToDbSetting(iStatus, setting));
+ if (tszStatusMsg != NULL) {
+ SetDlgItemText(hwndDlg, IDC_EDIT1, tszStatusMsg);
+ fcursel = SendMessage(data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)tszStatusMsg);
if (fcursel != CB_ERR)
SendMessage(data->recent_cbex, CB_SETCURSEL, (WPARAM)fcursel, 0);
- db_free(&dbv);
+ mir_free(tszStatusMsg);
}
}
@@ -794,7 +793,7 @@ void ChangeDlgStatus(HWND hwndDlg, struct MsgBoxData *msgbox_data, int iStatus)
CallService(MS_SS_GETPROFILENAME, iStatus - 40083, (LPARAM)buff1);
MultiByteToWideChar(Langpack_GetDefaultCodePage(), 0, buff1, -1, buff, 128);
- mir_sntprintf(szTitle, TranslateT("%s message (%s)"), (TCHAR *)buff, szProtoName);
+ mir_sntprintf(szTitle, TranslateT("%s message (%s)"), buff, szProtoName);
}
else
mir_sntprintf(szTitle, TranslateT("%s message (%s)"), pcli->pfnGetStatusModeDescription(iStatus, 0), szProtoName);
@@ -1170,14 +1169,14 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
}
else {
char buff[64], buff2[80];
- DBVARIANT dbv;
- BOOL found = FALSE;
+ bool found = false;
for (int i = 1; i <= msgbox_data->max_hist_msgs; i++) {
mir_snprintf(buff, "SMsg%d", i);
- if (!db_get_ts(NULL, "SimpleStatusMsg", buff, &dbv)) {
- if (!mir_tstrcmp(dbv.ptszVal, tszMsg)) {
- found = TRUE;
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SimpleStatusMsg", buff);
+ if (tszStatusMsg != NULL) {
+ if (!mir_tstrcmp(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);
@@ -1208,10 +1207,10 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
db_set_ts(NULL, "SRAway", StatusModeToDbSetting(iStatus, buff2), tszMsg);
}
}
- db_free(&dbv);
+ mir_free(tszStatusMsg);
break;
}
- db_free(&dbv);
+ mir_free(tszStatusMsg);
}
}
diff --git a/plugins/SimpleStatusMsg/src/options.cpp b/plugins/SimpleStatusMsg/src/options.cpp
index de55dcabb2..22658d55d8 100644
--- a/plugins/SimpleStatusMsg/src/options.cpp
+++ b/plugins/SimpleStatusMsg/src/options.cpp
@@ -291,9 +291,9 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
case CBN_SELCHANGE:
case CBN_SELENDOK:
{
- int i, j, l, k, status_modes = 0, newindex = 0;
+ int l, k, status_modes = 0, newindex = 0;
- i = SendMessage((HWND)lParam, CB_GETITEMDATA, (WPARAM)SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0), 0);
+ int i = SendMessage((HWND)lParam, CB_GETITEMDATA, (WPARAM)SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0), 0);
if (i == 0)
{
@@ -379,9 +379,12 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
status_modes = CallProtoService(accounts->pa[k]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
}
else
+ {
+ k = 0;
status_modes = accounts->statusMsgFlags;
+ }
- j = SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETCURSEL, 0, 0), 0);
+ 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++)
@@ -438,8 +441,6 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
}
else if (data->status_msg[i].flags[j] & STATUS_LAST_MSG)
{
- DBVARIANT dbv, dbv2;
-
char setting[80];
if (i)
mir_snprintf(setting, "Last%sMsg", accounts->pa[k]->szModuleName);
@@ -447,19 +448,18 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
mir_snprintf(setting, "LastMsg");
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, _T(""));
- if (!db_get(NULL, "SimpleStatusMsg", setting, &dbv))
+ char *szSetting = db_get_sa(NULL, "SimpleStatusMsg", setting);
+ if (szSetting)
{
- if (dbv.pszVal)
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SimpleStatusMsg", szSetting);
+ if (tszStatusMsg && mir_tstrlen(tszStatusMsg))
{
- if (!db_get_ts(NULL, "SimpleStatusMsg", dbv.pszVal, &dbv2) && mir_strlen(dbv.pszVal))
- {
- if ((dbv2.ptszVal) && (mir_tstrlen(dbv2.ptszVal)))
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, dbv2.ptszVal);
+ if (tszStatusMsg && mir_tstrlen(tszStatusMsg))
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
- db_free(&dbv2);
- }
+ mir_free(tszStatusMsg);
}
- db_free(&dbv);
+ mir_free(szSetting);
}
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
@@ -483,17 +483,17 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
else if (data->status_msg[i].flags[j] & STATUS_LAST_STATUS_MSG)
{
char setting[80];
- DBVARIANT dbv;
if (i)
mir_snprintf(setting, "%sMsg", accounts->pa[k]->szModuleName);
else
mir_snprintf(setting, "Msg");
- if (!db_get_ts(NULL, "SRAway", StatusModeToDbSetting(j + ID_STATUS_ONLINE, setting), &dbv))
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SRAway", StatusModeToDbSetting(j + ID_STATUS_ONLINE, setting));
+ if (tszStatusMsg)
{
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, dbv.ptszVal);
- db_free(&dbv);
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
+ mir_free(tszStatusMsg);
}
else
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, _T(""));
@@ -515,10 +515,8 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
switch (HIWORD(wParam)) {
case BN_CLICKED:
{
- int i, j;
-
- i = SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETCURSEL, 0, 0), 0);
- j = SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETCURSEL, 0, 0), 0);
+ int i = SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETCURSEL, 0, 0), 0);
+ int j = SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETCURSEL, 0, 0), 0);
data->proto_msg[i].flags = 0;
@@ -594,7 +592,6 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
else if (data->status_msg[i].flags[j] & STATUS_LAST_MSG)
{
char setting[80];
- DBVARIANT dbv, dbv2;
if (i)
mir_snprintf(setting, "Last%sMsg", accounts->pa[i-1]->szModuleName);
@@ -602,18 +599,17 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
mir_snprintf(setting, "LastMsg");
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, _T(""));
- if (!db_get(NULL, "SimpleStatusMsg", setting, &dbv))
+ char *szSetting = db_get_sa(NULL, "SimpleStatusMsg", setting);
+ if (szSetting != NULL)
{
- if (dbv.pszVal)
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SimpleStatusMsg", szSetting);
+ if (tszStatusMsg)
{
- if (!db_get_ts(NULL, "SimpleStatusMsg", dbv.pszVal, &dbv2) && mir_strlen(dbv.pszVal))
- {
- if (dbv2.ptszVal && mir_tstrlen(dbv2.ptszVal))
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, dbv2.ptszVal);
- db_free(&dbv2);
- }
+ if (tszStatusMsg[0])
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
+ mir_free(tszStatusMsg);
}
- db_free(&dbv);
+ mir_free(szSetting);
}
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
@@ -637,17 +633,17 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
else if (data->status_msg[i].flags[j] & STATUS_LAST_STATUS_MSG)
{
char setting[80];
- DBVARIANT dbv;
if (i)
mir_snprintf(setting, "%sMsg", accounts->pa[i-1]->szModuleName);
else
mir_snprintf(setting, "Msg");
- if (!db_get_ts(NULL, "SRAway", StatusModeToDbSetting(j + ID_STATUS_ONLINE, setting), &dbv))
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SRAway", StatusModeToDbSetting(j + ID_STATUS_ONLINE, setting));
+ if (tszStatusMsg != NULL)
{
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, dbv.ptszVal);
- db_free(&dbv);
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
+ mir_free(tszStatusMsg);
}
else
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, _T(""));
@@ -667,10 +663,8 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
case CBN_SELCHANGE:
case CBN_SELENDOK:
{
- int i, j;
-
- i = SendMessage((HWND)lParam, CB_GETITEMDATA, (WPARAM)SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0), 0);
- j = SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETCURSEL, 0, 0), 0);
+ int i = SendMessage((HWND)lParam, CB_GETITEMDATA, (WPARAM)SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0), 0);
+ int j = SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETCURSEL, 0, 0), 0);
if (data->status_msg[j].flags[i] & STATUS_SHOW_DLG)
CheckDlgButton(hwndDlg, IDC_COPTMSG1, BST_CHECKED);
@@ -694,26 +688,23 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
else if (data->status_msg[j].flags[i] & STATUS_LAST_MSG)
{
char setting[80];
- DBVARIANT dbv,dbv2;
-
if (j)
mir_snprintf(setting, "Last%sMsg", accounts->pa[j-1]->szModuleName);
else
mir_snprintf(setting, "LastMsg");
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, _T(""));
- if (!db_get(NULL, "SimpleStatusMsg", setting, &dbv))
+ char *szSetting = db_get_sa(NULL, "SimpleStatusMsg", setting);
+ if (szSetting != NULL)
{
- if (dbv.pszVal)
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SimpleStatusMsg", szSetting);
+ if (tszStatusMsg)
{
- if (!db_get_ts(NULL, "SimpleStatusMsg", dbv.pszVal, &dbv2) && mir_strlen(dbv.pszVal))
- {
- if (dbv2.ptszVal && mir_tstrlen(dbv2.ptszVal))
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, dbv2.ptszVal);
- db_free(&dbv2);
- }
+ if (tszStatusMsg[0])
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
+ mir_free(tszStatusMsg);
}
- db_free(&dbv);
+ mir_free(szSetting);
}
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
@@ -729,17 +720,17 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
else if (data->status_msg[j].flags[i] & STATUS_LAST_STATUS_MSG)
{
char setting[80];
- DBVARIANT dbv;
if (j)
mir_snprintf(setting, "%sMsg", accounts->pa[j-1]->szModuleName);
else
mir_snprintf(setting, "Msg");
- if (!db_get_ts(NULL, "SRAway", StatusModeToDbSetting(i + ID_STATUS_ONLINE, setting), &dbv))
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SRAway", StatusModeToDbSetting(j + ID_STATUS_ONLINE, setting));
+ if (tszStatusMsg != NULL)
{
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, dbv.ptszVal);
- db_free(&dbv);
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
+ mir_free(tszStatusMsg);
}
else
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, _T(""));
@@ -757,10 +748,8 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
switch (HIWORD(wParam)) {
case BN_CLICKED:
{
- int i, j;
-
- i = SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETCURSEL, 0, 0), 0);
- j = SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETCURSEL, 0, 0), 0);
+ 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 (IsDlgButtonChecked(hwndDlg, IDC_COPTMSG1) == BST_CHECKED)
data->status_msg[j].flags[i] |= STATUS_SHOW_DLG;
else
@@ -778,10 +767,8 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
switch (HIWORD(wParam)) {
case BN_CLICKED:
{
- int i, j;
-
- i = SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETCURSEL, 0, 0), 0);
- j = SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETCURSEL, 0, 0), 0);
+ 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 (LOWORD(wParam) == IDC_ROPTMSG4 && data->proto_msg[j].flags & PROTO_THIS_MSG)
break;
@@ -808,7 +795,6 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
else if (LOWORD(wParam) == IDC_ROPTMSG3)
{
char setting[80];
- DBVARIANT dbv, dbv2;
if (j)
mir_snprintf(setting, "Last%sMsg", accounts->pa[j-1]->szModuleName);
@@ -816,19 +802,21 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
mir_snprintf(setting, "LastMsg");
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, _T(""));
- if (!db_get(NULL, "SimpleStatusMsg", setting, &dbv))
+
+
+ char *szSetting = db_get_sa(NULL, "SimpleStatusMsg", setting);
+ if (szSetting != NULL)
{
- if (dbv.pszVal)
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SimpleStatusMsg", szSetting);
+ if (tszStatusMsg)
{
- if (!db_get_ts(NULL, "SimpleStatusMsg", dbv.pszVal, &dbv2) && mir_strlen(dbv.pszVal))
- {
- if (dbv2.ptszVal && mir_tstrlen(dbv2.ptszVal))
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, dbv2.ptszVal);
- db_free(&dbv2);
- }
+ if (tszStatusMsg[0])
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
+ mir_free(tszStatusMsg);
}
- db_free(&dbv);
+ mir_free(szSetting);
}
+
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTEDIT1), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARSHELP), FALSE);
data->status_msg[j].flags[i] |= STATUS_LAST_MSG;
@@ -843,17 +831,17 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
else if (LOWORD(wParam) == IDC_ROPTMSG5)
{
char setting[80];
- DBVARIANT dbv;
if (j)
mir_snprintf(setting, "%sMsg", accounts->pa[j-1]->szModuleName);
else
mir_snprintf(setting, "Msg");
- if (!db_get_ts(NULL, "SRAway", StatusModeToDbSetting(i+ID_STATUS_ONLINE, setting), &dbv))
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SRAway", StatusModeToDbSetting(i + ID_STATUS_ONLINE, setting));
+ if (tszStatusMsg != NULL)
{
- SetDlgItemText(hwndDlg, IDC_OPTEDIT1, dbv.ptszVal);
- db_free(&dbv);
+ SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
+ mir_free(tszStatusMsg);
}
else
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, _T(""));
@@ -913,12 +901,11 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
case IDC_BOPTPROTO:
{
- int i, j, k;
- j = SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETCURSEL, 0, 0), 0);
+ int j = SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETCURSEL, 0, 0), 0);
if (j)
{
- for (i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
+ for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
{
if (accounts->statusMsgFlags & Proto_Status2Flag(i))
{
@@ -929,7 +916,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
}
}
- for (k = 0; k < accounts->count; k++)
+ for (int k = 0; k < accounts->count; k++)
{
if (!Proto_IsAccountEnabled(accounts->pa[k]) || !CallProtoService(accounts->pa[k]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) || !(CallProtoService(accounts->pa[k]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
continue;
@@ -964,7 +951,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
}
else if (data->proto_msg[j].flags & PROTO_POPUPDLG)
{
- for (i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
+ for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
{
if (CallProtoService(accounts->pa[k]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(i))
{
@@ -981,17 +968,16 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
case IDC_BOPTSTATUS:
{
- int status_modes, i, j, k;
-
- i = SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_GETCURSEL, 0, 0), 0);
- j = SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_GETCURSEL, 0, 0), 0);
+ 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);
+ int status_modes;
if (j)
status_modes = CallProtoService(accounts->pa[j-1]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
else
status_modes = accounts->statusMsgFlags;
- for (k = ID_STATUS_ONLINE; k <= ID_STATUS_OUTTOLUNCH; k++)
+ for (int k = ID_STATUS_ONLINE; k <= ID_STATUS_OUTTOLUNCH; k++)
{
if (k - ID_STATUS_ONLINE != i && status_modes & Proto_Status2Flag(k))
{
@@ -1009,9 +995,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY)
{
char szSetting[80];
- int i;
-
- for (i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
+ for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
{
if (accounts->statusMsgFlags & Proto_Status2Flag(i))
{
@@ -1044,7 +1028,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
{
db_set_b(NULL, "SimpleStatusMsg", "ProtoFlags", (BYTE)data->proto_msg[0].flags);
- for (i = 0; i < accounts->count; i++)
+ for (int i = 0; i < accounts->count; i++)
{
if (!Proto_IsAccountEnabled(accounts->pa[i]))
continue;
@@ -1189,24 +1173,24 @@ static INT_PTR CALLBACK DlgVariablesOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM
return FALSE;
}
-static BOOL IsHistoryMsgsFound(HWND, int histMax)
+static bool IsHistoryMsgsFound(HWND, int histMax)
{
char szSetting[16];
- DBVARIANT dbv;
int j = db_get_w(NULL, "SimpleStatusMsg", "LMMsg", 1);
for (int i = 1; i <= histMax; ++i, --j) {
if (j < 1)
j = histMax;
mir_snprintf(szSetting, "SMsg%d", j);
- if (!db_get_ts(NULL, "SimpleStatusMsg", szSetting, &dbv)) {
- if (dbv.ptszVal != NULL && *dbv.ptszVal != '\0') {
- db_free(&dbv);
- return TRUE;
+ TCHAR *tszStatusMsg = db_get_tsa(NULL, "SimpleStatusMsg", szSetting);
+ if (tszStatusMsg != NULL) {
+ if (*tszStatusMsg != '\0') {
+ mir_free(tszStatusMsg);
+ return true;
}
- db_free(&dbv);
+ mir_free(tszStatusMsg);
}
}
- return FALSE;
+ return false;
}
static INT_PTR CALLBACK DlgAdvancedOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -1338,19 +1322,20 @@ static INT_PTR CALLBACK DlgAdvancedOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM w
case IDC_BOPTHIST:
if (MessageBox(NULL, TranslateT("Are you sure you want to clear status message history?"), TranslateT("Confirm clearing history"), MB_ICONQUESTION | MB_YESNO) == IDYES)
{
- int i, max_hist_msgs;
- char text[8], setting[80];
if (hwndSAMsgDialog)
DestroyWindow(hwndSAMsgDialog);
- max_hist_msgs = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10);
- for (i = 1; i <= max_hist_msgs; i++) {
+ int max_hist_msgs = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10);
+ for (int i = 1; i <= max_hist_msgs; i++) {
+ char text[8];
mir_snprintf(text, "SMsg%d", i);
db_set_ts(NULL, "SimpleStatusMsg", text, _T(""));
}
+
db_set_s(NULL, "SimpleStatusMsg", "LastMsg", "");
- for (i = 0; i < accounts->count; i++) {
+
+ for (int i = 0; i < accounts->count; i++) {
if (!Proto_IsAccountEnabled(accounts->pa[i]))
continue;
@@ -1360,6 +1345,7 @@ static INT_PTR CALLBACK DlgAdvancedOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM w
if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
continue;
+ char setting[80];
mir_snprintf(setting, "Last%sMsg", accounts->pa[i]->szModuleName);
db_set_s(NULL, "SimpleStatusMsg", setting, "");
}
@@ -1371,14 +1357,12 @@ static INT_PTR CALLBACK DlgAdvancedOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM w
case IDC_BOPTDEF:
if (MessageBox(NULL, TranslateT("Are you sure you want to clear predefined status messages?"), TranslateT("Confirm clearing predefined"), MB_ICONQUESTION | MB_YESNO) == IDYES)
{
- char szSetting[16];
- int nDefMSgCount;
-
if (hwndSAMsgDialog)
DestroyWindow(hwndSAMsgDialog);
- nDefMSgCount = db_get_w(NULL, "SimpleStatusMsg", "DefMsgCount", 0);
+ int nDefMSgCount = db_get_w(NULL, "SimpleStatusMsg", "DefMsgCount", 0);
for (int i = 1; i <= nDefMSgCount; i++) {
+ char szSetting[16];
mir_snprintf(szSetting, "DefMsg%d", i);
db_unset(NULL, "SimpleStatusMsg", szSetting);
}
@@ -1440,8 +1424,6 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
switch (uMsg) {
case WM_INITDIALOG:
{
- int index, i;
-
TranslateDialogDefault(hwndDlg);
data = (struct StatusOptDlgData *)mir_alloc(sizeof(struct StatusOptDlgData));
@@ -1449,12 +1431,12 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
data->status = (int *)mir_alloc(sizeof(int) * accounts->count);
data->setdelay = (int *)mir_alloc(sizeof(int) * accounts->count);
- for (i = 0; i < accounts->count; ++i)
+ for (int i = 0; i < accounts->count; ++i)
{
if (!Proto_IsAccountEnabled(accounts->pa[i]) || !(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) &~ CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)))
continue;
- index = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_ADDSTRING, 0, (LPARAM)accounts->pa[i]->tszAccountName);
+ int index = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_ADDSTRING, 0, (LPARAM)accounts->pa[i]->tszAccountName);
if (index != LB_ERR && index != LB_ERRSPACE)
{
char setting[80];
@@ -1477,7 +1459,7 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
if (!db_get_b(NULL, "SimpleStatusMsg", "GlobalStatusDelay", 1))
{
CheckDlgButton(hwndDlg, IDC_SPECSET, BST_CHECKED);
- i = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETCURSEL, 0, 0), 0);
+ 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
@@ -1503,7 +1485,7 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
{
EnableWindow(GetDlgItem(hwndDlg, IDC_SPECSET), FALSE);
CheckDlgButton(hwndDlg, IDC_SPECSET, BST_UNCHECKED); //should work like when checked, but should not be checked
- i = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETCURSEL, 0, 0), 0);
+ 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);
}
@@ -1580,17 +1562,17 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
switch (HIWORD(wParam)) {
case LBN_SELCHANGE:
{
- int status_modes, i, l, index, newindex = 0;
+ int newindex = 0;
- i = SendMessage((HWND)lParam, LB_GETITEMDATA, (WPARAM)SendMessage((HWND)lParam, LB_GETCURSEL, 0, 0), 0);
- status_modes = CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0);
+ int i = SendMessage((HWND)lParam, LB_GETITEMDATA, (WPARAM)SendMessage((HWND)lParam, LB_GETCURSEL, 0, 0), 0);
+ int status_modes = CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0);
SendDlgItemMessage(hwndDlg, IDC_LISTSTATUS, LB_RESETCONTENT, 0, 0);
- for (l = ID_STATUS_OFFLINE; l <= ID_STATUS_OUTTOLUNCH; l++)
+ for (int l = ID_STATUS_OFFLINE; l <= ID_STATUS_OUTTOLUNCH; l++)
{
if (status_modes & Proto_Status2Flag(l) || l == ID_STATUS_OFFLINE)
{
- index = SendDlgItemMessage(hwndDlg, IDC_LISTSTATUS, LB_INSERTSTRING, -1, (LPARAM)pcli->pfnGetStatusModeDescription(l, 0));
+ int index = SendDlgItemMessage(hwndDlg, IDC_LISTSTATUS, LB_INSERTSTRING, -1, (LPARAM)pcli->pfnGetStatusModeDescription(l, 0));
if (index != LB_ERR && index != LB_ERRSPACE)
{
SendDlgItemMessage(hwndDlg, IDC_LISTSTATUS, LB_SETITEMDATA, (WPARAM)index, (LPARAM)l - ID_STATUS_OFFLINE);
@@ -1600,7 +1582,7 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
}
}
- index = SendDlgItemMessage(hwndDlg, IDC_LISTSTATUS, LB_INSERTSTRING, -1, (LPARAM)TranslateT("<last status>"));
+ int index = SendDlgItemMessage(hwndDlg, IDC_LISTSTATUS, LB_INSERTSTRING, -1, (LPARAM)TranslateT("<last status>"));
if (index != LB_ERR && index != LB_ERRSPACE)
{
SendDlgItemMessage(hwndDlg, IDC_LISTSTATUS, LB_SETITEMDATA, (WPARAM)index, (LPARAM)ID_STATUS_CURRENT - ID_STATUS_OFFLINE);
@@ -1634,12 +1616,12 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
case WM_NOTIFY:
if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY)
{
- char szSetting[80];
for (int i = 0; i < accounts->count; i++)
{
if (!Proto_IsAccountEnabled(accounts->pa[i]) || !(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)))
continue;
+ char szSetting[80];
mir_snprintf(szSetting, "Startup%sStatus", accounts->pa[i]->szModuleName);
db_set_w(NULL, "SimpleStatusMsg", szSetting, (WORD)data->status[i]);