diff options
Diffstat (limited to 'plugins/SimpleStatusMsg')
-rw-r--r-- | plugins/SimpleStatusMsg/src/awaymsg.cpp | 151 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/src/main.cpp | 49 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/src/msgbox.cpp | 558 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/src/options.cpp | 12 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/src/utils.cpp | 72 |
5 files changed, 340 insertions, 502 deletions
diff --git a/plugins/SimpleStatusMsg/src/awaymsg.cpp b/plugins/SimpleStatusMsg/src/awaymsg.cpp index f918e447db..ab93e8b13f 100644 --- a/plugins/SimpleStatusMsg/src/awaymsg.cpp +++ b/plugins/SimpleStatusMsg/src/awaymsg.cpp @@ -33,17 +33,19 @@ static HANDLE hWindowList2; static char *StrNormNewlineA(char *szStr)
{
- if (szStr == NULL) return NULL;
+ if (szStr == NULL)
+ return NULL;
int nCR = 0;
for (int i = 0; szStr[i]; i++)
- if (szStr[i] != 0x0D && szStr[i + 1] == 0x0A) nCR++;
+ if (szStr[i] != 0x0D && szStr[i + 1] == 0x0A)
+ nCR++;
- if (!nCR) return mir_strdup(szStr);
+ if (!nCR)
+ return mir_strdup(szStr);
- char *szNewStr = (char*)mir_alloc(lstrlenA(szStr) + nCR + 1), *pszStr = szNewStr;
- while (*szStr)
- {
+ char *szNewStr = (char *)mir_alloc(lstrlenA(szStr) + nCR + 1), *pszStr = szNewStr;
+ while (*szStr) {
if (*szStr == 0x0A)
*pszStr++ = 0x0D;
*pszStr++ = *szStr++;
@@ -56,17 +58,19 @@ static char *StrNormNewlineA(char *szStr) static TCHAR *StrNormNewline(TCHAR *tszStr)
{
- if (tszStr == NULL) return NULL;
+ if (tszStr == NULL)
+ return NULL;
int nCR = 0;
for (int i = 0; tszStr[i]; i++)
- if (tszStr[i] != 0x0D && tszStr[i + 1] == 0x0A) nCR++;
+ if (tszStr[i] != 0x0D && tszStr[i + 1] == 0x0A)
+ nCR++;
- if (!nCR) return mir_tstrdup(tszStr);
+ if (!nCR)
+ return mir_tstrdup(tszStr);
- TCHAR *tszNewStr = (TCHAR*)mir_alloc((lstrlen(tszStr) + nCR + 1) * sizeof(TCHAR)), *ptszStr = tszNewStr;
- while (*tszStr)
- {
+ TCHAR *tszNewStr = (TCHAR *)mir_alloc((lstrlen(tszStr) + nCR + 1) * sizeof(TCHAR)), *ptszStr = tszNewStr;
+ while (*tszStr) {
if (*tszStr == 0x0A)
*ptszStr++ = 0x0D;
*ptszStr++ = *tszStr++;
@@ -88,13 +92,12 @@ struct AwayMsgDlgData static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
- AwayMsgDlgData *dat = (AwayMsgDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ AwayMsgDlgData *dat = (AwayMsgDlgData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (message)
- {
+ switch (message) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- dat = (AwayMsgDlgData*)mir_alloc(sizeof(AwayMsgDlgData));
+ dat = (AwayMsgDlgData *)mir_alloc(sizeof(AwayMsgDlgData));
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
dat->hContact = lParam;
@@ -103,7 +106,7 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP WindowList_Add(hWindowList, hwndDlg, dat->hContact);
{
TCHAR str[256], format[128];
- TCHAR *contactName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)dat->hContact, GCDNF_TCHAR);
+ TCHAR *contactName = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)dat->hContact, GCDNF_TCHAR);
char *szProto = GetContactProto(dat->hContact);
WORD dwStatus = db_get_w(dat->hContact, szProto, "Status", ID_STATUS_OFFLINE);
TCHAR *status = pcli->pfnGetStatusModeDescription(dwStatus, 0);
@@ -111,13 +114,11 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP GetWindowText(hwndDlg, format, SIZEOF(format));
mir_sntprintf(str, SIZEOF(str), format, status, contactName);
SetWindowText(hwndDlg, str);
- if (dat->hSeq)
- {
+ if (dat->hSeq) {
GetDlgItemText(hwndDlg, IDC_RETRIEVING, format, SIZEOF(format));
mir_sntprintf(str, SIZEOF(str), format, status);
}
- else
- {
+ else {
mir_sntprintf(str, SIZEOF(str), TranslateT("Failed to retrieve %s message."), status);
SetDlgItemText(hwndDlg, IDOK, TranslateT("&Close"));
}
@@ -131,16 +132,21 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP case HM_AWAYMSG:
{
- ACKDATA *ack = (ACKDATA*)lParam;
- if (ack->hContact != dat->hContact || ack->type != ACKTYPE_AWAYMSG) break;
- if (ack->result != ACKRESULT_SUCCESS) break;
- if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) { UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent = NULL; }
+ ACKDATA *ack = (ACKDATA *)lParam;
+ if (ack->hContact != dat->hContact || ack->type != ACKTYPE_AWAYMSG)
+ break;
+ if (ack->result != ACKRESULT_SUCCESS)
+ break;
+ if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) {
+ UnhookEvent(dat->hAwayMsgEvent);
+ dat->hAwayMsgEvent = NULL;
+ }
- TCHAR *tszMsg = StrNormNewline((TCHAR*)ack->lParam);
+ TCHAR *tszMsg = StrNormNewline((TCHAR *)ack->lParam);
SetDlgItemText(hwndDlg, IDC_MSG, tszMsg);
mir_free(tszMsg);
- if (ack->lParam && *((char*)ack->lParam) != '\0')
+ if (ack->lParam && *((char *)ack->lParam) != '\0')
EnableWindow(GetDlgItem(hwndDlg, IDC_COPY), TRUE);
ShowWindow(GetDlgItem(hwndDlg, IDC_RETRIEVING), SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_MSG), SW_SHOW);
@@ -149,25 +155,22 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP }
case WM_COMMAND:
- switch (LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
case IDCANCEL:
case IDOK:
DestroyWindow(hwndDlg);
break;
case IDC_COPY:
- if (!OpenClipboard(hwndDlg)) break;
- if (EmptyClipboard())
- {
+ if (!OpenClipboard(hwndDlg))
+ break;
+ if (EmptyClipboard()) {
TCHAR msg[1024];
int len = GetDlgItemText(hwndDlg, IDC_MSG, msg, SIZEOF(msg));
- if (len)
- {
- LPTSTR lptstrCopy;
+ if (len) {
+ LPTSTR lptstrCopy;
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(TCHAR));
- if (hglbCopy == NULL)
- {
+ if (hglbCopy == NULL) {
CloseClipboard();
break;
}
@@ -190,7 +193,8 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP break;
case WM_DESTROY:
- if (dat->hAwayMsgEvent) UnhookEvent(dat->hAwayMsgEvent);
+ if (dat->hAwayMsgEvent)
+ UnhookEvent(dat->hAwayMsgEvent);
Utils_SaveWindowPosition(hwndDlg, dat->hContact, "SRAway", "AwayMsgDlg");
WindowList_Remove(hWindowList, hwndDlg);
Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, NULL));
@@ -203,60 +207,70 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP static INT_PTR GetMessageCommand(WPARAM wParam, LPARAM)
{
- if (HWND hwnd = WindowList_Find(hWindowList, wParam))
- {
+ if (HWND hwnd = WindowList_Find(hWindowList, wParam)) {
SetForegroundWindow(hwnd);
SetFocus(hwnd);
}
- else CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_READAWAYMSG), NULL, ReadAwayMsgDlgProc, wParam);
+ else
+ CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_READAWAYMSG), NULL, ReadAwayMsgDlgProc, wParam);
return 0;
}
static INT_PTR CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
- AwayMsgDlgData *dat = (AwayMsgDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ AwayMsgDlgData *dat = (AwayMsgDlgData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (message)
- {
+ switch (message) {
case WM_INITDIALOG:
{
TCHAR str[256], format[128];
TCHAR *contactName;
TranslateDialogDefault(hwndDlg);
- dat = (AwayMsgDlgData*)mir_alloc(sizeof(AwayMsgDlgData));
+ dat = (AwayMsgDlgData *)mir_alloc(sizeof(AwayMsgDlgData));
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
dat->hContact = lParam;
dat->hSeq = (HANDLE)CallContactService(dat->hContact, PSS_GETAWAYMSG, 0, 0);
dat->hAwayMsgEvent = dat->hSeq ? HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_AWAYMSG) : NULL;
WindowList_Add(hWindowList2, hwndDlg, dat->hContact);
- contactName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)dat->hContact, GCDNF_TCHAR);
+ contactName = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)dat->hContact, GCDNF_TCHAR);
GetWindowText(hwndDlg, format, SIZEOF(format));
mir_sntprintf(str, SIZEOF(str), format, contactName);
SetWindowText(hwndDlg, str);
- if (!dat->hSeq) DestroyWindow(hwndDlg);
+ if (!dat->hSeq)
+ DestroyWindow(hwndDlg);
return TRUE;
}
case HM_AWAYMSG:
{
- ACKDATA *ack = (ACKDATA*)lParam;
- if (ack->hContact != dat->hContact || ack->type != ACKTYPE_AWAYMSG) { DestroyWindow(hwndDlg); break; }
- if (ack->result != ACKRESULT_SUCCESS) { DestroyWindow(hwndDlg); break; }
- if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) { UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent = NULL; }
+ ACKDATA *ack = (ACKDATA *)lParam;
+ if (ack->hContact != dat->hContact || ack->type != ACKTYPE_AWAYMSG) {
+ DestroyWindow(hwndDlg);
+ break;
+ }
+ if (ack->result != ACKRESULT_SUCCESS) {
+ DestroyWindow(hwndDlg);
+ break;
+ }
+ if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) {
+ UnhookEvent(dat->hAwayMsgEvent);
+ dat->hAwayMsgEvent = NULL;
+ }
- if (!OpenClipboard(hwndDlg)) { DestroyWindow(hwndDlg); break; }
- if (EmptyClipboard())
- {
+ if (!OpenClipboard(hwndDlg)) {
+ DestroyWindow(hwndDlg);
+ break;
+ }
+ if (EmptyClipboard()) {
TCHAR msg[1024];
- TCHAR *tszMsg = StrNormNewline((TCHAR*)ack->lParam);
+ TCHAR *tszMsg = StrNormNewline((TCHAR *)ack->lParam);
mir_sntprintf(msg, SIZEOF(msg), _T("%s"), tszMsg);
mir_free(tszMsg);
size_t len = lstrlen(msg);
- if (len)
- {
- LPTSTR lptstrCopy;
+ if (len) {
+ LPTSTR lptstrCopy;
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(TCHAR));
if (hglbCopy == NULL) {
CloseClipboard();
@@ -277,8 +291,7 @@ static INT_PTR CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP }
case WM_COMMAND:
- switch (LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
case IDCANCEL:
case IDOK:
DestroyWindow(hwndDlg);
@@ -301,12 +314,12 @@ static INT_PTR CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP static INT_PTR CopyAwayMsgCommand(WPARAM wParam, LPARAM)
{
- if (HWND hwnd = WindowList_Find(hWindowList2, wParam))
- {
+ if (HWND hwnd = WindowList_Find(hWindowList2, wParam)) {
SetForegroundWindow(hwnd);
SetFocus(hwnd);
}
- else CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_COPY), NULL, CopyAwayMsgDlgProc, wParam);
+ else
+ CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_COPY), NULL, CopyAwayMsgDlgProc, wParam);
return 0;
}
@@ -314,8 +327,7 @@ static char *StrFindURL(char *pszStr) {
char *pszURL = NULL;
- if (pszStr != NULL && *pszStr != '\0')
- {
+ if (pszStr != NULL && *pszStr != '\0') {
pszURL = strstr(pszStr, "www.");
if (pszURL == NULL)
pszURL = strstr(pszStr, "http://");
@@ -333,15 +345,12 @@ static INT_PTR GoToURLMsgCommand(WPARAM wParam, LPARAM lParam) ptrA szMsg(db_get_sa(wParam, "CList", "StatusMsg"));
char *szURL = StrFindURL(szMsg);
- if (szURL != NULL)
- {
+ if (szURL != NULL) {
int i;
- for (i = 0; szURL[i] != ' ' && szURL[i] != '\n' && szURL[i] != '\r' &&
- szURL[i] != '\t' && szURL[i] != '\0'; i++);
+ for (i = 0; szURL[i] != ' ' && szURL[i] != '\n' && szURL[i] != '\r' && szURL[i] != '\t' && szURL[i] != '\0'; i++);
char *szMsgURL = (char *)mir_alloc(i + 1);
- if (szMsgURL)
- {
+ if (szMsgURL) {
lstrcpynA(szMsgURL, szURL, i + 1);
CallService(MS_UTILS_OPENURL, 1, (LPARAM)szMsgURL);
mir_free(szMsgURL);
diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp index e21867ae3b..aceecf50d1 100644 --- a/plugins/SimpleStatusMsg/src/main.cpp +++ b/plugins/SimpleStatusMsg/src/main.cpp @@ -1665,8 +1665,7 @@ static TCHAR *ParseWinampSong(ARGUMENTSINFO *ai) ai->flags |= AIF_DONTPARSE;
ptszWinampTitle = GetWinampSong();
- if (ptszWinampTitle != NULL)
- {
+ if (ptszWinampTitle != NULL) {
mir_free(g_ptszWinampSong);
g_ptszWinampSong = mir_tstrdup(ptszWinampTitle);
}
@@ -1691,8 +1690,7 @@ static TCHAR *ParseDate(ARGUMENTSINFO *ai) int ICQMsgTypeToStatus(int iMsgType)
{
- switch (iMsgType)
- {
+ switch (iMsgType) {
case MTYPE_AUTOONLINE: return ID_STATUS_ONLINE;
case MTYPE_AUTOAWAY: return ID_STATUS_AWAY;
case MTYPE_AUTOBUSY: return ID_STATUS_OCCUPIED;
@@ -1745,17 +1743,16 @@ static int OnAccListChanged(WPARAM wParam, LPARAM lParam) UnhookProtoEvents();
ProtoEnumAccounts(&accounts->count, &accounts->pa);
- for (int i = 0; i < accounts->count; ++i)
- {
+ for (int i = 0; i < accounts->count; ++i) {
if (!IsAccountEnabled(accounts->pa[i]))
continue;
if (!strcmp(accounts->pa[i]->szProtoName, "ICQ"))
HookProtoEvent(accounts->pa[i]->szModuleName, ME_ICQ_STATUSMSGREQ, OnICQStatusMsgRequest);
- accounts->statusFlags |= (CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) &~ CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0));
+ accounts->statusFlags |= (CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0));
- if (CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) &~ CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))
+ if (CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0))
accounts->statusCount++;
if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
@@ -1794,8 +1791,7 @@ static int OnModulesLoaded(WPARAM wParam, LPARAM lParam) HookEvent(ME_CLIST_PREBUILDSTATUSMENU, ChangeStatusMsgPrebuild);
ChangeStatusMsgPrebuild(0, 0);
- if (ServiceExists(MS_VARS_REGISTERTOKEN))
- {
+ if (ServiceExists(MS_VARS_REGISTERTOKEN)) {
TOKENREGISTER tr = {0};
tr.cbSize = sizeof(TOKENREGISTER);
tr.memType = TR_MEM_MIRANDA;
@@ -1805,8 +1801,7 @@ static int OnModulesLoaded(WPARAM wParam, LPARAM lParam) tr.szHelpText = LPGEN("External Applications")"\t"LPGEN("retrieves song name of the song currently playing in Winamp (Simple Status Message compatible)");
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
- if (db_get_b(NULL, "SimpleStatusMsg", "ExclDateToken", 0) != 0)
- {
+ if (db_get_b(NULL, "SimpleStatusMsg", "ExclDateToken", 0) != 0) {
tr.tszTokenString = _T("date");
tr.parseFunctionT = ParseDate;
tr.szHelpText = LPGEN("Miranda Related")"\t"LPGEN("get the date (Simple Status Message compatible)");
@@ -1817,8 +1812,7 @@ static int OnModulesLoaded(WPARAM wParam, LPARAM lParam) /* if (db_get_b(NULL, "SimpleStatusMsg", "AmpLeaveTitle", 1))*/ {
DBVARIANT dbv;
- if (!db_get_ts(NULL, "SimpleStatusMsg", "AmpLastTitle", &dbv))
- {
+ if (!db_get_ts(NULL, "SimpleStatusMsg", "AmpLastTitle", &dbv)) {
g_ptszWinampSong = mir_tstrdup(dbv.ptszVal);
db_free(&dbv);
}
@@ -1837,21 +1831,16 @@ static int OnModulesLoaded(WPARAM wParam, LPARAM lParam) if (accounts->statusCount == 0)
return 0;
- if (!ServiceExists(MS_SS_GETPROFILECOUNT))
- {
+ if (!ServiceExists(MS_SS_GETPROFILECOUNT)) {
if (db_get_b(NULL, "SimpleStatusMsg", "GlobalStatusDelay", 1))
- {
SetTimer(NULL, 0, db_get_w(NULL, "SimpleStatusMsg", "SetStatusDelay", 300), (TIMERPROC)SetStartupStatusGlobal);
- }
- else
- {
- g_uSetStatusTimer = (UINT_PTR*)mir_alloc(sizeof(UINT_PTR) * accounts->count);
- for (int i = 0; i < accounts->count; ++i)
- {
+ else {
+ g_uSetStatusTimer = (UINT_PTR *)mir_alloc(sizeof(UINT_PTR) * accounts->count);
+ for (int i = 0; i < accounts->count; ++i) {
if (!IsAccountEnabled(accounts->pa[i]))
continue;
- if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) &~ CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)))
+ if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)))
continue;
char szSetting[80];
@@ -1866,16 +1855,14 @@ static int OnModulesLoaded(WPARAM wParam, LPARAM lParam) static int OnOkToExit(WPARAM wParam, LPARAM lParam)
{
- if (accounts->statusCount)
- {
+ if (accounts->statusCount) {
char szSetting[80];
- for (int i = 0; i < accounts->count; ++i)
- {
+ for (int i = 0; i < accounts->count; ++i) {
if (!IsAccountEnabled(accounts->pa[i]))
continue;
- if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) &~ CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)))
+ if (!(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_5, 0)))
continue;
mir_snprintf(szSetting, SIZEOF(szSetting), "Last%sStatus", accounts->pa[i]->szModuleName);
@@ -1907,7 +1894,7 @@ static int OnPreShutdown(WPARAM wParam, LPARAM lParam) //remember to mir_free() the return value
static INT_PTR sttGetAwayMessageT(WPARAM wParam, LPARAM lParam)
{
- return (INT_PTR)GetAwayMessage((int)wParam, (char*)lParam, TRUE, NULL);
+ return (INT_PTR)GetAwayMessage((int)wParam, (char *)lParam, TRUE, NULL);
}
extern "C" int __declspec(dllexport) Load(void)
@@ -1915,7 +1902,7 @@ extern "C" int __declspec(dllexport) Load(void) mir_getLP(&pluginInfo);
mir_getCLI();
- hwndSAMsgDialog = NULL;
+ hwndSAMsgDialog = NULL;
accounts = (PROTOACCOUNTS *)mir_alloc(sizeof(PROTOACCOUNTS));
db_set_w(NULL, "CList", "Status", (WORD)ID_STATUS_OFFLINE);
diff --git a/plugins/SimpleStatusMsg/src/msgbox.cpp b/plugins/SimpleStatusMsg/src/msgbox.cpp index acbe2b22ea..57399207fe 100644 --- a/plugins/SimpleStatusMsg/src/msgbox.cpp +++ b/plugins/SimpleStatusMsg/src/msgbox.cpp @@ -52,8 +52,7 @@ typedef struct {
clock_t ctLastDblClk;
UINT uClocksPerDblClk;
-}
-MsgEditCtrl;
+} MsgEditCtrl;
HIMAGELIST AddOtherIconsToImageList(struct MsgBoxData *data)
{
@@ -73,7 +72,8 @@ HIMAGELIST AddStatusIconsToImageList(const char *szProto, int status_flags) int i;
for (i = 0; i < 9; ++i)
- if (Proto_Status2Flag(ID_STATUS_ONLINE + i) & status_flags) num_icons++;
+ if (Proto_Status2Flag(ID_STATUS_ONLINE + i) & status_flags)
+ num_icons++;
HIMAGELIST himlIcons = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, num_icons, 0);
HICON hicon = LoadSkinnedProtoIcon(szProto, ID_STATUS_OFFLINE);
@@ -82,10 +82,8 @@ HIMAGELIST AddStatusIconsToImageList(const char *szProto, int status_flags) statusicon_nr[0] = 0;
int j = 1;
- for (i = 0; i < 9; ++i)
- {
- if (Proto_Status2Flag(ID_STATUS_ONLINE + i) & status_flags)
- {
+ for (i = 0; i < 9; ++i) {
+ if (Proto_Status2Flag(ID_STATUS_ONLINE + i) & status_flags) {
hicon = LoadSkinnedProtoIcon(szProto, ID_STATUS_ONLINE + i);
ImageList_AddIcon(himlIcons, hicon);
Skin_ReleaseIcon(hicon);
@@ -96,7 +94,7 @@ HIMAGELIST AddStatusIconsToImageList(const char *szProto, int status_flags) statusicon_nr[i + 1] = 0;
}
- return himlIcons;
+ return himlIcons;
}
HWND WINAPI CreateStatusComboBoxEx(HWND hwndDlg, struct MsgBoxData *data)
@@ -118,15 +116,14 @@ HWND WINAPI CreateStatusComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) cbei.mask = CBEIF_LPARAM | CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
if (data->m_bOnStartup)
- status_desc = (TCHAR*)TranslateT("<startup>");
+ status_desc = (TCHAR *)TranslateT("<startup>");
else
- status_desc = (TCHAR*)TranslateT("<current>");
+ status_desc = (TCHAR *)TranslateT("<current>");
cbei.iItem = j;
cbei.pszText = (LPTSTR)status_desc;
cbei.cchTextMax = sizeof(status_desc);
- if (data->m_szProto || data->m_iStatus == ID_STATUS_CURRENT)
- {
+ if (data->m_szProto || data->m_iStatus == ID_STATUS_CURRENT) {
if (data->m_bOnStartup)
j = GetStartupStatus(data->m_szProto) - ID_STATUS_OFFLINE;
else
@@ -135,10 +132,10 @@ HWND WINAPI CreateStatusComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) else
j = data->m_iStatus - ID_STATUS_OFFLINE;
- if (j < 0 || j > 9) j = 0; // valid status modes only
+ if (j < 0 || j > 9)
+ j = 0; // valid status modes only
- if (data->m_iDlgFlags & DLG_SHOW_STATUS_ICONS)
- {
+ if (data->m_iDlgFlags & DLG_SHOW_STATUS_ICONS) {
cbei.iImage = statusicon_nr[j];
cbei.iSelectedImage = statusicon_nr[j];
}
@@ -151,20 +148,17 @@ HWND WINAPI CreateStatusComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) SendMessage(handle, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
j++;
- for (int i = 0; i < 10; ++i)
- {
- if ((Proto_Status2Flag(ID_STATUS_OFFLINE + i) & data->m_iStatusModes) || i == 0)
- {
+ for (int i = 0; i < 10; ++i) {
+ if ((Proto_Status2Flag(ID_STATUS_OFFLINE + i) & data->m_iStatusModes) || i == 0) {
status_desc = pcli->pfnGetStatusModeDescription(ID_STATUS_OFFLINE + i, 0);
cbei.iItem = j;
cbei.pszText = (LPTSTR)status_desc;
cbei.cchTextMax = sizeof(status_desc);
- if (data->m_iDlgFlags & DLG_SHOW_STATUS_ICONS)
- {
+ if (data->m_iDlgFlags & DLG_SHOW_STATUS_ICONS) {
cbei.iImage = j - 1;
cbei.iSelectedImage = j - 1;
}
- cbei.lParam = (LPARAM)ID_STATUS_OFFLINE + i;
+ cbei.lParam = (LPARAM)ID_STATUS_OFFLINE + i;
if (ID_STATUS_OFFLINE + i == data->m_iInitialStatus)
cur_sel = j;
@@ -175,8 +169,7 @@ HWND WINAPI CreateStatusComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) }
}
- if (!data->m_szProto && (data->m_iDlgFlags & DLG_SHOW_STATUS_PROFILES) && ServiceExists(MS_SS_GETPROFILECOUNT))
- {
+ if (!data->m_szProto && (data->m_iDlgFlags & DLG_SHOW_STATUS_PROFILES) && ServiceExists(MS_SS_GETPROFILECOUNT)) {
int defaultProfile;
int profileCount = (int)CallService(MS_SS_GETPROFILECOUNT, (WPARAM)&defaultProfile, 0);
@@ -184,16 +177,17 @@ HWND WINAPI CreateStatusComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) TCHAR tszProfileName[128];
CallService(MS_SS_GETPROFILENAME, (WPARAM)i, (LPARAM)tszProfileName);
- cbei.iItem = j;
- cbei.pszText = (LPTSTR)tszProfileName;
- cbei.cchTextMax = SIZEOF(tszProfileName);
+ cbei.iItem = j;
+ cbei.pszText = (LPTSTR)tszProfileName;
+ cbei.cchTextMax = SIZEOF(tszProfileName);
if (data->m_iDlgFlags & DLG_SHOW_STATUS_ICONS) {
int k = GetCurrentStatus(NULL) - ID_STATUS_OFFLINE;
- if (k < 0 || k > 9) k = 0; // valid status modes only
+ if (k < 0 || k > 9)
+ k = 0; // valid status modes only
cbei.iImage = statusicon_nr[k];
cbei.iSelectedImage = statusicon_nr[k];
}
- cbei.lParam = (LPARAM)40083+i;
+ cbei.lParam = (LPARAM)40083 + i;
mir_free(status_desc);
@@ -205,8 +199,7 @@ HWND WINAPI CreateStatusComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) if (!(data->m_iDlgFlags & DLG_SHOW_STATUS_ICONS))
SendMessage(handle, CB_SETITEMHEIGHT, 0, (LPARAM)16);
- else
- {
+ else {
SendMessage(handle, CB_SETITEMHEIGHT, 0, (LPARAM)18);
SendMessage(handle, CBEM_SETIMAGELIST, 0, (LPARAM)data->status_icons);
}
@@ -214,7 +207,7 @@ HWND WINAPI CreateStatusComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) SendMessage(handle, CB_SETCURSEL, (WPARAM)cur_sel, 0);
SendMessage(handle, CB_SETITEMHEIGHT, (WPARAM)-1, (LPARAM)16);
- return handle;
+ return handle;
}
#define HISTORY_MSG 1
@@ -244,22 +237,19 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) j = db_get_w(NULL, "SimpleStatusMsg", "LMMsg", 1);
- for (i = 1; i <= data->max_hist_msgs; ++i)
- {
+ for (i = 1; i <= data->max_hist_msgs; ++i) {
// history messages
- if (j < 1) j = data->max_hist_msgs;
+ if (j < 1)
+ j = data->max_hist_msgs;
mir_snprintf(buff, SIZEOF(buff), "SMsg%d", j);
j--;
- if (!db_get_ts(NULL, "SimpleStatusMsg", buff, &dbv))
- {
- if (dbv.ptszVal != NULL && dbv.ptszVal != '\0')
- {
+ if (!db_get_ts(NULL, "SimpleStatusMsg", buff, &dbv)) {
+ if (dbv.ptszVal != NULL && dbv.ptszVal != '\0') {
found = TRUE;
cbei.iItem = -1;
cbei.pszText = (LPTSTR)dbv.ptszVal;
cbei.cchTextMax = sizeof(dbv.ptszVal);
- if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS)
- {
+ if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) {
cbei.iImage = I_ICON_HIST;
cbei.iSelectedImage = I_ICON_HIST;
}
@@ -267,8 +257,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) cbei.iIndent = 0;
cbei.lParam = MAKELPARAM(HISTORY_MSG, j + 1);
- if (SendMessage(handle, CBEM_INSERTITEM, 0, (LPARAM)&cbei) == -1)
- {
+ if (SendMessage(handle, CBEM_INSERTITEM, 0, (LPARAM)&cbei) == -1) {
db_free(&dbv);
break;
}
@@ -279,28 +268,22 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) data->m_bIsMsgHistory = found;
- if ((data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT))
- {
- if (found)
- {
+ if ((data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) {
+ if (found) {
if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BCLEAR)))
EnableWindow(GetDlgItem(hwndDlg, IDC_BCLEAR), TRUE);
}
else if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BCLEAR)))
EnableWindow(GetDlgItem(hwndDlg, IDC_BCLEAR), FALSE);
}
- else if (data->m_iDlgFlags & DLG_SHOW_BUTTONS_INLIST)
- {
- if (found)
- {
- if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS)
- {
+ else if (data->m_iDlgFlags & DLG_SHOW_BUTTONS_INLIST) {
+ if (found) {
+ if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) {
mir_sntprintf(text, SIZEOF(text), TranslateT("Clear history"));
cbei.iImage = I_ICON_CLEAR;
cbei.iSelectedImage = I_ICON_CLEAR;
}
- else
- {
+ else {
mir_sntprintf(text, SIZEOF(text), _T("## %s ##"), TranslateT("Clear history"));
cbei.iIndent = 1;
}
@@ -312,14 +295,12 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) }
cbei.iItem = -1;
- if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS)
- {
+ if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) {
mir_sntprintf(text, SIZEOF(text), TranslateT("Add to predefined"));
cbei.iImage = I_ICON_ADD;
cbei.iSelectedImage = I_ICON_ADD;
}
- else
- {
+ else {
mir_sntprintf(text, SIZEOF(text), _T("## %s ##"), TranslateT("Add to predefined"));
cbei.iIndent = 1;
}
@@ -328,14 +309,12 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) cbei.lParam = MAKELPARAM(ADD_MSG, 0);
SendMessage(handle, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
- if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS)
- {
+ if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) {
mir_sntprintf(text, SIZEOF(text), TranslateT("Delete selected"));
cbei.iImage = I_ICON_DEL;
cbei.iSelectedImage = I_ICON_DEL;
}
- else
- {
+ else {
cbei.iIndent = 1;
mir_sntprintf(text, SIZEOF(text), _T("## %s ##"), TranslateT("Delete selected"));
}
@@ -346,10 +325,8 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) SendMessage(handle, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
}
- if ((data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT))
- {
- if (data->num_def_msgs || found)
- {
+ if ((data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) {
+ if (data->num_def_msgs || found) {
if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BDEL)))
EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), TRUE);
}
@@ -357,16 +334,12 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE);
}
- for (i = 1; i <= data->num_def_msgs; ++i)
- {
+ for (i = 1; i <= data->num_def_msgs; ++i) {
// predefined messages
mir_snprintf(buff, SIZEOF(buff), "DefMsg%d", i);
- if (!db_get_ts(NULL, "SimpleStatusMsg", buff, &dbv))
- {
- if (dbv.ptszVal)
- {
- if (!lstrlen(dbv.ptszVal))
- {
+ if (!db_get_ts(NULL, "SimpleStatusMsg", buff, &dbv)) {
+ if (dbv.ptszVal) {
+ if (!lstrlen(dbv.ptszVal)) {
db_free(&dbv);
continue;
}
@@ -374,8 +347,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) cbei.iItem = -1;
cbei.pszText = (LPTSTR)dbv.ptszVal;
cbei.cchTextMax = sizeof(dbv.ptszVal);
- if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS)
- {
+ if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) {
cbei.iImage = I_ICON_MSG;
cbei.iSelectedImage = I_ICON_MSG;
}
@@ -383,39 +355,35 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) cbei.iIndent = 0;
cbei.lParam = MAKELPARAM(PREDEFINED_MSG, i);
- if (SendMessage(handle,CBEM_INSERTITEM,0,(LPARAM)&cbei) == -1)
+ if (SendMessage(handle, CBEM_INSERTITEM, 0, (LPARAM)&cbei) == -1)
break;
}
db_free(&dbv);
}
- }
+ }
- if (db_get_b(NULL, "SimpleStatusMsg", "PutDefInList", 0))
- {
+ if (db_get_b(NULL, "SimpleStatusMsg", "PutDefInList", 0)) {
cbei.iItem = -1;
cbei.pszText = (LPTSTR)GetDefaultMessage(data->m_iStatus);
cbei.cchTextMax = sizeof(GetDefaultMessage(data->m_iStatus));
- if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS)
- {
- cbei.iImage = I_ICON_MSG;
+ if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) {
+ cbei.iImage = I_ICON_MSG;
cbei.iSelectedImage = I_ICON_MSG;
}
else
cbei.iIndent = 0;
cbei.lParam = MAKELPARAM(DEFAULT_MSG, 0);
- SendMessage(handle,CBEM_INSERTITEM,0,(LPARAM)&cbei);
+ SendMessage(handle, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
}
if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS)
SendMessage(handle, CBEM_SETIMAGELIST, 0, (LPARAM)data->other_icons);
- if (!(data->m_iDlgFlags & DLG_SHOW_STATUS))
- {
+ if (!(data->m_iDlgFlags & DLG_SHOW_STATUS)) {
SetWindowPos(handle, NULL, 11, 11, 290, 20, SWP_NOACTIVATE);
SendMessage(handle, CB_SETDROPPEDWIDTH, (WPARAM)290, 0);
}
- else
- {
+ else {
SetWindowPos(handle, NULL, 127, 11, 174, 20, SWP_NOACTIVATE);
SendMessage(handle, CB_SETDROPPEDWIDTH, (WPARAM)250, 0);
}
@@ -428,7 +396,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) if (((!(data->m_iDlgFlags & DLG_SHOW_BUTTONS)) && (!(data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) && (!(data->m_iDlgFlags & DLG_SHOW_BUTTONS_INLIST))) && !found && !data->num_def_msgs)
EnableWindow(handle, FALSE);
- return handle;
+ return handle;
}
VOID APIENTRY HandlePopupMenu(HWND hwnd, POINT pt, HWND edit_control)
@@ -441,12 +409,11 @@ VOID APIENTRY HandlePopupMenu(HWND hwnd, POINT pt, HWND edit_control) TranslateMenu(hmenuTrackPopup);
- ClientToScreen(hwnd, (LPPOINT) &pt);
+ ClientToScreen(hwnd, (LPPOINT)&pt);
LPDWORD sel_s = NULL, sel_e = NULL;
SendMessage(edit_control, EM_GETSEL, (WPARAM)&sel_s, (LPARAM)&sel_e);
- if (sel_s == sel_e)
- {
+ if (sel_s == sel_e) {
EnableMenuItem(hmenuTrackPopup, IDM_COPY, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(hmenuTrackPopup, IDM_CUT, MF_BYCOMMAND | MF_GRAYED);
}
@@ -461,8 +428,7 @@ VOID APIENTRY HandlePopupMenu(HWND hwnd, POINT pt, HWND edit_control) DeleteMenu(hmenuTrackPopup, 7, MF_BYPOSITION);
int m_selection = TrackPopupMenu(hmenuTrackPopup, TPM_LEFTALIGN | TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL);
- switch (m_selection)
- {
+ switch (m_selection) {
case IDM_COPY:
SendMessage(edit_control, WM_COPY, 0, 0);
break;
@@ -485,13 +451,11 @@ VOID APIENTRY HandlePopupMenu(HWND hwnd, POINT pt, HWND edit_control) break;
case ID__FORTUNEAWAYMSG:
- CallService(MS_UTILS_OPENURL,1,(LPARAM)"http://miranda-ng.org/");
+ CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://miranda-ng.org/");
break;
case ID__VARIABLES:
-
- CallService(MS_UTILS_OPENURL,1,(LPARAM)"http://miranda-ng.org/");
-
+ CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://miranda-ng.org/");
break;
case ID__VARIABLES_MOREVARIABLES:
@@ -507,20 +471,18 @@ VOID APIENTRY HandlePopupMenu(HWND hwnd, POINT pt, HWND edit_control) }
default:
- if (!OpenClipboard(GetParent(hwnd))) break;
- if (EmptyClipboard())
- {
+ if (!OpenClipboard(GetParent(hwnd)))
+ break;
+ if (EmptyClipboard()) {
TCHAR item_string[128];
int len;
GetMenuString(hmenu, m_selection, (LPTSTR)&item_string, 128, MF_BYCOMMAND);
len = lstrlen(item_string);
- if (len)
- {
+ if (len) {
LPTSTR lptstrCopy;
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(TCHAR));
- if (hglbCopy == NULL)
- {
+ if (hglbCopy == NULL) {
CloseClipboard();
break;
}
@@ -549,11 +511,9 @@ static LRESULT CALLBACK EditBoxSubProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L 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;
}
@@ -568,23 +528,19 @@ 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;
}
- if (wParam == 1 && GetKeyState(VK_CONTROL) & 0x8000) // Ctrl + A
- {
+ if (wParam == 1 && GetKeyState(VK_CONTROL) & 0x8000) { // Ctrl + A
SendMessage(hwndDlg, EM_SETSEL, 0, -1);
return 0;
}
- if (wParam == 23 && GetKeyState(VK_CONTROL) & 0x8000) // Ctrl + W
- {
+ if (wParam == 23 && GetKeyState(VK_CONTROL) & 0x8000) { // Ctrl + W
SendMessage(GetParent(hwndDlg), WM_COMMAND, IDC_CANCEL, 0);
return 0;
}
- if (wParam == 127 && GetKeyState(VK_CONTROL) & 0x8000) // Ctrl + Backspace
- {
+ if (wParam == 127 && GetKeyState(VK_CONTROL) & 0x8000) { // Ctrl + Backspace
DWORD start, end;
TCHAR *text;
int textLen;
@@ -605,9 +561,8 @@ static LRESULT CALLBACK EditBoxSubProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L case WM_LBUTTONDBLCLK:
{
- MsgEditCtrl* mec = (MsgEditCtrl*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- if (mec != NULL)
- {
+ MsgEditCtrl *mec = (MsgEditCtrl *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ if (mec != NULL) {
mec->ctLastDblClk = clock();
mec->uClocksPerDblClk = GetDoubleClickTime() * CLOCKS_PER_SEC / 1000;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)mec);
@@ -617,9 +572,8 @@ static LRESULT CALLBACK EditBoxSubProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L case WM_LBUTTONDOWN:
{
- MsgEditCtrl* mec = (MsgEditCtrl*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- if (mec != NULL && UINT(clock() - mec->ctLastDblClk) < mec->uClocksPerDblClk)
- {
+ MsgEditCtrl *mec = (MsgEditCtrl *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ if (mec != NULL && UINT(clock() - mec->ctLastDblClk) < mec->uClocksPerDblClk) {
SendMessage(hwndDlg, EM_SETSEL, 0, -1);
return 0;
}
@@ -628,14 +582,14 @@ static LRESULT CALLBACK EditBoxSubProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L case WM_SETFOCUS:
{
- MsgEditCtrl* mec = (MsgEditCtrl*)mir_calloc(sizeof(MsgEditCtrl));
+ MsgEditCtrl *mec = (MsgEditCtrl *)mir_calloc(sizeof(MsgEditCtrl));
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)mec);
break;
}
case WM_KILLFOCUS:
{
- MsgEditCtrl* mec = (MsgEditCtrl*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ MsgEditCtrl *mec = (MsgEditCtrl *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
mir_free(mec);
mec = NULL;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)mec);
@@ -659,8 +613,7 @@ int AddToPredefined(HWND hwndDlg, struct MsgBoxData *data) return -1;
num_items = SendMessage(data->recent_cbex, CB_GETCOUNT, 0, 0) - 1;
- for (int i = 1; i <= data->num_def_msgs; i++, num_items--)
- {
+ for (int i = 1; i <= data->num_def_msgs; i++, num_items--) {
newitem.mask = CBEIF_LPARAM | CBEIF_TEXT;
newitem.iItem = num_items;
newitem.cchTextMax = SIZEOF(text);
@@ -675,16 +628,14 @@ int AddToPredefined(HWND hwndDlg, struct MsgBoxData *data) data->m_bPredefChanged = TRUE;
newitem.iItem = -1;
- newitem.pszText = (LPTSTR)msg;
+ newitem.pszText = (LPTSTR)msg;
newitem.cchTextMax = SIZEOF(msg);
- if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS)
- {
+ if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) {
newitem.mask = CBEIF_LPARAM | CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
newitem.iImage = I_ICON_MSG;
newitem.iSelectedImage = I_ICON_MSG;
}
- else
- {
+ else {
newitem.mask = CBEIF_LPARAM | CBEIF_TEXT | CBEIF_INDENT;
newitem.iIndent = 0;
}
@@ -698,14 +649,12 @@ void ClearHistory(struct MsgBoxData *data, int cur_sel) int i, num_items;
char text[16], buff2[80];
- for (i = 1; i <= data->max_hist_msgs; i++)
- {
+ for (i = 1; i <= data->max_hist_msgs; i++) {
mir_snprintf(text, SIZEOF(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 (i = 0; i < accounts->count; i++) {
if (!IsAccountEnabled(accounts->pa[i]))
continue;
@@ -727,8 +676,7 @@ void ClearHistory(struct MsgBoxData *data, int cur_sel) if ((!(data->m_iDlgFlags & DLG_SHOW_BUTTONS)) && (!(data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)))
SendMessage(data->recent_cbex, CBEM_DELETEITEM, (WPARAM)cur_sel, 0);
- for (i = num_items; i >= 0; i--)
- {
+ for (i = num_items; i >= 0; i--) {
histitem.mask = CBEIF_LPARAM;
histitem.iItem = i;
SendMessage(data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&histitem);
@@ -747,13 +695,12 @@ void DisplayCharsCount(struct MsgBoxData *dlg_data, HWND hwndDlg) return;
len = GetDlgItemText(hwndDlg, IDC_EDIT1, msg, SIZEOF(msg));
- if (db_get_b(NULL, "SimpleStatusMsg", "RemoveCR", 0))
- {
- int index, num_lines = SendMessage(GetDlgItem(hwndDlg, IDC_EDIT1), EM_GETLINECOUNT, 0, 0);
- for (int i = 1; i < num_lines; ++i)
- {
+ if (db_get_b(NULL, "SimpleStatusMsg", "RemoveCR", 0)) {
+ int index, num_lines = SendMessage(GetDlgItem(hwndDlg, IDC_EDIT1), EM_GETLINECOUNT, 0, 0);
+ for (int i = 1; i < num_lines; ++i) {
index = SendMessage(GetDlgItem(hwndDlg, IDC_EDIT1), EM_LINEINDEX, (WPARAM)i, 0);
- if (msg[index - 1] == '\n') lines++;
+ if (msg[index - 1] == '\n')
+ lines++;
}
}
mir_sntprintf(status_text, SIZEOF(status_text), TranslateT("OK (%d)"), len - (lines - 1));
@@ -772,21 +719,16 @@ void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus) mir_snprintf(setting, SIZEOF(setting), "%sFlags", data->m_szProto ? data->m_szProto : "");
flags = db_get_b(NULL, "SimpleStatusMsg", (char *)StatusModeToDbSetting(iStatus, setting), STATUS_DEFAULT);
- if (flags & STATUS_LAST_MSG)
- {
+ if (flags & STATUS_LAST_MSG) {
if (data->m_szProto)
mir_snprintf(setting, SIZEOF(setting), "Last%sMsg", data->m_szProto);
else
mir_snprintf(setting, SIZEOF(setting), "LastMsg");
- if (!db_get(NULL, "SimpleStatusMsg", setting, &dbv))
- {
- if (dbv.pszVal && strlen(dbv.pszVal))
- {
- if (!db_get_ts(NULL, "SimpleStatusMsg", dbv.pszVal, &dbv2))
- {
- if (dbv2.ptszVal && lstrlen(dbv2.ptszVal))
- {
+ if (!db_get(NULL, "SimpleStatusMsg", setting, &dbv)) {
+ if (dbv.pszVal && strlen(dbv.pszVal)) {
+ if (!db_get_ts(NULL, "SimpleStatusMsg", dbv.pszVal, &dbv2)) {
+ if (dbv2.ptszVal && lstrlen(dbv2.ptszVal)) {
SetDlgItemText(hwndDlg, IDC_EDIT1, dbv2.ptszVal);
fcursel = SendMessage(data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)dbv2.ptszVal);
if (fcursel != CB_ERR)
@@ -798,26 +740,22 @@ void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus) db_free(&dbv);
}
}
- else if (flags & STATUS_DEFAULT_MSG)
- {
+ else if (flags & STATUS_DEFAULT_MSG) {
SetDlgItemText(hwndDlg, IDC_EDIT1, GetDefaultMessage(iStatus));
- if (db_get_b(NULL, "SimpleStatusMsg", "PutDefInList", 0))
- {
+ if (db_get_b(NULL, "SimpleStatusMsg", "PutDefInList", 0)) {
fcursel = SendMessage(data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)GetDefaultMessage(iStatus));
if (fcursel != CB_ERR)
SendMessage(data->recent_cbex, CB_SETCURSEL, (WPARAM)fcursel, 0);
}
}
- else if (flags & STATUS_THIS_MSG)
- {
+ else if (flags & STATUS_THIS_MSG) {
if (data->m_szProto)
mir_snprintf(setting, SIZEOF(setting), "%sDefault", data->m_szProto);
else
mir_snprintf(setting, SIZEOF(setting), "Default");
- if (!db_get_ts(NULL, "SRAway", StatusModeToDbSetting(iStatus, setting), &dbv))
- {
+ 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);
if (fcursel != CB_ERR)
@@ -825,15 +763,13 @@ void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus) db_free(&dbv);
}
}
- else if (flags & STATUS_LAST_STATUS_MSG)
- {
+ else if (flags & STATUS_LAST_STATUS_MSG) {
if (data->m_szProto)
mir_snprintf(setting, SIZEOF(setting), "%sMsg", data->m_szProto);
else
mir_snprintf(setting, SIZEOF(setting), "Msg");
- if (!db_get_ts(NULL, "SRAway", StatusModeToDbSetting(iStatus, setting), &dbv))
- {
+ 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);
if (fcursel != CB_ERR)
@@ -852,24 +788,23 @@ void ChangeDlgStatus(HWND hwndDlg, struct MsgBoxData *msgbox_data, int iStatus) BOOL bDisabled = msgbox_data->m_szProto && !(CallProtoService(msgbox_data->m_szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND);
mir_sntprintf(szProtoName, SIZEOF(szProtoName), msgbox_data->m_szProto ? ProtoGetAccount(msgbox_data->m_szProto)->tszAccountName : TranslateT("global"));
- if (iStatus == ID_STATUS_CURRENT)
- {
+ if (iStatus == ID_STATUS_CURRENT) {
if (msgbox_data->m_bOnStartup)
mir_sntprintf(szTitle, SIZEOF(szTitle), TranslateT("%s message (%s)"), TranslateT("<startup>"), szProtoName);
else
mir_sntprintf(szTitle, SIZEOF(szTitle), TranslateT("%s message (%s)"), TranslateT("<current>"), szProtoName);
}
- else if (iStatus > ID_STATUS_CURRENT)
- {
+ else if (iStatus > ID_STATUS_CURRENT) {
TCHAR buff[128];
char buff1[128];
CallService(MS_SS_GETPROFILENAME, iStatus - 40083, (LPARAM)buff1);
MultiByteToWideChar(CallService(MS_LANGPACK_GETCODEPAGE, 0, 0), 0, buff1, -1, buff, 128);
- mir_sntprintf(szTitle, SIZEOF(szTitle), TranslateT("%s message (%s)"), (TCHAR*)buff, szProtoName);
+ mir_sntprintf(szTitle, SIZEOF(szTitle), TranslateT("%s message (%s)"), (TCHAR *)buff, szProtoName);
}
- else mir_sntprintf(szTitle, SIZEOF(szTitle), TranslateT("%s message (%s)"), pcli->pfnGetStatusModeDescription(iStatus, 0), szProtoName);
+ else
+ mir_sntprintf(szTitle, SIZEOF(szTitle), TranslateT("%s message (%s)"), pcli->pfnGetStatusModeDescription(iStatus, 0), szProtoName);
SetWindowText(hwndDlg, szTitle);
if (iStatus == ID_STATUS_CURRENT)
@@ -896,38 +831,31 @@ void ChangeDlgStatus(HWND hwndDlg, struct MsgBoxData *msgbox_data, int iStatus) // TODO what if num_start <= 0 ?
if (GetDlgItemText(hwndDlg, IDC_EDIT1, msg, SIZEOF(msg)))
fcursel = SendMessage(msgbox_data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)msg);
- if (fcursel != CB_ERR)
- {
+ if (fcursel != CB_ERR) {
SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, fcursel, 0);
msgbox_data->curr_sel_msg = fcursel;
}
- if ((msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT))
- {
- if (!GetDlgItemText(hwndDlg, IDC_EDIT1, msg, SIZEOF(msg)))
- {
+ if ((msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) {
+ if (!GetDlgItemText(hwndDlg, IDC_EDIT1, msg, SIZEOF(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);
- if (num_items)
- {
- if (msgbox_data->curr_sel_msg == -1)
- {
+ if (num_items) {
+ if (msgbox_data->curr_sel_msg == -1) {
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BDEL)))
EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE);
}
- else
- {
+ else {
COMBOBOXEXITEM cbitem = {0};
cbitem.mask = CBEIF_LPARAM | CBEIF_TEXT;
cbitem.iItem = msgbox_data->curr_sel_msg;
cbitem.cchTextMax = SIZEOF(msg);
cbitem.pszText = msg;
SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&cbitem);
- if (LOWORD(cbitem.lParam) == PREDEFINED_MSG)
- {
+ if (LOWORD(cbitem.lParam) == PREDEFINED_MSG) {
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD)))
EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE);
}
@@ -943,15 +871,13 @@ void ChangeDlgStatus(HWND hwndDlg, struct MsgBoxData *msgbox_data, int iStatus) }
}
}
- else
- {
+ else {
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1)))
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT1), FALSE);
if (IsWindowEnabled(msgbox_data->recent_cbex))
EnableWindow(msgbox_data->recent_cbex, FALSE);
- if ((msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT))
- {
+ if ((msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) {
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD)))
EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE);
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BCLEAR)))
@@ -967,10 +893,9 @@ void ChangeDlgStatus(HWND hwndDlg, struct MsgBoxData *msgbox_data, int iStatus) INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- struct MsgBoxData *msgbox_data = (struct MsgBoxData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ struct MsgBoxData *msgbox_data = (struct MsgBoxData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (uMsg)
- {
+ switch (uMsg) {
case WM_INITDIALOG:
{
TCHAR szTitle[256], szFormat[256], szProtoName[128];
@@ -985,18 +910,18 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA InitCommonControlsEx(&icex);
TranslateDialogDefault(hwndDlg);
- init_data = (struct MsgBoxInitData*)lParam;
+ init_data = (struct MsgBoxInitData *)lParam;
GetWindowText(hwndDlg, szFormat, SIZEOF(szFormat));
mir_sntprintf(szProtoName, SIZEOF(szProtoName), init_data->m_szProto ? ProtoGetAccount(init_data->m_szProto)->tszAccountName : TranslateT("global"));
- if (init_data->m_iStatus == ID_STATUS_CURRENT)
- {
+ if (init_data->m_iStatus == ID_STATUS_CURRENT) {
if (init_data->m_bOnStartup)
mir_sntprintf(szTitle, SIZEOF(szTitle), szFormat, TranslateT("<startup>"), szProtoName);
else
mir_sntprintf(szTitle, SIZEOF(szTitle), szFormat, TranslateT("<current>"), szProtoName);
}
- else mir_sntprintf(szTitle, SIZEOF(szTitle), szFormat, pcli->pfnGetStatusModeDescription(init_data->m_iStatus, 0), szProtoName);
+ else
+ mir_sntprintf(szTitle, SIZEOF(szTitle), szFormat, pcli->pfnGetStatusModeDescription(init_data->m_iStatus, 0), szProtoName);
SetWindowText(hwndDlg, szTitle);
int icoStatus = ID_STATUS_OFFLINE;
@@ -1037,8 +962,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (copy_init_data->m_iDlgFlags & DLG_SHOW_LIST_ICONS)
copy_init_data->other_icons = AddOtherIconsToImageList(copy_init_data);
- if ((copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT))
- {
+ if ((copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) {
SendMessage(GetDlgItem(hwndDlg, IDC_BADD), BUTTONADDTOOLTIP, (WPARAM)Translate("Add to predefined"), 0);
SendMessage(GetDlgItem(hwndDlg, IDC_BADD), BM_SETIMAGE, IMAGE_ICON, (LPARAM)copy_init_data->icon[I_ICON_ADD]);
EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), TRUE);
@@ -1052,25 +976,22 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA SendMessage(GetDlgItem(hwndDlg, IDC_BCLEAR), BM_SETIMAGE, IMAGE_ICON, (LPARAM)copy_init_data->icon[I_ICON_CLEAR]);
ShowWindow(GetDlgItem(hwndDlg, IDC_BCLEAR), TRUE);
- if (copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)
- {
+ if (copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT) {
SendMessage(GetDlgItem(hwndDlg, IDC_BADD), BUTTONSETASFLATBTN, TRUE, 0);
SendMessage(GetDlgItem(hwndDlg, IDC_BDEL), BUTTONSETASFLATBTN, TRUE, 0);
SendMessage(GetDlgItem(hwndDlg, IDC_BCLEAR), BUTTONSETASFLATBTN, TRUE, 0);
}
}
- else
- {
- SetWindowPos(GetDlgItem(hwndDlg, IDC_OK), NULL, 52, 115, 0, 0, SWP_NOSIZE|SWP_NOZORDER);
- SetWindowPos(GetDlgItem(hwndDlg, IDC_CANCEL), NULL, 160, 115, 0, 0, SWP_NOSIZE|SWP_NOZORDER);
+ else {
+ SetWindowPos(GetDlgItem(hwndDlg, IDC_OK), NULL, 52, 115, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
+ SetWindowPos(GetDlgItem(hwndDlg, IDC_CANCEL), NULL, 160, 115, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
ShowWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE);
ShowWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE);
ShowWindow(GetDlgItem(hwndDlg, IDC_BCLEAR), FALSE);
}
copy_init_data->status_cbex = CreateStatusComboBoxEx(hwndDlg, copy_init_data);
- if (copy_init_data->m_iStatus == ID_STATUS_CURRENT)
- {
+ if (copy_init_data->m_iStatus == ID_STATUS_CURRENT) {
if (copy_init_data->m_bOnStartup)
copy_init_data->m_iStatus = GetStartupStatus(copy_init_data->m_szProto);
else
@@ -1084,29 +1005,25 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA copy_init_data->m_bPredefChanged = FALSE;
SetEditControlText(copy_init_data, hwndDlg, copy_init_data->m_iStatus);
- if ((copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT))
- {
+ if ((copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) {
TCHAR msg[1024];
if (!GetDlgItemText(hwndDlg, IDC_EDIT1, msg, SIZEOF(msg)))
EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE);
- if (copy_init_data->curr_sel_msg == -1)
- {
+ if (copy_init_data->curr_sel_msg == -1) {
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BDEL)))
EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE);
}
- else
- {
+ else {
COMBOBOXEXITEM cbitem = {0};
- cbitem.mask = CBEIF_LPARAM|CBEIF_TEXT;
+ cbitem.mask = CBEIF_LPARAM | CBEIF_TEXT;
cbitem.iItem = copy_init_data->curr_sel_msg;
cbitem.cchTextMax = SIZEOF(msg);
cbitem.pszText = msg;
SendMessage(copy_init_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&cbitem);
- if (LOWORD(cbitem.lParam) == PREDEFINED_MSG)
- {
+ if (LOWORD(cbitem.lParam) == PREDEFINED_MSG) {
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD)))
EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE);
}
@@ -1120,16 +1037,15 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (copy_init_data->m_szProto && !(CallProtoService(copy_init_data->m_szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
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))
+ 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))
{
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1)))
EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT1), FALSE);
if (IsWindowEnabled(copy_init_data->recent_cbex))
EnableWindow(copy_init_data->recent_cbex, FALSE);
- if ((copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT))
- {
+ if ((copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (copy_init_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) {
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD)))
EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE);
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BCLEAR)))
@@ -1139,14 +1055,12 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA }
}
- if (db_get_b(NULL, "SimpleStatusMsg", "AutoClose", 1) && init_data->m_bOnEvent)
- {
+ if (db_get_b(NULL, "SimpleStatusMsg", "AutoClose", 1) && init_data->m_bOnEvent) {
copy_init_data->m_iCountdown = db_get_b(NULL, "SimpleStatusMsg", "DlgTime", 5);
SendMessage(hwndDlg, WM_TIMER, 0, 0);
SetTimer(hwndDlg, 1, 1000, 0);
}
- else
- {
+ else {
copy_init_data->m_iCountdown = -2;
DisplayCharsCount(copy_init_data, hwndDlg);
}
@@ -1155,8 +1069,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA copy_init_data->m_iStatus = ID_STATUS_CURRENT;
mir_subclassWindow( GetDlgItem(hwndDlg, IDC_EDIT1), EditBoxSubProc);
- if (!init_data->m_bOnEvent && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1)))
- {
+ if (!init_data->m_bOnEvent && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1))) {
SetFocus(GetDlgItem(hwndDlg, IDC_EDIT1));
SendMessage(GetDlgItem(hwndDlg, IDC_EDIT1), EM_SETSEL, 0, -1);
}
@@ -1165,8 +1078,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA mir_free(init_data);
- if (!db_get_b(NULL, "SimpleStatusMsg", "WinCentered", 1))
- {
+ if (!db_get_b(NULL, "SimpleStatusMsg", "WinCentered", 1)) {
WINDOWPLACEMENT wp;
int x, y;
@@ -1176,8 +1088,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);
@@ -1187,15 +1098,13 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA }
case WM_TIMER:
- if (msgbox_data->m_iCountdown == -1)
- {
+ 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
- {
+ else {
TCHAR str[64];
mir_sntprintf(str, SIZEOF(str), TranslateT("Closing in %d"), msgbox_data->m_iCountdown);
SetDlgItemText(hwndDlg, IDC_OK, str);
@@ -1204,22 +1113,19 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA break;
case WM_COMMAND:
- switch (LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
case IDC_OK:
{
TCHAR tszMsg[1024];
int iStatus, iMsgLen = 0, iProfileStatus = 0;
BOOL bCurrentStatus = FALSE;
- if (msgbox_data->m_iStatus == ID_STATUS_CURRENT)
- {
+ 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 == NULL)
bCurrentStatus = TRUE;
}
- else if (msgbox_data->m_iStatus >= ID_STATUS_CURRENT)
- {
+ else if (msgbox_data->m_iStatus >= ID_STATUS_CURRENT) {
iProfileStatus = msgbox_data->m_iStatus;
msgbox_data->m_iStatus = GetCurrentStatus(NULL);
}
@@ -1227,22 +1133,18 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1)))
iMsgLen = GetDlgItemText(hwndDlg, IDC_EDIT1, tszMsg, SIZEOF(tszMsg));
- if (iMsgLen == 0)
- {
+ if (iMsgLen == 0) {
char szSetting[80];
- if (msgbox_data->m_szProto)
- {
+ if (msgbox_data->m_szProto) {
mir_snprintf(szSetting, SIZEOF(szSetting), "Last%sMsg", msgbox_data->m_szProto);
db_set_s(NULL, "SimpleStatusMsg", szSetting, "");
mir_snprintf(szSetting, SIZEOF(szSetting), "%sMsg", msgbox_data->m_szProto);
db_set_ts(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, szSetting), _T(""));
}
- else
- {
+ else {
db_set_s(NULL, "SimpleStatusMsg", "LastMsg", "");
- for (int j = 0; j < accounts->count; j++)
- {
+ for (int j = 0; j < accounts->count; j++) {
if (!IsAccountEnabled(accounts->pa[j]))
continue;
@@ -1273,33 +1175,26 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA else
SetStatusMessage(msgbox_data->m_szProto, msgbox_data->m_iInitialStatus, msgbox_data->m_iStatus, 0, msgbox_data->m_bOnStartup);
}
- else
- {
+ else {
char buff[64], buff2[80];
DBVARIANT dbv;
BOOL found = FALSE;
- for (int i = 1; i <= msgbox_data->max_hist_msgs; i++)
- {
+ for (int i = 1; i <= msgbox_data->max_hist_msgs; i++) {
mir_snprintf(buff, SIZEOF(buff), "SMsg%d", i);
- if (!db_get_ts(NULL, "SimpleStatusMsg", buff, &dbv))
- {
- if (!lstrcmp(dbv.ptszVal, tszMsg))
- {
+ if (!db_get_ts(NULL, "SimpleStatusMsg", buff, &dbv)) {
+ if (!lstrcmp(dbv.ptszVal, tszMsg)) {
found = TRUE;
- if (msgbox_data->m_szProto)
- {
+ if (msgbox_data->m_szProto) {
mir_snprintf(buff2, SIZEOF(buff2), "Last%sMsg", msgbox_data->m_szProto);
db_set_s(NULL, "SimpleStatusMsg", buff2, buff);
mir_snprintf(buff2, SIZEOF(buff2), "%sMsg", msgbox_data->m_szProto);
db_set_ts(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, buff2), tszMsg);
}
- else
- {
+ else {
db_set_s(NULL, "SimpleStatusMsg", "LastMsg", buff);
- for (int j = 0; j < accounts->count; j++)
- {
+ for (int j = 0; j < accounts->count; j++) {
if (!IsAccountEnabled(accounts->pa[j]))
continue;
@@ -1327,9 +1222,8 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA }
}
- if (!found)
- {
- int last_modified_msg = db_get_w(NULL, "SimpleStatusMsg", "LMMsg", msgbox_data->max_hist_msgs);
+ 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;
@@ -1339,19 +1233,16 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA mir_snprintf(buff, SIZEOF(buff), "SMsg%d", last_modified_msg);
db_set_ts(NULL, "SimpleStatusMsg", buff, tszMsg);
- if (msgbox_data->m_szProto)
- {
+ if (msgbox_data->m_szProto) {
mir_snprintf(buff2, SIZEOF(buff2), "Last%sMsg", msgbox_data->m_szProto);
db_set_s(NULL, "SimpleStatusMsg", buff2, buff);
mir_snprintf(buff2, SIZEOF(buff2), "%sMsg", msgbox_data->m_szProto);
db_set_ts(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, buff2), tszMsg);
}
- else
- {
+ else {
db_set_s(NULL, "SimpleStatusMsg", "LastMsg", buff);
- for (int j = 0; j < accounts->count; j++)
- {
+ for (int j = 0; j < accounts->count; j++) {
if (!IsAccountEnabled(accounts->pa[j]))
continue;
@@ -1393,26 +1284,22 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA return TRUE;
case IDC_EDIT1: // Notification from the edit control
- if (msgbox_data->m_iCountdown > -2)
- {
+ if (msgbox_data->m_iCountdown > -2) {
KillTimer(hwndDlg, 1);
msgbox_data->m_iCountdown = -2;
DisplayCharsCount(msgbox_data, hwndDlg);
}
- switch (HIWORD(wParam))
- {
+ 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))
- {
+ if ((msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) {
TCHAR msg[1024];
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BDEL)))
EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE);
- if (!GetDlgItemText(hwndDlg, IDC_EDIT1, msg, SIZEOF(msg)))
- {
+ if (!GetDlgItemText(hwndDlg, IDC_EDIT1, msg, SIZEOF(msg))) {
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD)))
EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE);
}
@@ -1424,16 +1311,13 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA break;
}
- if ((HWND)lParam == msgbox_data->status_cbex)
- {
- if (msgbox_data->m_iCountdown > -2)
- {
+ 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))
- {
+ switch (HIWORD(wParam)) {
case CBN_SELENDOK:
case CBN_SELCHANGE:
{
@@ -1453,16 +1337,13 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA }
}
- if ((HWND)lParam == msgbox_data->recent_cbex)
- {
- if (msgbox_data->m_iCountdown > -2)
- {
+ 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))
- {
+ switch (HIWORD(wParam)) {
case CBN_SELENDOK:
{
TCHAR text[1024];
@@ -1479,12 +1360,10 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA {
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 ((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 (LOWORD(cbitem.lParam) == PREDEFINED_MSG) {
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BADD)))
EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), FALSE);
}
@@ -1492,14 +1371,10 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA EnableWindow(GetDlgItem(hwndDlg, IDC_BADD), TRUE);
}
}
- else if (LOWORD(cbitem.lParam) == CLEAR_HISTORY)
- {
+ else if (LOWORD(cbitem.lParam) == CLEAR_HISTORY) {
if (MessageBox(NULL, 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)))
- {
+ else if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1))) {
TCHAR msg[1024];
int fcursel = CB_ERR, num_start;
num_start = SendMessage(msgbox_data->recent_cbex, CB_GETCOUNT, 0, 0);
@@ -1509,8 +1384,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, fcursel, 0);
}
}
- else if (LOWORD(cbitem.lParam) == DELETE_SELECTED)
- {
+ else if (LOWORD(cbitem.lParam) == DELETE_SELECTED) {
COMBOBOXEXITEM histitem = {0};
BOOL scursel = FALSE;
@@ -1518,26 +1392,22 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA histitem.iItem = msgbox_data->curr_sel_msg;
SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&histitem);
- if (LOWORD(histitem.lParam) == HISTORY_MSG)
- {
+ if (LOWORD(histitem.lParam) == HISTORY_MSG) {
char szSetting[16];
mir_snprintf(szSetting, SIZEOF(szSetting), "SMsg%d", (int)HIWORD(histitem.lParam));
db_set_ts(NULL, "SimpleStatusMsg", szSetting, _T(""));
SendMessage(msgbox_data->recent_cbex, CBEM_DELETEITEM, (WPARAM)msgbox_data->curr_sel_msg, 0);
}
- if (LOWORD(histitem.lParam) == PREDEFINED_MSG)
- {
+ 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)
- {
+ while (!scursel) {
if (cur_sel - 1 >= 0)
cur_sel--;
- else
- {
+ else {
scursel = TRUE;
break;
}
@@ -1563,11 +1433,9 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA DisplayCharsCount(msgbox_data, hwndDlg);
}
}
- else if (LOWORD(cbitem.lParam) == ADD_MSG)
- {
+ else if (LOWORD(cbitem.lParam) == ADD_MSG) {
int sel = AddToPredefined(hwndDlg, msgbox_data);
- if (sel != -1)
- {
+ if (sel != -1) {
SendMessage(msgbox_data->recent_cbex, CB_SETCURSEL, (WPARAM)sel, 0);
msgbox_data->curr_sel_msg = sel;
}
@@ -1577,8 +1445,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA }
msgbox_data->curr_sel_msg = cur_sel;
- if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1)))
- {
+ if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1))) {
SetFocus(GetDlgItem(hwndDlg, IDC_EDIT1));
SendMessage(GetDlgItem(hwndDlg, IDC_EDIT1), EM_SETSEL, 0, -1);
}
@@ -1587,15 +1454,12 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA }
}
- if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_BADD))
- {
- switch (HIWORD(wParam))
- {
+ if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_BADD)) {
+ switch (HIWORD(wParam)) {
case BN_CLICKED:
{
int sel = AddToPredefined(hwndDlg, msgbox_data);
- if (sel != -1)
- {
+ if (sel != -1) {
if (!IsWindowEnabled(msgbox_data->recent_cbex))
EnableWindow(msgbox_data->recent_cbex, TRUE);
if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_BDEL)))
@@ -1611,20 +1475,16 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA }
}
- if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_BCLEAR))
- {
- switch (HIWORD(wParam))
- {
+ if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_BCLEAR)) {
+ switch (HIWORD(wParam)) {
case BN_CLICKED:
if (MessageBox(NULL, 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))
- {
+ if (!num_items) {
+ if (IsWindowEnabled(msgbox_data->recent_cbex)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_BDEL), FALSE);
EnableWindow(msgbox_data->recent_cbex, FALSE);
}
@@ -1635,10 +1495,8 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA }
}
- if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_BDEL))
- {
- switch (HIWORD(wParam))
- {
+ if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_BDEL)) {
+ switch (HIWORD(wParam)) {
case BN_CLICKED:
{
int cur_sel;
@@ -1653,27 +1511,22 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&histitem);
- if (LOWORD(histitem.lParam) == HISTORY_MSG)
- {
+ if (LOWORD(histitem.lParam) == HISTORY_MSG) {
mir_snprintf(buff, SIZEOF(buff), "SMsg%d", (int)HIWORD(histitem.lParam));
db_set_ts(NULL, "SimpleStatusMsg", buff, _T(""));
}
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 (!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
- {
+ else {
TCHAR text[1024];
if (cur_sel - 1 >= 0)
@@ -1715,13 +1568,11 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA 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)
- {
+ 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))
- {
+ if ((msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS) || (msgbox_data->m_iDlgFlags & DLG_SHOW_BUTTONS_FLAT)) {
SendMessage(GetDlgItem(hwndDlg, IDC_BADD), BM_SETIMAGE, IMAGE_ICON, (LPARAM)msgbox_data->icon[I_ICON_ADD]);
SendMessage(GetDlgItem(hwndDlg, IDC_BCLEAR), BM_SETIMAGE, IMAGE_ICON, (LPARAM)msgbox_data->icon[I_ICON_CLEAR]);
SendMessage(GetDlgItem(hwndDlg, IDC_BDEL), BM_SETIMAGE, IMAGE_ICON, (LPARAM)msgbox_data->icon[I_ICON_DEL]);
@@ -1736,8 +1587,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA db_set_dw(NULL, "SimpleStatusMsg", "Winx", wp.rcNormalPosition.left);
db_set_dw(NULL, "SimpleStatusMsg", "Winy", wp.rcNormalPosition.top);
- if (msgbox_data->m_bPredefChanged)
- {
+ if (msgbox_data->m_bPredefChanged) {
int i, num_items, new_num_def_msgs = 0;
COMBOBOXEXITEM cbitem = {0};
TCHAR text[1024];
@@ -1745,17 +1595,15 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA num_items = SendMessage(msgbox_data->recent_cbex, CB_GETCOUNT, 0, 0);
num_items--;
- for (i = 1; i <= msgbox_data->num_def_msgs; i++)
- {
- cbitem.mask = CBEIF_LPARAM|CBEIF_TEXT;
+ for (i = 1; i <= msgbox_data->num_def_msgs; i++) {
+ cbitem.mask = CBEIF_LPARAM | CBEIF_TEXT;
cbitem.iItem = num_items;
cbitem.cchTextMax = SIZEOF(text);
cbitem.pszText = text;
SendMessage(msgbox_data->recent_cbex, CBEM_GETITEM, 0, (LPARAM)&cbitem);
mir_snprintf(buff, SIZEOF(buff), "DefMsg%d", i);
- if (LOWORD(cbitem.lParam) == PREDEFINED_MSG)
- {
+ if (LOWORD(cbitem.lParam) == PREDEFINED_MSG) {
new_num_def_msgs++;
db_set_ts(NULL, "SimpleStatusMsg", buff, text);
}
diff --git a/plugins/SimpleStatusMsg/src/options.cpp b/plugins/SimpleStatusMsg/src/options.cpp index 251f005a99..5ad595fc8a 100644 --- a/plugins/SimpleStatusMsg/src/options.cpp +++ b/plugins/SimpleStatusMsg/src/options.cpp @@ -1194,14 +1194,12 @@ static BOOL IsHistoryMsgsFound(HWND hwndDlg, 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;
+ for (int i = 1; i <= histMax; ++i, --j) {
+ if (j < 1)
+ j = histMax;
mir_snprintf(szSetting, SIZEOF(szSetting), "SMsg%d", j);
- if (!db_get_ts(NULL, "SimpleStatusMsg", szSetting, &dbv))
- {
- if (dbv.ptszVal != NULL && *dbv.ptszVal != '\0')
- {
+ if (!db_get_ts(NULL, "SimpleStatusMsg", szSetting, &dbv)) {
+ if (dbv.ptszVal != NULL && *dbv.ptszVal != '\0') {
db_free(&dbv);
return TRUE;
}
diff --git a/plugins/SimpleStatusMsg/src/utils.cpp b/plugins/SimpleStatusMsg/src/utils.cpp index 3880df82a3..a147197d6a 100644 --- a/plugins/SimpleStatusMsg/src/utils.cpp +++ b/plugins/SimpleStatusMsg/src/utils.cpp @@ -39,7 +39,7 @@ void IconsInit(void) Icon_Register(g_hInst, LPGEN("Simple Status Message"), iconList, SIZEOF(iconList), "SimpleStatusMsg");
}
-HICON LoadIconEx(const char* name)
+HICON LoadIconEx(const char *name)
{
char szSettingName[100];
mir_snprintf(szSettingName, sizeof(szSettingName), "SimpleStatusMsg_%s", name);
@@ -55,10 +55,10 @@ HANDLE GetIconHandle(int iconId) return NULL;
}
-void ReleaseIconEx(const char* name)
+void ReleaseIconEx(const char *name)
{
char szSettingName[100];
- mir_snprintf(szSettingName, sizeof(szSettingName), "SimpleStatusMsg_%s", name);
+ mir_snprintf(szSettingName, sizeof(szSettingName), "SimpleStatusMsg_%s", name);
Skin_ReleaseIcon(szSettingName);
}
@@ -81,7 +81,8 @@ void UnhookProtoEvents(void) // Generate random number in a specified range
int GetRandom(int from, int to)
{
- if ((to - from) < 1) return from;
+ if ((to - from) < 1)
+ return from;
unsigned randnum;
CallService(MS_UTILS_GETRANDOM, sizeof(randnum), (LPARAM)&randnum);
return ((randnum % (to - from + 1)) + from);
@@ -90,19 +91,18 @@ int GetRandom(int from, int to) // From SRAway module
const TCHAR *GetDefaultMessage(int status)
{
- switch (status)
- {
- case ID_STATUS_AWAY: return TranslateT("I've been away since %time%.");
- case ID_STATUS_NA: return TranslateT("Give it up, I'm not in!");
- case ID_STATUS_OCCUPIED: return TranslateT("Not right now.");
- case ID_STATUS_DND: return TranslateT("Give a guy some peace, would ya?");
- case ID_STATUS_FREECHAT: return TranslateT("I'm a chatbot!");
- case ID_STATUS_ONLINE: return TranslateT("Yep, I'm here.");
- case ID_STATUS_OFFLINE: return TranslateT("Nope, not here.");
- case ID_STATUS_INVISIBLE: return TranslateT("I'm hiding from the mafia.");
- case ID_STATUS_ONTHEPHONE: return TranslateT("That'll be the phone.");
- case ID_STATUS_OUTTOLUNCH: return TranslateT("Mmm... food.");
- case ID_STATUS_IDLE: return TranslateT("idleeeeeeee");
+ switch (status) {
+ case ID_STATUS_AWAY: return TranslateT("I've been away since %time%.");
+ case ID_STATUS_NA: return TranslateT("Give it up, I'm not in!");
+ case ID_STATUS_OCCUPIED: return TranslateT("Not right now.");
+ case ID_STATUS_DND: return TranslateT("Give a guy some peace, would ya?");
+ case ID_STATUS_FREECHAT: return TranslateT("I'm a chatbot!");
+ case ID_STATUS_ONLINE: return TranslateT("Yep, I'm here.");
+ case ID_STATUS_OFFLINE: return TranslateT("Nope, not here.");
+ case ID_STATUS_INVISIBLE: return TranslateT("I'm hiding from the mafia.");
+ case ID_STATUS_ONTHEPHONE: return TranslateT("That'll be the phone.");
+ case ID_STATUS_OUTTOLUNCH: return TranslateT("Mmm... food.");
+ case ID_STATUS_IDLE: return TranslateT("idleeeeeeee");
}
return NULL;
}
@@ -112,20 +112,19 @@ const char *StatusModeToDbSetting(int status, const char *suffix) const char *prefix;
static char str[64];
- switch (status)
- {
- case ID_STATUS_AWAY: prefix = "Away"; break;
- case ID_STATUS_NA: prefix = "Na"; break;
- case ID_STATUS_DND: prefix = "Dnd"; break;
- case ID_STATUS_OCCUPIED: prefix = "Occupied"; break;
- case ID_STATUS_FREECHAT: prefix = "FreeChat"; break;
- case ID_STATUS_ONLINE: prefix = "On"; break;
- case ID_STATUS_OFFLINE: prefix = "Off"; break;
- case ID_STATUS_INVISIBLE: prefix = "Inv"; break;
- case ID_STATUS_ONTHEPHONE: prefix = "Otp"; break;
- case ID_STATUS_OUTTOLUNCH: prefix = "Otl"; break;
- case ID_STATUS_IDLE: prefix = "Idl"; break;
- default: return NULL;
+ switch (status) {
+ case ID_STATUS_AWAY: prefix = "Away"; break;
+ case ID_STATUS_NA: prefix = "Na"; break;
+ case ID_STATUS_DND: prefix = "Dnd"; break;
+ case ID_STATUS_OCCUPIED: prefix = "Occupied"; break;
+ case ID_STATUS_FREECHAT: prefix = "FreeChat"; break;
+ case ID_STATUS_ONLINE: prefix = "On"; break;
+ case ID_STATUS_OFFLINE: prefix = "Off"; break;
+ case ID_STATUS_INVISIBLE: prefix = "Inv"; break;
+ case ID_STATUS_ONTHEPHONE: prefix = "Otp"; break;
+ case ID_STATUS_OUTTOLUNCH: prefix = "Otl"; break;
+ case ID_STATUS_IDLE: prefix = "Idl"; break;
+ default: return NULL;
}
mir_snprintf(str, SIZEOF(str), "%s%s", prefix, suffix);
return str;
@@ -133,8 +132,7 @@ const char *StatusModeToDbSetting(int status, const char *suffix) int GetCurrentStatus(const char *szProto)
{
- if (szProto)
- {
+ if (szProto) {
char szSetting[80];
mir_snprintf(szSetting, SIZEOF(szSetting), "Cur%sStatus", szProto);
return (int)db_get_w(NULL, "SimpleStatusMsg", szSetting, ID_STATUS_OFFLINE);
@@ -145,15 +143,13 @@ int GetCurrentStatus(const char *szProto) int GetStartupStatus(const char *szProto)
{
- if (szProto)
- {
- int status_mode;
+ if (szProto) {
+ int status_mode;
char szSetting[80];
mir_snprintf(szSetting, SIZEOF(szSetting), "Startup%sStatus", szProto);
status_mode = db_get_w(NULL, "SimpleStatusMsg", szSetting, ID_STATUS_OFFLINE);
- if (status_mode == ID_STATUS_CURRENT)
- {
+ if (status_mode == ID_STATUS_CURRENT) {
// load status used for this proto last time
mir_snprintf(szSetting, SIZEOF(szSetting), "Last%sStatus", szProto);
status_mode = db_get_w(NULL, "SimpleStatusMsg", szSetting, ID_STATUS_OFFLINE);
|