summaryrefslogtreecommitdiff
path: root/plugins/KeyboardNotify
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2014-11-28 21:19:14 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2014-11-28 21:19:14 +0000
commit6895d635acb37ba42e53ba95ca3eee2ddbbef24d (patch)
treef85a1d97784c4597099864119acb027b9a3f2dba /plugins/KeyboardNotify
parent8ef06acf351fdb6034b6e13670d84bfd79161956 (diff)
Massive code cleanup and fixes for a lot of warnings reported in #837
git-svn-id: http://svn.miranda-ng.org/main/trunk@11136 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/KeyboardNotify')
-rw-r--r--plugins/KeyboardNotify/src/main.cpp23
-rw-r--r--plugins/KeyboardNotify/src/options.cpp80
2 files changed, 47 insertions, 56 deletions
diff --git a/plugins/KeyboardNotify/src/main.cpp b/plugins/KeyboardNotify/src/main.cpp
index 29d448d822..73ea6cf54b 100644
--- a/plugins/KeyboardNotify/src/main.cpp
+++ b/plugins/KeyboardNotify/src/main.cpp
@@ -452,13 +452,13 @@ static VOID CALLBACK ReminderTimer(HWND hwnd, UINT message, UINT_PTR idEvent, DW
// Support for third-party plugins and mBot's scripts
-static INT_PTR EnableService(WPARAM wParam, LPARAM lParam)
+static INT_PTR EnableService(WPARAM, LPARAM)
{
bFlashingEnabled = TRUE;
return 0;
}
-static INT_PTR DisableService(WPARAM wParam, LPARAM lParam)
+static INT_PTR DisableService(WPARAM, LPARAM)
{
bFlashingEnabled = FALSE;
return 0;
@@ -487,12 +487,12 @@ static INT_PTR EventsWereOpenedService(WPARAM wParam, LPARAM lParam)
}
-static INT_PTR IsFlashingActiveService(WPARAM wParam, LPARAM lParam)
+static INT_PTR IsFlashingActiveService(WPARAM, LPARAM)
{
if (!bReminderDisabled)
return 0;
- return (int)getCurrentSequenceString();
+ return (INT_PTR)getCurrentSequenceString();
}
@@ -508,10 +508,11 @@ INT_PTR NormalizeSequenceService(WPARAM wParam, LPARAM lParam)
// Support for Trigger plugin
-static void ForceEventsWereOpenedThread(void *eventMaxSeconds)
+static DWORD WINAPI ForceEventsWereOpenedThread(void *eventMaxSeconds)
{
Sleep(((WORD)eventMaxSeconds) * 1000);
CallService(MS_KBDNOTIFY_EVENTSOPENED, 1, 0);
+ return 0;
}
@@ -520,7 +521,7 @@ void StartBlinkAction(char *flashSequence, WORD eventMaxSeconds)
DWORD threadID = 0;
if (eventMaxSeconds)
- CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ForceEventsWereOpenedThread, (void *)eventMaxSeconds, 0, &threadID);
+ CreateThread(NULL, 0, ForceEventsWereOpenedThread, (void *)eventMaxSeconds, 0, &threadID);
CallService(MS_KBDNOTIFY_STARTBLINK, 1, (LPARAM)flashSequence);
}
@@ -540,7 +541,7 @@ void createProcessList(void)
if (db_get_ts(NULL, KEYBDMODULE, fmtDBSettingName("process%d", i), &dbv))
ProcessList.szFileName[i] = NULL;
else {
- ProcessList.szFileName[i] = (TCHAR *)malloc(wcslen(dbv.ptszVal) + 1);
+ ProcessList.szFileName[i] = (TCHAR *)malloc((wcslen(dbv.ptszVal) + 1)*sizeof(TCHAR));
if (ProcessList.szFileName[i])
wcscpy(ProcessList.szFileName[i], dbv.ptszVal);
db_free(&dbv);
@@ -586,9 +587,9 @@ void LoadSettings(void)
bMirandaOrWindows = db_get_b(NULL, KEYBDMODULE, "mirorwin", DEF_SETTING_MIRORWIN);
wStatusMap = db_get_w(NULL, KEYBDMODULE, "status", DEF_SETTING_STATUS);
wReminderCheck = db_get_w(NULL, KEYBDMODULE, "remcheck", DEF_SETTING_CHECKTIME);
- bFlashLed[0] = !!db_get_b(NULL, KEYBDMODULE, "fnum", DEF_SETTING_FLASHNUM);
- bFlashLed[1] = !!db_get_b(NULL, KEYBDMODULE, "fcaps", DEF_SETTING_FLASHCAPS);
- bFlashLed[2] = !!db_get_b(NULL, KEYBDMODULE, "fscroll", DEF_SETTING_FLASHSCROLL);
+ bFlashLed[0] = db_get_b(NULL, KEYBDMODULE, "fnum", DEF_SETTING_FLASHNUM);
+ bFlashLed[1] = db_get_b(NULL, KEYBDMODULE, "fcaps", DEF_SETTING_FLASHCAPS);
+ bFlashLed[2] = db_get_b(NULL, KEYBDMODULE, "fscroll", DEF_SETTING_FLASHSCROLL);
bFlashEffect = db_get_b(NULL, KEYBDMODULE, "feffect", DEF_SETTING_FLASHEFFECT);
bSequenceOrder = db_get_b(NULL, KEYBDMODULE, "order", DEF_SETTING_SEQORDER);
wCustomTheme = db_get_w(NULL, KEYBDMODULE, "custom", DEF_SETTING_CUSTOMTHEME);
@@ -729,7 +730,7 @@ static int OnMetaChanged(WPARAM wParam, LPARAM)
return 0;
}
-static int ModulesLoaded(WPARAM wParam, LPARAM lParam)
+static int ModulesLoaded(WPARAM, LPARAM)
{
TCHAR eventPrefix[MAX_PATH+1], eventName[MAX_PATH+1];
diff --git a/plugins/KeyboardNotify/src/options.cpp b/plugins/KeyboardNotify/src/options.cpp
index 99c459e453..63df423bd6 100644
--- a/plugins/KeyboardNotify/src/options.cpp
+++ b/plugins/KeyboardNotify/src/options.cpp
@@ -87,7 +87,7 @@ BYTE trillianLedsMsg, trillianLedsURL, trillianLedsFile, trillianLedsOther;
// **
// ** Initialize the Miranda options page
// **
-int InitializeOptions(WPARAM wParam,LPARAM lParam)
+int InitializeOptions(WPARAM wParam,LPARAM)
{
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.hInstance = hInst;
@@ -654,17 +654,14 @@ INT_PTR CALLBACK DlgProcEffectOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
if(IsDlgButtonChecked(hwndDlg, IDC_INTURN) == BST_CHECKED)
db_set_b(NULL, KEYBDMODULE, "feffect", FLASH_INTURN);
+ else if (IsDlgButtonChecked(hwndDlg, IDC_INSEQUENCE) == BST_CHECKED)
+ db_set_b(NULL, KEYBDMODULE, "feffect", FLASH_INSEQUENCE);
+ else if (IsDlgButtonChecked(hwndDlg, IDC_CUSTOM) == BST_CHECKED)
+ db_set_b(NULL, KEYBDMODULE, "feffect", FLASH_CUSTOM);
+ else if (IsDlgButtonChecked(hwndDlg, IDC_TRILLIAN) == BST_CHECKED)
+ db_set_b(NULL, KEYBDMODULE, "feffect", FLASH_TRILLIAN);
else
- if (IsDlgButtonChecked(hwndDlg, IDC_INSEQUENCE) == BST_CHECKED)
- db_set_b(NULL, KEYBDMODULE, "feffect", FLASH_INSEQUENCE);
- else
- if (IsDlgButtonChecked(hwndDlg, IDC_CUSTOM) == BST_CHECKED)
- db_set_b(NULL, KEYBDMODULE, "feffect", FLASH_CUSTOM);
- else
- if (IsDlgButtonChecked(hwndDlg, IDC_TRILLIAN) == BST_CHECKED)
- db_set_b(NULL, KEYBDMODULE, "feffect", FLASH_TRILLIAN);
- else
- db_set_b(NULL, KEYBDMODULE, "feffect", FLASH_SAMETIME);
+ db_set_b(NULL, KEYBDMODULE, "feffect", FLASH_SAMETIME);
db_set_b(NULL, KEYBDMODULE, "order", (BYTE)SendDlgItemMessage(hwndDlg, IDC_SEQORDER, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_SEQORDER, CB_GETCURSEL, 0, 0), 0));
db_set_w(NULL, KEYBDMODULE, "custom", (WORD)SendDlgItemMessage(hwndDlg, IDC_SCUSTOM, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_SCUSTOM, CB_GETCURSEL, 0, 0), 0));
@@ -715,7 +712,7 @@ INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
int index = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)dbv.ptszVal);
db_free(&dbv);
if (index != CB_ERR && index != CB_ERRSPACE) {
- str = (TCHAR *)malloc(MAX_PATH+1);
+ str = (TCHAR *)malloc((MAX_PATH+1)*sizeof(TCHAR));
if (str)
if (db_get_ts(NULL, KEYBDMODULE, fmtDBSettingName("custom%d", i), &dbv))
str[0] = _T('\0');
@@ -782,11 +779,11 @@ INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
return TRUE;
case IDC_CUSTOMSTRING:
if(HIWORD(wParam) == EN_CHANGE) {
- int item;
TCHAR theme[MAX_PATH+1], customAux[MAX_PATH+1];
GetDlgItemText(hwndDlg, IDC_THEME, theme, SIZEOF(theme));
- if ((item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_FINDSTRINGEXACT, -1, (LPARAM)theme)) == CB_ERR)
+ int item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_FINDSTRINGEXACT, -1, (LPARAM)theme);
+ if (item == CB_ERR)
return TRUE;
str = (TCHAR *)SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETITEMDATA, (WPARAM)item, 0);
if (str) {
@@ -809,14 +806,13 @@ INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
return TRUE;
case IDC_ADD:
{
- int item;
TCHAR theme[MAX_PATH+1];
GetDlgItemText(hwndDlg, IDC_THEME, theme, SIZEOF(theme));
if (!theme[0])
return TRUE;
- item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_ADDSTRING, 0, (LPARAM)theme);
- str = (TCHAR *)malloc(MAX_PATH+1);
+ int item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_ADDSTRING, 0, (LPARAM)theme);
+ str = (TCHAR *)malloc((MAX_PATH+1)*sizeof(TCHAR));
if (str) {
GetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, str, MAX_PATH);
SetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, normalizeCustomString(str));
@@ -830,11 +826,10 @@ INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
return TRUE;
case IDC_UPDATE:
{
- int item;
TCHAR theme[MAX_PATH+1];
GetDlgItemText(hwndDlg, IDC_THEME, theme, SIZEOF(theme));
- item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_FINDSTRINGEXACT, -1, (LPARAM)theme);
+ int item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_FINDSTRINGEXACT, -1, (LPARAM)theme);
str = (TCHAR *)SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETITEMDATA, (WPARAM)item, 0);
if (str) {
GetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, str, MAX_PATH);
@@ -846,11 +841,10 @@ INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
return TRUE;
case IDC_DELETE:
{
- int item;
TCHAR theme[MAX_PATH+1];
GetDlgItemText(hwndDlg, IDC_THEME, theme, SIZEOF(theme));
- item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_FINDSTRINGEXACT, -1, (LPARAM)theme);
+ int item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_FINDSTRINGEXACT, -1, (LPARAM)theme);
str = (TCHAR *)SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETITEMDATA, (WPARAM)item, 0);
if (str)
free(str);
@@ -1033,14 +1027,14 @@ void exportThemes(const TCHAR *filename)
void importThemes(const TCHAR *filename, BOOL overrideExisting)
{
- int status=0;
- size_t i;
FILE *fImport = _tfopen(filename, _T("rt"));
- TCHAR buffer[MAX_PATH+1], theme[MAX_PATH+1], *str;
-
if (!fImport)
return;
+ int status=0;
+ size_t i;
+ TCHAR buffer[MAX_PATH+1], theme[MAX_PATH+1], *str;
+
while (_fgetts(buffer, MAX_PATH, fImport) != NULL) {
for (str=buffer; *str && isspace(*str); str++); //ltrim
if (!*str || *str == ';') //empty line or comment
@@ -1067,13 +1061,12 @@ void importThemes(const TCHAR *filename, BOOL overrideExisting)
void writeThemeToCombo(const TCHAR *theme, const TCHAR *custom, BOOL overrideExisting)
{
- int item;
TCHAR *str;
- item = SendDlgItemMessage(hwndTheme, IDC_THEME, CB_FINDSTRINGEXACT, -1, (LPARAM)theme);
+ int item = SendDlgItemMessage(hwndTheme, IDC_THEME, CB_FINDSTRINGEXACT, -1, (LPARAM)theme);
if (item == CB_ERR) {
item = SendDlgItemMessage(hwndTheme, IDC_THEME, CB_ADDSTRING, 0, (LPARAM)theme);
- str = (TCHAR *)malloc(MAX_PATH+1);
+ str = (TCHAR *)malloc((MAX_PATH+1)*sizeof(TCHAR));
if (str)
_tcscpy(str, custom);
SendDlgItemMessage(hwndTheme, IDC_THEME, CB_SETITEMDATA, (WPARAM)item, (LPARAM)str);
@@ -1174,7 +1167,7 @@ INT_PTR CALLBACK DlgProcProcesses(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
TCHAR szFileNameAux[MAX_PATH+1];
SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_GETLBTEXT, (WPARAM)i, (LPARAM)szFileNameAux);
- ProcessListAux.szFileName[i] = (TCHAR *)malloc(_tcslen(szFileNameAux) + 1);
+ ProcessListAux.szFileName[i] = (TCHAR *)malloc((_tcslen(szFileNameAux) + 1)*sizeof(TCHAR));
if (ProcessListAux.szFileName[i])
_tcscpy(ProcessListAux.szFileName[i], szFileNameAux);
}
@@ -1193,7 +1186,7 @@ INT_PTR CALLBACK DlgProcProcesses(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
void createProcessListAux(void)
{
ProcessListAux.count = ProcessList.count;
- ProcessListAux.szFileName = (TCHAR **)malloc(ProcessListAux.count * sizeof(char *));
+ ProcessListAux.szFileName = (TCHAR **)malloc(ProcessListAux.count * sizeof(TCHAR *));
if (!ProcessListAux.szFileName)
ProcessListAux.count = 0;
else
@@ -1201,7 +1194,7 @@ void createProcessListAux(void)
if (!ProcessList.szFileName[i])
ProcessListAux.szFileName[i] = NULL;
else {
- ProcessListAux.szFileName[i] = (TCHAR *)malloc(_tcslen(ProcessList.szFileName[i]) + 1);
+ ProcessListAux.szFileName[i] = (TCHAR *)malloc((_tcslen(ProcessList.szFileName[i]) + 1)*sizeof(TCHAR));
if (ProcessListAux.szFileName[i])
_tcscpy(ProcessListAux.szFileName[i], ProcessList.szFileName[i]);
}
@@ -1337,9 +1330,6 @@ INT_PTR CALLBACK DlgProcXstatusList(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
{
WPARAM j;
- int imageCount;
- HICON hIconAux;
- HIMAGELIST hImageList;
TVINSERTSTRUCT tvis={0};
TVITEM tvi={0};
HTREEITEM hSectionItem, hItem;
@@ -1351,16 +1341,19 @@ INT_PTR CALLBACK DlgProcXstatusList(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
if (!XstatusListAux) return TRUE;
// Calculate hImageList size
- imageCount=1;
+ int imageCount=1;
for (int i = 0; i < ProtoList.protoCount; i++)
if (ProtoList.protoInfo[i].enabled && XstatusListAux[i].count)
imageCount += XstatusListAux[i].count;
- hImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, imageCount, imageCount);
+ HIMAGELIST hImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, imageCount, imageCount);
TreeView_SetImageList(hwndTree, hImageList, TVSIL_NORMAL);
- ImageList_AddIcon(hImageList, hIconAux=(HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, 0, 0, 0));
- if (hIconAux) DestroyIcon(hIconAux);
+ HICON hIconAux=(HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, 0, 0, 0);
+ if (hIconAux) {
+ ImageList_AddIcon(hImageList, hIconAux);
+ DestroyIcon(hIconAux);
+ }
TreeView_SelectItem(hwndTree, NULL);
ShowWindow(hwndTree, SW_HIDE);
@@ -1368,9 +1361,8 @@ INT_PTR CALLBACK DlgProcXstatusList(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
for (int i = 0; i < ProtoList.protoCount; i++)
if (ProtoList.protoInfo[i].enabled && XstatusListAux[i].count) {
- HTREEITEM hParent;
-
- int count; PROTOACCOUNT** protos;
+ int count;
+ PROTOACCOUNT **protos;
ProtoEnumAccounts( &count, &protos );
tvis.hParent = NULL;
@@ -1382,7 +1374,7 @@ INT_PTR CALLBACK DlgProcXstatusList(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
tvis.item.state = TVIS_BOLD|TVIS_EXPANDED;
tvis.item.iImage = tvis.item.iSelectedImage = ImageList_AddIcon(hImageList, hIconAux=(HICON)CallProtoService(ProtoList.protoInfo[i].szProto, PS_LOADICON, PLI_PROTOCOL, 0));
if (hIconAux) DestroyIcon(hIconAux);
- hParent = TreeView_InsertItem(hwndTree, &tvis);
+ HTREEITEM hParent = TreeView_InsertItem(hwndTree, &tvis);
for (j = 0; j < XstatusListAux[i].count; j++) {
tvis.hParent = hParent;
tvis.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
@@ -1426,10 +1418,8 @@ INT_PTR CALLBACK DlgProcXstatusList(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
case WM_DESTROY:
{
- HIMAGELIST hImageList;
-
// Destroy tree view imagelist since it does not get destroyed automatically (see msdn docs)
- hImageList = TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TREE_XSTATUS), TVSIL_STATE);
+ HIMAGELIST hImageList = TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TREE_XSTATUS), TVSIL_STATE);
if (hImageList) {
TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TREE_XSTATUS), NULL, TVSIL_STATE);
ImageList_Destroy(hImageList);