From 448529a1b204ad9ee122760ed11165d778661eef Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 6 Nov 2014 20:38:41 +0000 Subject: code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@10919 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/NewsAggregator/Src/Options.cpp | 197 ++++++++++++++++----------------- 1 file changed, 93 insertions(+), 104 deletions(-) (limited to 'plugins/NewsAggregator/Src/Options.cpp') diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp index b1b299a748..90bad063a1 100644 --- a/plugins/NewsAggregator/Src/Options.cpp +++ b/plugins/NewsAggregator/Src/Options.cpp @@ -30,16 +30,16 @@ INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SetDlgItemText(hwndDlg, IDC_TAGSEDIT, TAGSDEFAULT); SendDlgItemMessage(hwndDlg, IDC_CHECKTIME, EM_LIMITTEXT, 3, 0); SetDlgItemInt(hwndDlg, IDC_CHECKTIME, DEFAULT_UPDATE_TIME, TRUE); - SendDlgItemMessage(hwndDlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, 0, 999); + SendDlgItemMessage(hwndDlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, 0, 999); Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, MODULE, "AddDlg"); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: + TCHAR str[MAX_PATH]; + char passw[MAX_PATH]; { - TCHAR str[MAX_PATH]; - char passw[MAX_PATH]; if (!GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str))) { MessageBox(hwndDlg, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK); break; @@ -56,11 +56,12 @@ INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA MessageBox(hwndDlg, TranslateT("Enter message format"), TranslateT("Error"), MB_OK); break; } - + MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)MODULE); GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str)); db_set_ts(hContact, MODULE, "Nick", str); + HWND hwndList = (HWND)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str)); db_set_ts(hContact, MODULE, "URL", str); @@ -79,6 +80,7 @@ INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA DeleteAllItems(hwndList); UpdateList(hwndList); } + // fall through case IDCANCEL: DestroyWindow(hwndDlg); @@ -96,19 +98,16 @@ INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA break; case IDC_TAGHELP: - { - TCHAR tszTagHelp[1024]; - mir_sntprintf(tszTagHelp, SIZEOF(tszTagHelp), _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"), - _T("##"), TranslateT("The title of the item."), - _T("#<description>#"), TranslateT("The item synopsis."), - _T("#<link>#"), TranslateT("The URL of the item."), - _T("#<author>#"), TranslateT("Email address of the author of the item."), - _T("#<comments>#"), TranslateT("URL of a page for comments relating to the item."), - _T("#<guid>#"), TranslateT("A string that uniquely identifies the item."), - _T("#<category>#"), TranslateT("Specify one or more categories that the item belongs to.") - ); - MessageBox(hwndDlg, tszTagHelp, TranslateT("Feed Tag Help"), MB_OK); - } + TCHAR tszTagHelp[1024]; + mir_sntprintf(tszTagHelp, SIZEOF(tszTagHelp), _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"), + _T("#<title>#"), TranslateT("The title of the item."), + _T("#<description>#"), TranslateT("The item synopsis."), + _T("#<link>#"), TranslateT("The URL of the item."), + _T("#<author>#"), TranslateT("Email address of the author of the item."), + _T("#<comments>#"), TranslateT("URL of a page for comments relating to the item."), + _T("#<guid>#"), TranslateT("A string that uniquely identifies the item."), + _T("#<category>#"), TranslateT("Specify one or more categories that the item belongs to.")); + MessageBox(hwndDlg, tszTagHelp, TranslateT("Feed Tag Help"), MB_OK); break; case IDC_RESET: @@ -119,7 +118,7 @@ INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case IDC_DISCOVERY: EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), FALSE); SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Wait...")); - TCHAR tszURL[MAX_PATH] = {0}, *tszTitle = NULL; + TCHAR tszURL[MAX_PATH] = { 0 }, *tszTitle = NULL; if (GetDlgItemText(hwndDlg, IDC_FEEDURL, tszURL, SIZEOF(tszURL)) || lstrcmp(tszURL, _T("http://")) != 0) tszTitle = CheckFeed(tszURL, hwndDlg); else @@ -157,14 +156,14 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP MCONTACT hContact; for (hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) { - ptrT dbNick( db_get_tsa(hContact, MODULE, "Nick")); + ptrT dbNick(db_get_tsa(hContact, MODULE, "Nick")); if (dbNick == NULL) continue; if (lstrcmp(dbNick, SelItem.nick) != 0) continue; - ptrT dbURL( db_get_tsa(hContact, MODULE, "URL")); + ptrT dbURL(db_get_tsa(hContact, MODULE, "URL")); if (dbURL == NULL) continue; @@ -176,7 +175,7 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP SetDlgItemText(hwndDlg, IDC_FEEDURL, SelItem.url); SetDlgItemText(hwndDlg, IDC_FEEDTITLE, SelItem.nick); SetDlgItemInt(hwndDlg, IDC_CHECKTIME, db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME), TRUE); - + TCHAR *szMsgFormat = db_get_tsa(hContact, MODULE, "MsgFormat"); if (szMsgFormat) { SetDlgItemText(hwndDlg, IDC_TAGSEDIT, szMsgFormat); @@ -205,9 +204,9 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: + TCHAR str[MAX_PATH]; { ItemInfo *SelItem = (ItemInfo*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - TCHAR str[MAX_PATH]; char passw[MAX_PATH]; if (!GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str))) { MessageBox(hwndDlg, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK); @@ -242,8 +241,7 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP GetDlgItemTextA(hwndDlg, IDC_PASSWORD, passw, SIZEOF(passw)); db_set_s(SelItem->hContact, MODULE, "Password", passw); } - else - { + else { db_unset(SelItem->hContact, MODULE, "UseAuth"); db_unset(SelItem->hContact, MODULE, "Login"); db_unset(SelItem->hContact, MODULE, "Password"); @@ -251,6 +249,7 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP DeleteAllItems(SelItem->hwndList); UpdateList(SelItem->hwndList); } + // fall through case IDCANCEL: DestroyWindow(hwndDlg); @@ -268,19 +267,16 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; case IDC_TAGHELP: - { - TCHAR tszTagHelp[1024]; - mir_sntprintf(tszTagHelp, SIZEOF(tszTagHelp), _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"), - _T("#<title>#"), TranslateT("The title of the item."), - _T("#<description>#"), TranslateT("The item synopsis."), - _T("#<link>#"), TranslateT("The URL of the item."), - _T("#<author>#"), TranslateT("Email address of the author of the item."), - _T("#<comments>#"), TranslateT("URL of a page for comments relating to the item."), - _T("#<guid>#"), TranslateT("A string that uniquely identifies the item."), - _T("#<category>#"), TranslateT("Specify one or more categories that the item belongs to.") - ); - MessageBox(hwndDlg, tszTagHelp, TranslateT("Feed Tag Help"), MB_OK); - } + TCHAR tszTagHelp[1024]; + mir_sntprintf(tszTagHelp, SIZEOF(tszTagHelp), _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"), + _T("#<title>#"), TranslateT("The title of the item."), + _T("#<description>#"), TranslateT("The item synopsis."), + _T("#<link>#"), TranslateT("The URL of the item."), + _T("#<author>#"), TranslateT("Email address of the author of the item."), + _T("#<comments>#"), TranslateT("URL of a page for comments relating to the item."), + _T("#<guid>#"), TranslateT("A string that uniquely identifies the item."), + _T("#<category>#"), TranslateT("Specify one or more categories that the item belongs to.")); + MessageBox(hwndDlg, tszTagHelp, TranslateT("Feed Tag Help"), MB_OK); break; case IDC_RESET: @@ -289,7 +285,7 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; case IDC_DISCOVERY: - TCHAR tszURL[MAX_PATH] = {0}; + TCHAR tszURL[MAX_PATH] = { 0 }; if (GetDlgItemText(hwndDlg, IDC_FEEDURL, tszURL, SIZEOF(tszURL)) || lstrcmp(tszURL, _T("http://")) != 0) { EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), FALSE); SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Wait...")); @@ -331,13 +327,13 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP Utils_RestoreWindowPositionNoSize(hwndDlg, hContact, MODULE, "ChangeDlg"); TCHAR *ptszNick = db_get_tsa(hContact, MODULE, "Nick"); - if(ptszNick) { + if (ptszNick) { SetDlgItemText(hwndDlg, IDC_FEEDTITLE, ptszNick); mir_free(ptszNick); } - + TCHAR *ptszURL = db_get_tsa(hContact, MODULE, "URL"); - if(ptszNick) { + if (ptszNick) { SetDlgItemText(hwndDlg, IDC_FEEDURL, ptszURL); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); mir_free(ptszURL); @@ -369,9 +365,9 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: + TCHAR str[MAX_PATH]; { MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - TCHAR str[MAX_PATH]; char passw[MAX_PATH]; if (!GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str))) { MessageBox(hwndDlg, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK); @@ -406,13 +402,13 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP GetDlgItemTextA(hwndDlg, IDC_PASSWORD, passw, SIZEOF(passw)); db_set_s(hContact, MODULE, "Password", passw); } - else - { + else { db_unset(hContact, MODULE, "UseAuth"); db_unset(hContact, MODULE, "Login"); db_unset(hContact, MODULE, "Password"); } } + // fall through case IDCANCEL: DestroyWindow(hwndDlg); @@ -430,19 +426,16 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; case IDC_TAGHELP: - { - TCHAR tszTagHelp[1024]; - mir_sntprintf(tszTagHelp, SIZEOF(tszTagHelp), _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"), - _T("#<title>#"), TranslateT("The title of the item."), - _T("#<description>#"), TranslateT("The item synopsis."), - _T("#<link>#"), TranslateT("The URL of the item."), - _T("#<author>#"), TranslateT("Email address of the author of the item."), - _T("#<comments>#"), TranslateT("URL of a page for comments relating to the item."), - _T("#<guid>#"), TranslateT("A string that uniquely identifies the item."), - _T("#<category>#"), TranslateT("Specify one or more categories that the item belongs to.") - ); - MessageBox(hwndDlg, tszTagHelp, TranslateT("Feed Tag Help"), MB_OK); - } + TCHAR tszTagHelp[1024]; + mir_sntprintf(tszTagHelp, SIZEOF(tszTagHelp), _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"), + _T("#<title>#"), TranslateT("The title of the item."), + _T("#<description>#"), TranslateT("The item synopsis."), + _T("#<link>#"), TranslateT("The URL of the item."), + _T("#<author>#"), TranslateT("Email address of the author of the item."), + _T("#<comments>#"), TranslateT("URL of a page for comments relating to the item."), + _T("#<guid>#"), TranslateT("A string that uniquely identifies the item."), + _T("#<category>#"), TranslateT("Specify one or more categories that the item belongs to.")); + MessageBox(hwndDlg, tszTagHelp, TranslateT("Feed Tag Help"), MB_OK); break; case IDC_RESET: @@ -451,7 +444,7 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; case IDC_DISCOVERY: - TCHAR tszURL[MAX_PATH] = {0}; + TCHAR tszURL[MAX_PATH] = { 0 }; if (GetDlgItemText(hwndDlg, IDC_FEEDURL, tszURL, SIZEOF(tszURL)) || lstrcmp(tszURL, _T("http://")) != 0) { EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), FALSE); SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Wait...")); @@ -480,6 +473,8 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hwndList = GetDlgItem(hwndDlg, IDC_FEEDLIST); + int sel; + switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); @@ -492,14 +487,14 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_ADD: - if(hAddFeedDlg == 0) + if (hAddFeedDlg == 0) hAddFeedDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), hwndDlg, DlgProcAddFeedOpts, (LPARAM)hwndList); return FALSE; case IDC_CHANGE: + sel = ListView_GetSelectionMark(hwndList); { - ItemInfo SelItem = {0}; - int sel = ListView_GetSelectionMark(hwndList); + ItemInfo SelItem = { 0 }; ListView_GetItemText(hwndList, sel, 0, SelItem.nick, MAX_PATH); ListView_GetItemText(hwndList, sel, 1, SelItem.url, MAX_PATH); SelItem.hwndList = hwndList; @@ -516,16 +511,16 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA ListView_GetItemText(hwndList, sel, 1, url, MAX_PATH); for (MCONTACT hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) { - ptrT dbNick( db_get_tsa(hContact, MODULE, "Nick")); + ptrT dbNick(db_get_tsa(hContact, MODULE, "Nick")); if (dbNick == NULL) break; - if ( lstrcmp(dbNick, nick)) + if (lstrcmp(dbNick, nick)) continue; - - ptrT dbURL( db_get_tsa(hContact, MODULE, "URL")); + + ptrT dbURL(db_get_tsa(hContact, MODULE, "URL")); if (dbURL == NULL) break; - if ( lstrcmp(dbURL, url)) + if (lstrcmp(dbURL, url)) continue; CallService(MS_DB_CONTACT_DELETE, hContact, 0); @@ -550,48 +545,42 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA break; case WM_NOTIFY: - { - NMHDR *hdr = (NMHDR *)lParam; - switch (hdr->code) { - case PSN_APPLY: - { - db_set_b(NULL, MODULE, "StartupRetrieve", IsDlgButtonChecked(hwndDlg, IDC_STARTUPRETRIEVE)); - int i = 0; - for (MCONTACT hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) { - db_set_b(hContact, MODULE, "CheckState", ListView_GetCheckState(hwndList, i)); - if (!ListView_GetCheckState(hwndList, i)) - db_set_b(hContact, "CList", "Hidden", 1); - else - db_unset(hContact,"CList","Hidden"); - i++; - } - } - break; - - case NM_DBLCLK: - { - ItemInfo SelItem = {0}; - int sel = ListView_GetHotItem(hwndList); - if (sel != -1) { - ListView_GetItemText(hwndList, sel, 0, SelItem.nick, MAX_PATH); - ListView_GetItemText(hwndList, sel, 1, SelItem.url, MAX_PATH); - SelItem.hwndList = hwndList; - SelItem.SelNumber = sel; - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), hwndDlg, DlgProcChangeFeedOpts, (LPARAM)&SelItem); - } - break; + NMHDR *hdr = (NMHDR *)lParam; + switch (hdr->code) { + case PSN_APPLY: + db_set_b(NULL, MODULE, "StartupRetrieve", IsDlgButtonChecked(hwndDlg, IDC_STARTUPRETRIEVE)); + { + int i = 0; + for (MCONTACT hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) { + db_set_b(hContact, MODULE, "CheckState", ListView_GetCheckState(hwndList, i)); + if (!ListView_GetCheckState(hwndList, i)) + db_set_b(hContact, "CList", "Hidden", 1); + else + db_unset(hContact, "CList", "Hidden"); + i++; } + } + break; - case LVN_ITEMCHANGED: - { - NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; - if (((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) && !UpdateListFlag) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } + case NM_DBLCLK: + sel = ListView_GetHotItem(hwndList); + if (sel != -1) { + ItemInfo SelItem = { 0 }; + ListView_GetItemText(hwndList, sel, 0, SelItem.nick, MAX_PATH); + ListView_GetItemText(hwndList, sel, 1, SelItem.url, MAX_PATH); + SelItem.hwndList = hwndList; + SelItem.SelNumber = sel; + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), hwndDlg, DlgProcChangeFeedOpts, (LPARAM)&SelItem); } + break; + + case LVN_ITEMCHANGED: + NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; + if (((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) && !UpdateListFlag) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; } - }//end* switch (msg) + } return FALSE; } -- cgit v1.2.3