diff options
author | George Hazan <george.hazan@gmail.com> | 2015-08-16 23:08:55 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-08-16 23:08:55 +0000 |
commit | 0c060267ccea726d5c2c2fd1e45d1f16965fb01e (patch) | |
tree | ef15e5533dbda23f63e423056b9d746e5d643ae3 /plugins/PasteIt/src | |
parent | af58213e6005cbf4b9ce8be2ad66eb6eae3df4a9 (diff) |
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@14975 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/PasteIt/src')
-rw-r--r-- | plugins/PasteIt/src/Options.cpp | 828 |
1 files changed, 361 insertions, 467 deletions
diff --git a/plugins/PasteIt/src/Options.cpp b/plugins/PasteIt/src/Options.cpp index 65781ac2f0..24405b97de 100644 --- a/plugins/PasteIt/src/Options.cpp +++ b/plugins/PasteIt/src/Options.cpp @@ -20,7 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. Options *Options::instance;
-struct TCpTable {
+struct TCpTable
+{
UINT cpId;
TCHAR *cpName;
}
@@ -55,8 +56,7 @@ Options::Options() autoUTF = true;
confDlg = true;
autoSend = false;
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
webOptions[i] = new WebOptions(i);
}
}
@@ -64,8 +64,7 @@ Options::Options() Options::~Options()
{
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
delete webOptions[i];
webOptions[i] = NULL;
}
@@ -75,55 +74,50 @@ void DefWebPageChanged(); INT_PTR CALLBACK Options::DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- CheckDlgButton(hwndDlg, IDC_AUTOUTF, instance->autoUTF ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CONFDLG, instance->confDlg ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_AUTOSEND, instance->autoSend ? BST_CHECKED : BST_UNCHECKED);
-
- for (int i = 0; i < PasteToWeb::pages; ++i)
{
- ComboBox_AddString(GetDlgItem(hwndDlg, IDC_WEBLIST), pasteToWebs[i]->GetName());
- }
+ TranslateDialogDefault(hwndDlg);
+ CheckDlgButton(hwndDlg, IDC_AUTOUTF, instance->autoUTF ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CONFDLG, instance->confDlg ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_AUTOSEND, instance->autoSend ? BST_CHECKED : BST_UNCHECKED);
- ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_WEBLIST), instance->defWeb);
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
+ ComboBox_AddString(GetDlgItem(hwndDlg, IDC_WEBLIST), pasteToWebs[i]->GetName());
+ }
- InitCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), instance->codepage);
- return TRUE;
- }
+ ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_WEBLIST), instance->defWeb);
+
+ InitCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), instance->codepage);
+ return TRUE;
+ }
case WM_COMMAND:
- {
- if (LOWORD(wParam) == IDC_CODEPAGE)
{
- if (HIWORD(wParam) == CBN_KILLFOCUS)
- {
- GetCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), true, instance->codepage);
+ if (LOWORD(wParam) == IDC_CODEPAGE) {
+ if (HIWORD(wParam) == CBN_KILLFOCUS) {
+ GetCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), true, instance->codepage);
+ }
}
- }
- if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE)
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- return TRUE;
- }
+ if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+ }
case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->code == PSN_APPLY)
{
- instance->codepage = GetCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), false, instance->codepage);
- instance->autoUTF = IsDlgButtonChecked(hwndDlg, IDC_AUTOUTF) ? true : false;
- instance->confDlg = IsDlgButtonChecked(hwndDlg, IDC_CONFDLG) ? true : false;
- instance->autoSend = IsDlgButtonChecked(hwndDlg, IDC_AUTOSEND) ? true : false;
- instance->defWeb = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBLIST));
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
+ instance->codepage = GetCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), false, instance->codepage);
+ instance->autoUTF = IsDlgButtonChecked(hwndDlg, IDC_AUTOUTF) ? true : false;
+ instance->confDlg = IsDlgButtonChecked(hwndDlg, IDC_CONFDLG) ? true : false;
+ instance->autoSend = IsDlgButtonChecked(hwndDlg, IDC_AUTOSEND) ? true : false;
+ instance->defWeb = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBLIST));
- DefWebPageChanged();
+ DefWebPageChanged();
- Options::instance->Save();
+ Options::instance->Save();
+ }
+ return TRUE;
}
- return TRUE;
- }
}
return FALSE;
@@ -136,16 +130,14 @@ public: : lastPage(0)
{
init = false;
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
webOptions[i] = Options::instance->webOptions[i]->Copy();
}
}
~OptsPagesData()
{
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
delete webOptions[i];
webOptions[i] = NULL;
}
@@ -173,15 +165,13 @@ void ReloadFormatsCombo(HWND hWnd, WebOptions* wo) while (ComboBox_DeleteString(hWnd, 0) > 0);
int sel = 0;
int i = 0;
- for (std::list<PasteFormat>::iterator it = wo->formats.begin(); it != wo->formats.end(); ++it)
- {
+ for (std::list<PasteFormat>::iterator it = wo->formats.begin(); it != wo->formats.end(); ++it) {
ComboBox_AddString(hWnd, it->name.c_str());
if (it->id == wo->defFormatId)
sel = i;
++i;
}
- if (!wo->formats.empty())
- {
+ if (!wo->formats.empty()) {
ComboBox_SetCurSel(hWnd, sel);
}
}
@@ -190,12 +180,9 @@ void GetPagesSettings(HWND hwndDlg, OptsPagesData* optsPagesData) {
int selected = optsPagesData->lastPage;
int format = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_DEFFORMAT));
- if (format >= 0 && format < (int)optsPagesData->webOptions[selected]->formats.size())
- {
- for (std::list<PasteFormat>::iterator it = optsPagesData->webOptions[selected]->formats.begin(); it != optsPagesData->webOptions[selected]->formats.end(); ++it)
- {
- if (format-- <= 0)
- {
+ if (format >= 0 && format < (int)optsPagesData->webOptions[selected]->formats.size()) {
+ for (std::list<PasteFormat>::iterator it = optsPagesData->webOptions[selected]->formats.begin(); it != optsPagesData->webOptions[selected]->formats.end(); ++it) {
+ if (format-- <= 0) {
optsPagesData->webOptions[selected]->defFormatId = it->id;
break;
}
@@ -206,29 +193,22 @@ void GetPagesSettings(HWND hwndDlg, OptsPagesData* optsPagesData) optsPagesData->webOptions[selected]->sendFileName = IsDlgButtonChecked(hwndDlg, IDC_AUTOFORMAT) ? true : false;
if (optsPagesData->webOptions[selected]->isPublicPaste)
optsPagesData->webOptions[selected]->publicPaste = IsDlgButtonChecked(hwndDlg, IDC_PUBLICPASTE) ? true : false;
- if (optsPagesData->webOptions[selected]->isCombo1)
- {
+ if (optsPagesData->webOptions[selected]->isCombo1) {
int sel = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_COMBO1));
- if (sel >= 0 && sel < (int)optsPagesData->webOptions[selected]->combo1Values.size())
- {
- for (std::list<PasteFormat>::iterator it = optsPagesData->webOptions[selected]->combo1Values.begin(); it != optsPagesData->webOptions[selected]->combo1Values.end(); ++it)
- {
- if (sel-- <= 0)
- {
+ if (sel >= 0 && sel < (int)optsPagesData->webOptions[selected]->combo1Values.size()) {
+ for (std::list<PasteFormat>::iterator it = optsPagesData->webOptions[selected]->combo1Values.begin(); it != optsPagesData->webOptions[selected]->combo1Values.end(); ++it) {
+ if (sel-- <= 0) {
optsPagesData->webOptions[selected]->combo1 = it->id;
break;
}
}
}
}
- if (optsPagesData->webOptions[selected]->isPublicPaste)
- {
- if (IsDlgButtonChecked(hwndDlg, IDC_GUEST))
- {
+ if (optsPagesData->webOptions[selected]->isPublicPaste) {
+ if (IsDlgButtonChecked(hwndDlg, IDC_GUEST)) {
optsPagesData->webOptions[selected]->pastebinUserKey = _T("");
}
- else
- {
+ else {
TCHAR buf[100];
Edit_GetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), buf, 100);
optsPagesData->webOptions[selected]->pastebinUserKey = buf;
@@ -238,194 +218,68 @@ void GetPagesSettings(HWND hwndDlg, OptsPagesData* optsPagesData) INT_PTR CALLBACK Options::DlgProcOptsPages(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- OptsPagesData* optsPagesData = new OptsPagesData();
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)optsPagesData);
-
- HWND btnhwnd = GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN);
- int btSize = Button_GetTextLength(btnhwnd);
- if (btSize > 20)
- {
- SetWindowPos(btnhwnd, NULL, 0, 0, 115, 34, SWP_NOZORDER | SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOACTIVATE | SWP_NOREDRAW);
- }
-
- for (int i = 0; i < PasteToWeb::pages; ++i)
{
- ComboBox_AddString(GetDlgItem(hwndDlg, IDC_WEBPAGE), pasteToWebs[i]->GetName());
- }
-
- ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE), 0);
- ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), optsPagesData->webOptions[0]);
- if (optsPagesData->webOptions[0]->isSendFileName)
- CheckDlgButton(hwndDlg, IDC_AUTOFORMAT, optsPagesData->webOptions[0]->sendFileName ? BST_CHECKED : BST_UNCHECKED);
- else
- ShowWindow(GetDlgItem(hwndDlg, IDC_AUTOFORMAT), SW_HIDE);
-
- if (Options::instance->webOptions[0]->isPublicPaste)
- CheckDlgButton(hwndDlg, IDC_PUBLICPASTE, Options::instance->webOptions[0]->publicPaste ? BST_CHECKED : BST_UNCHECKED);
- else
- ShowWindow(GetDlgItem(hwndDlg, IDC_PUBLICPASTE), SW_HIDE);
+ TranslateDialogDefault(hwndDlg);
+ OptsPagesData* optsPagesData = new OptsPagesData();
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)optsPagesData);
- if (Options::instance->webOptions[0]->isCombo1)
- {
- int sel = 0;
- int i = 0;
- std::wstring &val = Options::instance->webOptions[0]->combo1;
- HWND cb = GetDlgItem(hwndDlg, IDC_COMBO1);
- for (std::list<PasteFormat>::iterator it = Options::instance->webOptions[0]->combo1Values.begin(); it != Options::instance->webOptions[0]->combo1Values.end(); ++it)
- {
- ComboBox_AddString(cb, it->name.c_str());
- if (val == it->id)
- sel = i;
- ++i;
+ HWND btnhwnd = GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN);
+ int btSize = Button_GetTextLength(btnhwnd);
+ if (btSize > 20) {
+ SetWindowPos(btnhwnd, NULL, 0, 0, 115, 34, SWP_NOZORDER | SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOACTIVATE | SWP_NOREDRAW);
}
- ComboBox_SetCurSel(cb, sel);
- Static_SetText(GetDlgItem(hwndDlg, IDC_COMBO1_DESC), Options::instance->webOptions[0]->combo1Desc.c_str());
- }
- else
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1_DESC), SW_HIDE);
- }
- Edit_LimitText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), 99);
- if (Options::instance->webOptions[0]->isPastebin)
- {
- std::wstring pastebinUserKey = Options::instance->webOptions[0]->pastebinUserKey;
- if (pastebinUserKey.empty())
- {
- CheckDlgButton(hwndDlg, IDC_GUEST, BST_CHECKED);
- Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), FALSE);
- Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), FALSE);
- Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), FALSE);
- }
- else
- {
- Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), pastebinUserKey.c_str());
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
+ ComboBox_AddString(GetDlgItem(hwndDlg, IDC_WEBPAGE), pasteToWebs[i]->GetName());
}
- }
- else
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_GUEST), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), SW_HIDE);
- }
- optsPagesData->init = true;
- return TRUE;
- }
- case WM_COMMAND:
- {
- OptsPagesData* optsPagesData = (OptsPagesData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_CONFIGURE)
- {
- GetPagesSettings(hwndDlg, optsPagesData);
- OptsConfigureData d;
- d.page = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE));
- WebOptions* wo = optsPagesData->webOptions[d.page];
- d.tempFormats = wo->formats;
- if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_CONFIGURE), hwndDlg, DlgProcOptsConfigure, (LPARAM)&d) == IDOK)
- {
- wo->formats = d.tempFormats;
- ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), wo);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- }
- else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_PASTEBIN_LOGIN)
- {
- OptsLoginData d;
- if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_PASTEBIN_LOGIN), hwndDlg, DlgProcOptsLogin, (LPARAM)&d) == IDOK)
- {
- PasteToWeb1 *web = (PasteToWeb1*)pasteToWebs[optsPagesData->lastPage];
- Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), web->GetUserKey(d.user, d.password).c_str());
- }
- }
- else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_GUEST)
- {
- BOOL enabled = IsDlgButtonChecked(hwndDlg, IDC_GUEST) ? FALSE : TRUE;
- Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), enabled);
- Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), enabled);
- Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), enabled);
- }
- else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_WEBPAGE)
- {
- GetPagesSettings(hwndDlg, optsPagesData);
- optsPagesData->init = false;
- optsPagesData->lastPage = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE));
- ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), optsPagesData->webOptions[optsPagesData->lastPage]);
- if (optsPagesData->webOptions[optsPagesData->lastPage]->isSendFileName)
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_AUTOFORMAT), SW_SHOW);
- CheckDlgButton(hwndDlg, IDC_AUTOFORMAT, optsPagesData->webOptions[optsPagesData->lastPage]->sendFileName ? BST_CHECKED : BST_UNCHECKED);
- }
+ ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE), 0);
+ ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), optsPagesData->webOptions[0]);
+ if (optsPagesData->webOptions[0]->isSendFileName)
+ CheckDlgButton(hwndDlg, IDC_AUTOFORMAT, optsPagesData->webOptions[0]->sendFileName ? BST_CHECKED : BST_UNCHECKED);
else
ShowWindow(GetDlgItem(hwndDlg, IDC_AUTOFORMAT), SW_HIDE);
- if (optsPagesData->webOptions[optsPagesData->lastPage]->isPublicPaste)
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_PUBLICPASTE), SW_SHOW);
- CheckDlgButton(hwndDlg, IDC_PUBLICPASTE, optsPagesData->webOptions[optsPagesData->lastPage]->publicPaste ? BST_CHECKED : BST_UNCHECKED);
- }
+ if (Options::instance->webOptions[0]->isPublicPaste)
+ CheckDlgButton(hwndDlg, IDC_PUBLICPASTE, Options::instance->webOptions[0]->publicPaste ? BST_CHECKED : BST_UNCHECKED);
else
ShowWindow(GetDlgItem(hwndDlg, IDC_PUBLICPASTE), SW_HIDE);
- if (optsPagesData->webOptions[optsPagesData->lastPage]->isCombo1)
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1), SW_SHOW);
- ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1_DESC), SW_SHOW);
+ if (Options::instance->webOptions[0]->isCombo1) {
int sel = 0;
int i = 0;
- std::wstring &val = optsPagesData->webOptions[optsPagesData->lastPage]->combo1;
+ std::wstring &val = Options::instance->webOptions[0]->combo1;
HWND cb = GetDlgItem(hwndDlg, IDC_COMBO1);
- while (ComboBox_DeleteString(cb, 0) > 0);
- for (std::list<PasteFormat>::iterator it = optsPagesData->webOptions[optsPagesData->lastPage]->combo1Values.begin(); it != optsPagesData->webOptions[optsPagesData->lastPage]->combo1Values.end(); ++it)
- {
+ for (std::list<PasteFormat>::iterator it = Options::instance->webOptions[0]->combo1Values.begin(); it != Options::instance->webOptions[0]->combo1Values.end(); ++it) {
ComboBox_AddString(cb, it->name.c_str());
if (val == it->id)
sel = i;
++i;
}
ComboBox_SetCurSel(cb, sel);
- SetDlgItemText(hwndDlg, IDC_COMBO1_DESC, optsPagesData->webOptions[optsPagesData->lastPage]->combo1Desc.c_str());
+ Static_SetText(GetDlgItem(hwndDlg, IDC_COMBO1_DESC), Options::instance->webOptions[0]->combo1Desc.c_str());
}
- else
- {
+ else {
ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1), SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1_DESC), SW_HIDE);
}
-
- if (optsPagesData->webOptions[optsPagesData->lastPage]->isPastebin)
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_GUEST), SW_SHOW);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), SW_SHOW);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), SW_SHOW);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), SW_SHOW);
- std::wstring pastebinUserKey = optsPagesData->webOptions[optsPagesData->lastPage]->pastebinUserKey;
- if (pastebinUserKey.empty())
- {
+ Edit_LimitText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), 99);
+ if (Options::instance->webOptions[0]->isPastebin) {
+ std::wstring pastebinUserKey = Options::instance->webOptions[0]->pastebinUserKey;
+ if (pastebinUserKey.empty()) {
CheckDlgButton(hwndDlg, IDC_GUEST, BST_CHECKED);
Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), FALSE);
Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), FALSE);
Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), FALSE);
}
- else
- {
- CheckDlgButton(hwndDlg, IDC_GUEST, BST_UNCHECKED);
- Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), TRUE);
- Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), TRUE);
- Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), TRUE);
+ else {
+ Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), pastebinUserKey.c_str());
}
-
- Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), pastebinUserKey.c_str());
}
- else
- {
+ else {
ShowWindow(GetDlgItem(hwndDlg, IDC_GUEST), SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), SW_HIDE);
@@ -433,34 +287,133 @@ INT_PTR CALLBACK Options::DlgProcOptsPages(HWND hwndDlg, UINT msg, WPARAM wParam }
optsPagesData->init = true;
+ return TRUE;
}
-
- if (optsPagesData->init && ((HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) != IDC_CONFIGURE && LOWORD(wParam) != IDC_PASTEBIN_LOGIN) || (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) != IDC_WEBPAGE) || HIWORD(wParam) == EN_CHANGE))
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- return TRUE;
- }
- case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->code == PSN_APPLY)
+ case WM_COMMAND:
{
OptsPagesData* optsPagesData = (OptsPagesData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- GetPagesSettings(hwndDlg, optsPagesData);
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
- *Options::instance->webOptions[i] = *optsPagesData->webOptions[i];
+ if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_CONFIGURE) {
+ GetPagesSettings(hwndDlg, optsPagesData);
+ OptsConfigureData d;
+ d.page = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE));
+ WebOptions* wo = optsPagesData->webOptions[d.page];
+ d.tempFormats = wo->formats;
+ if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_CONFIGURE), hwndDlg, DlgProcOptsConfigure, (LPARAM)&d) == IDOK) {
+ wo->formats = d.tempFormats;
+ ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), wo);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ }
+ else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_PASTEBIN_LOGIN) {
+ OptsLoginData d;
+ if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_PASTEBIN_LOGIN), hwndDlg, DlgProcOptsLogin, (LPARAM)&d) == IDOK) {
+ PasteToWeb1 *web = (PasteToWeb1*)pasteToWebs[optsPagesData->lastPage];
+ Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), web->GetUserKey(d.user, d.password).c_str());
+ }
+ }
+ else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_GUEST) {
+ BOOL enabled = IsDlgButtonChecked(hwndDlg, IDC_GUEST) ? FALSE : TRUE;
+ Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), enabled);
+ Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), enabled);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), enabled);
}
+ else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_WEBPAGE) {
+ GetPagesSettings(hwndDlg, optsPagesData);
+ optsPagesData->init = false;
+ optsPagesData->lastPage = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE));
+ ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), optsPagesData->webOptions[optsPagesData->lastPage]);
+ if (optsPagesData->webOptions[optsPagesData->lastPage]->isSendFileName) {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_AUTOFORMAT), SW_SHOW);
+ CheckDlgButton(hwndDlg, IDC_AUTOFORMAT, optsPagesData->webOptions[optsPagesData->lastPage]->sendFileName ? BST_CHECKED : BST_UNCHECKED);
+ }
+ else
+ ShowWindow(GetDlgItem(hwndDlg, IDC_AUTOFORMAT), SW_HIDE);
+
+ if (optsPagesData->webOptions[optsPagesData->lastPage]->isPublicPaste) {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PUBLICPASTE), SW_SHOW);
+ CheckDlgButton(hwndDlg, IDC_PUBLICPASTE, optsPagesData->webOptions[optsPagesData->lastPage]->publicPaste ? BST_CHECKED : BST_UNCHECKED);
+ }
+ else
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PUBLICPASTE), SW_HIDE);
+
+ if (optsPagesData->webOptions[optsPagesData->lastPage]->isCombo1) {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1_DESC), SW_SHOW);
+ int sel = 0;
+ int i = 0;
+ std::wstring &val = optsPagesData->webOptions[optsPagesData->lastPage]->combo1;
+ HWND cb = GetDlgItem(hwndDlg, IDC_COMBO1);
+ while (ComboBox_DeleteString(cb, 0) > 0);
+ for (std::list<PasteFormat>::iterator it = optsPagesData->webOptions[optsPagesData->lastPage]->combo1Values.begin(); it != optsPagesData->webOptions[optsPagesData->lastPage]->combo1Values.end(); ++it) {
+ ComboBox_AddString(cb, it->name.c_str());
+ if (val == it->id)
+ sel = i;
+ ++i;
+ }
+ ComboBox_SetCurSel(cb, sel);
+ SetDlgItemText(hwndDlg, IDC_COMBO1_DESC, optsPagesData->webOptions[optsPagesData->lastPage]->combo1Desc.c_str());
+ }
+ else {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1_DESC), SW_HIDE);
+ }
+
+
+ if (optsPagesData->webOptions[optsPagesData->lastPage]->isPastebin) {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_GUEST), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), SW_SHOW);
+ std::wstring pastebinUserKey = optsPagesData->webOptions[optsPagesData->lastPage]->pastebinUserKey;
+ if (pastebinUserKey.empty()) {
+ CheckDlgButton(hwndDlg, IDC_GUEST, BST_CHECKED);
+ Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), FALSE);
+ Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), FALSE);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), FALSE);
+ }
+ else {
+ CheckDlgButton(hwndDlg, IDC_GUEST, BST_UNCHECKED);
+ Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), TRUE);
+ Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), TRUE);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), TRUE);
+ }
- Options::instance->Save();
+ Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), pastebinUserKey.c_str());
+ }
+ else {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_GUEST), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), SW_HIDE);
+ }
+
+ optsPagesData->init = true;
+ }
+
+ if (optsPagesData->init && ((HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) != IDC_CONFIGURE && LOWORD(wParam) != IDC_PASTEBIN_LOGIN) || (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) != IDC_WEBPAGE) || HIWORD(wParam) == EN_CHANGE))
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+ }
+ case WM_NOTIFY:
+ {
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
+ OptsPagesData* optsPagesData = (OptsPagesData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ GetPagesSettings(hwndDlg, optsPagesData);
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
+ *Options::instance->webOptions[i] = *optsPagesData->webOptions[i];
+ }
+
+ Options::instance->Save();
+ }
+ return TRUE;
}
- return TRUE;
- }
case WM_CLOSE:
- {
- OptsPagesData* optsPagesData = (OptsPagesData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- delete optsPagesData;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
- break;
- }
+ {
+ OptsPagesData* optsPagesData = (OptsPagesData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ delete optsPagesData;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
+ break;
+ }
}
return FALSE;
@@ -468,8 +421,7 @@ INT_PTR CALLBACK Options::DlgProcOptsPages(HWND hwndDlg, UINT msg, WPARAM wParam void SelectLbConfigure(HWND hwndDlg, int sel, OptsConfigureData* optsConfigureData)
{
- if (sel >= 0 && sel < (int)optsConfigureData->tempFormats.size())
- {
+ if (sel >= 0 && sel < (int)optsConfigureData->tempFormats.size()) {
Button_Enable(GetDlgItem(hwndDlg, IDC_DELETE), TRUE);
if (sel == 0)
Button_Enable(GetDlgItem(hwndDlg, IDC_UP), FALSE);
@@ -480,8 +432,7 @@ void SelectLbConfigure(HWND hwndDlg, int sel, OptsConfigureData* optsConfigureDa else
Button_Enable(GetDlgItem(hwndDlg, IDC_DOWN), TRUE);
}
- else
- {
+ else {
Button_Enable(GetDlgItem(hwndDlg, IDC_DELETE), FALSE);
Button_Enable(GetDlgItem(hwndDlg, IDC_UP), FALSE);
Button_Enable(GetDlgItem(hwndDlg, IDC_DOWN), FALSE);
@@ -490,152 +441,129 @@ void SelectLbConfigure(HWND hwndDlg, int sel, OptsConfigureData* optsConfigureDa INT_PTR CALLBACK Options::DlgProcOptsConfigure(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- OptsConfigureData* optsConfigureData = (OptsConfigureData*)lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
-
- HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
- for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
{
- ListBox_AddString(lb, it->name.c_str());
- }
+ TranslateDialogDefault(hwndDlg);
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- SelectLbConfigure(hwndDlg, -1, optsConfigureData);
- return TRUE;
- }
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it) {
+ ListBox_AddString(lb, it->name.c_str());
+ }
+
+ SelectLbConfigure(hwndDlg, -1, optsConfigureData);
+ return TRUE;
+ }
case WM_COMMAND:
- {
- if (HIWORD(wParam) == BN_CLICKED)
{
- if (LOWORD(wParam) == IDOK)
- {
- EndDialog(hwndDlg, IDOK);
- }
- else if (LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hwndDlg, IDCANCEL);
- }
- else if (LOWORD(wParam) == IDC_DELETE)
- {
- HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
- OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- int sel = ListBox_GetCurSel(lb);
- if (sel >= 0)
- {
- ListBox_DeleteString(lb, sel);
- int i = sel;
- for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
- {
- if (i-- <= 0)
- {
- optsConfigureData->tempFormats.erase(it);
- ListBox_SetCurSel(lb, sel);
- SelectLbConfigure(hwndDlg, sel, optsConfigureData);
- break;
+ if (HIWORD(wParam) == BN_CLICKED) {
+ if (LOWORD(wParam) == IDOK) {
+ EndDialog(hwndDlg, IDOK);
+ }
+ else if (LOWORD(wParam) == IDCANCEL) {
+ EndDialog(hwndDlg, IDCANCEL);
+ }
+ else if (LOWORD(wParam) == IDC_DELETE) {
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ int sel = ListBox_GetCurSel(lb);
+ if (sel >= 0) {
+ ListBox_DeleteString(lb, sel);
+ int i = sel;
+ for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it) {
+ if (i-- <= 0) {
+ optsConfigureData->tempFormats.erase(it);
+ ListBox_SetCurSel(lb, sel);
+ SelectLbConfigure(hwndDlg, sel, optsConfigureData);
+ break;
+ }
}
}
}
- }
- else if (LOWORD(wParam) == IDC_UP)
- {
- HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
- OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- int sel = ListBox_GetCurSel(lb);
- if (sel > 0)
- {
- int i = sel;
- for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
- {
- if (i-- <= 0)
- {
- PasteFormat pf = *it;
- std::list<PasteFormat>::iterator prevIt = it;
- --prevIt;
- optsConfigureData->tempFormats.erase(it);
- optsConfigureData->tempFormats.insert(prevIt, pf);
- ListBox_DeleteString(lb, sel--);
- ListBox_InsertString(lb, sel, pf.name.c_str());
- ListBox_SetCurSel(lb, sel);
- SelectLbConfigure(hwndDlg, sel, optsConfigureData);
- break;
+ else if (LOWORD(wParam) == IDC_UP) {
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ int sel = ListBox_GetCurSel(lb);
+ if (sel > 0) {
+ int i = sel;
+ for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it) {
+ if (i-- <= 0) {
+ PasteFormat pf = *it;
+ std::list<PasteFormat>::iterator prevIt = it;
+ --prevIt;
+ optsConfigureData->tempFormats.erase(it);
+ optsConfigureData->tempFormats.insert(prevIt, pf);
+ ListBox_DeleteString(lb, sel--);
+ ListBox_InsertString(lb, sel, pf.name.c_str());
+ ListBox_SetCurSel(lb, sel);
+ SelectLbConfigure(hwndDlg, sel, optsConfigureData);
+ break;
+ }
}
}
}
- }
- else if (LOWORD(wParam) == IDC_DOWN)
- {
- HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
- OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- int sel = ListBox_GetCurSel(lb);
- if (sel >= 0 && sel + 1 < (int)optsConfigureData->tempFormats.size())
- {
- int i = sel;
- for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
- {
- if (i-- <= 0)
- {
- PasteFormat pf = *it;
- std::list<PasteFormat>::iterator nextIt = it;
- ++(++nextIt);
- optsConfigureData->tempFormats.erase(it);
- optsConfigureData->tempFormats.insert(nextIt, pf);
- ListBox_DeleteString(lb, sel++);
- ListBox_InsertString(lb, sel, pf.name.c_str());
- ListBox_SetCurSel(lb, sel);
- SelectLbConfigure(hwndDlg, sel, optsConfigureData);
- break;
+ else if (LOWORD(wParam) == IDC_DOWN) {
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ int sel = ListBox_GetCurSel(lb);
+ if (sel >= 0 && sel + 1 < (int)optsConfigureData->tempFormats.size()) {
+ int i = sel;
+ for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it) {
+ if (i-- <= 0) {
+ PasteFormat pf = *it;
+ std::list<PasteFormat>::iterator nextIt = it;
+ ++(++nextIt);
+ optsConfigureData->tempFormats.erase(it);
+ optsConfigureData->tempFormats.insert(nextIt, pf);
+ ListBox_DeleteString(lb, sel++);
+ ListBox_InsertString(lb, sel, pf.name.c_str());
+ ListBox_SetCurSel(lb, sel);
+ SelectLbConfigure(hwndDlg, sel, optsConfigureData);
+ break;
+ }
}
}
}
- }
- else if (LOWORD(wParam) == IDC_DOWNLOAD)
- {
- OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
- while (ListBox_DeleteString(lb, 0) > 0);
- SelectLbConfigure(hwndDlg, -1, optsConfigureData);
- optsConfigureData->tempFormats = pasteToWebs[optsConfigureData->page]->GetFormats();
- for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
- {
- ListBox_AddString(lb, it->name.c_str());
+ else if (LOWORD(wParam) == IDC_DOWNLOAD) {
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ while (ListBox_DeleteString(lb, 0) > 0);
+ SelectLbConfigure(hwndDlg, -1, optsConfigureData);
+ optsConfigureData->tempFormats = pasteToWebs[optsConfigureData->page]->GetFormats();
+ for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it) {
+ ListBox_AddString(lb, it->name.c_str());
+ }
+ }
+ else if (LOWORD(wParam) == IDC_RESTORE) {
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ while (ListBox_DeleteString(lb, 0) > 0);
+ SelectLbConfigure(hwndDlg, -1, optsConfigureData);
+ optsConfigureData->tempFormats = pasteToWebs[optsConfigureData->page]->GetDefFormats();
+ for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it) {
+ ListBox_AddString(lb, it->name.c_str());
+ }
}
}
- else if (LOWORD(wParam) == IDC_RESTORE)
- {
+ else if (HIWORD(wParam) == LBN_SELCHANGE && LOWORD(wParam) == IDC_FORMATTING) {
OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
- while (ListBox_DeleteString(lb, 0) > 0);
- SelectLbConfigure(hwndDlg, -1, optsConfigureData);
- optsConfigureData->tempFormats = pasteToWebs[optsConfigureData->page]->GetDefFormats();
- for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
- {
- ListBox_AddString(lb, it->name.c_str());
- }
+ int sel = ListBox_GetCurSel(GetDlgItem(hwndDlg, IDC_FORMATTING));
+ SelectLbConfigure(hwndDlg, sel, optsConfigureData);
}
+ return TRUE;
}
- else if (HIWORD(wParam) == LBN_SELCHANGE && LOWORD(wParam) == IDC_FORMATTING)
- {
- OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- int sel = ListBox_GetCurSel(GetDlgItem(hwndDlg, IDC_FORMATTING));
- SelectLbConfigure(hwndDlg, sel, optsConfigureData);
- }
- return TRUE;
- }
case WM_VKEYTOITEM:
- if (LOWORD(wParam) == VK_DELETE && (HWND)lParam == GetDlgItem(hwndDlg, IDC_FORMATTING))
- {
+ if (LOWORD(wParam) == VK_DELETE && (HWND)lParam == GetDlgItem(hwndDlg, IDC_FORMATTING)) {
DlgProcOptsConfigure(hwndDlg, WM_COMMAND, MAKELONG(IDC_DELETE, BN_CLICKED), NULL);
return -2;
}
return -1;
case WM_NOTIFY:
- {
- return TRUE;
- }
+ {
+ return TRUE;
+ }
}
return FALSE;
@@ -643,41 +571,37 @@ INT_PTR CALLBACK Options::DlgProcOptsConfigure(HWND hwndDlg, UINT msg, WPARAM wP INT_PTR CALLBACK Options::DlgProcOptsLogin(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- Edit_LimitText(GetDlgItem(hwndDlg, IDC_PASTEBIN_USER), 99);
- Edit_LimitText(GetDlgItem(hwndDlg, IDC_PASTEBIN_PASSWORD), 99);
- return TRUE;
- }
+ {
+ TranslateDialogDefault(hwndDlg);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ Edit_LimitText(GetDlgItem(hwndDlg, IDC_PASTEBIN_USER), 99);
+ Edit_LimitText(GetDlgItem(hwndDlg, IDC_PASTEBIN_PASSWORD), 99);
+ return TRUE;
+ }
case WM_COMMAND:
- {
- if (HIWORD(wParam) == BN_CLICKED)
{
- if (LOWORD(wParam) == IDOK)
- {
- TCHAR buf[100];
- OptsLoginData* optsLoginData = (OptsLoginData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- Edit_GetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_USER), buf, 100);
- optsLoginData->user = buf;
- Edit_GetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_PASSWORD), buf, 100);
- optsLoginData->password = buf;
- EndDialog(hwndDlg, IDOK);
- }
- else if (LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hwndDlg, IDCANCEL);
+ if (HIWORD(wParam) == BN_CLICKED) {
+ if (LOWORD(wParam) == IDOK) {
+ TCHAR buf[100];
+ OptsLoginData* optsLoginData = (OptsLoginData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ Edit_GetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_USER), buf, 100);
+ optsLoginData->user = buf;
+ Edit_GetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_PASSWORD), buf, 100);
+ optsLoginData->password = buf;
+ EndDialog(hwndDlg, IDOK);
+ }
+ else if (LOWORD(wParam) == IDCANCEL) {
+ EndDialog(hwndDlg, IDCANCEL);
+ }
}
+ return TRUE;
}
- return TRUE;
- }
case WM_NOTIFY:
- {
- return TRUE;
- }
+ {
+ return TRUE;
+ }
}
return FALSE;
@@ -686,14 +610,12 @@ INT_PTR CALLBACK Options::DlgProcOptsLogin(HWND hwndDlg, UINT msg, WPARAM wParam unsigned int Options::GetCodepageCB(HWND hwndCB, bool errorReport, unsigned int defCp)
{
int selCpIdx = ComboBox_GetCurSel(hwndCB);
- if (selCpIdx < 0)
- {
+ if (selCpIdx < 0) {
TCHAR text[128];
ComboBox_GetText(hwndCB, text, 128);
TCHAR * stopOn = NULL;
long cp = _tcstol(text, &stopOn, 10);
- if (errorReport && (stopOn == text || *stopOn != '\0' || cp < 0 || cp > 0xffff))
- {
+ if (errorReport && (stopOn == text || *stopOn != '\0' || cp < 0 || cp > 0xffff)) {
MessageBox(GetParent(hwndCB), TranslateT("You've entered invalid codepage. Select codepage from combo box or enter correct number."), TranslateT("Invalid codepage"), MB_OK | MB_ICONERROR);
SetFocus(hwndCB);
SetCodepageCB(hwndCB, defCp);
@@ -716,21 +638,18 @@ void Options::InitCodepageCB(HWND hwndCB, unsigned int codepage) {
int cpCount = sizeof(cpTable) / sizeof(cpTable[0]);
int selCpIdx = -1;
- for (int i = 0; i < cpCount; ++i)
- {
+ for (int i = 0; i < cpCount; ++i) {
ComboBox_AddString(hwndCB, TranslateTS(cpTable[i].cpName));
if (cpTable[i].cpId == codepage)
selCpIdx = i;
}
- if (selCpIdx == -1)
- {
+ if (selCpIdx == -1) {
TCHAR buf[10];
mir_sntprintf(buf, _T("%d"), codepage);
ComboBox_SetText(hwndCB, buf);
}
- else
- {
+ else {
ComboBox_SetCurSel(hwndCB, selCpIdx);
}
@@ -741,20 +660,17 @@ void Options::SetCodepageCB(HWND hwndCB, unsigned int codepage) {
int cpCount = sizeof(cpTable) / sizeof(cpTable[0]);
int selCpIdx = -1;
- for (int i = 0; i < cpCount; ++i)
- {
+ for (int i = 0; i < cpCount; ++i) {
if (cpTable[i].cpId == codepage)
selCpIdx = i;
}
- if (selCpIdx == -1)
- {
+ if (selCpIdx == -1) {
TCHAR buf[10];
mir_sntprintf(buf, _T("%d"), codepage);
ComboBox_SetText(hwndCB, buf);
}
- else
- {
+ else {
ComboBox_SetCurSel(hwndCB, selCpIdx);
}
}
@@ -787,13 +703,11 @@ void Options::Save() db_set_b(0, MODULE, "autoUTF", autoUTF ? 1 : 0);
db_set_b(0, MODULE, "confDlg", confDlg ? 1 : 0);
db_set_b(0, MODULE, "autoSend", autoSend ? 1 : 0);
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
char buf[256];
TCHAR* name = pasteToWebs[i]->GetName();
int j = 0;
- while (name[j])
- {
+ while (name[j]) {
buf[j] = (char)name[j];
++j;
}
@@ -801,8 +715,7 @@ void Options::Save() mir_strncpy(buf + j, "formats", _countof(buf) - j);
std::wstring forms;
- for (std::list<PasteFormat>::iterator it = webOptions[i]->formats.begin(); it != webOptions[i]->formats.end(); ++it)
- {
+ for (std::list<PasteFormat>::iterator it = webOptions[i]->formats.begin(); it != webOptions[i]->formats.end(); ++it) {
forms += it->id + L'=' + it->name + L';';
}
@@ -811,26 +724,22 @@ void Options::Save() mir_strncpy(buf + j, "defFormatId", _countof(buf) - j);
db_set_ws(0, MODULE, buf, webOptions[i]->defFormatId.c_str());
- if (webOptions[i]->isSendFileName)
- {
+ if (webOptions[i]->isSendFileName) {
mir_strncpy(buf + j, "sendFileName", _countof(buf) - j);
db_set_b(0, MODULE, buf, webOptions[i]->sendFileName ? 1 : 0);
}
- if (webOptions[i]->isPublicPaste)
- {
+ if (webOptions[i]->isPublicPaste) {
mir_strncpy(buf + j, "publicPaste", _countof(buf) - j);
db_set_b(0, MODULE, buf, webOptions[i]->publicPaste ? 1 : 0);
}
- if (webOptions[i]->isCombo1)
- {
+ if (webOptions[i]->isCombo1) {
mir_strncpy(buf + j, "combo1", _countof(buf) - j);
db_set_ws(0, MODULE, buf, webOptions[i]->combo1.c_str());
}
- if (webOptions[i]->isPastebin)
- {
+ if (webOptions[i]->isPastebin) {
mir_strncpy(buf + j, "pastebinUserKey", _countof(buf) - j);
db_set_ws(0, MODULE, buf, webOptions[i]->pastebinUserKey.c_str());
}
@@ -840,12 +749,9 @@ void Options::Save() void Options::Load()
{
DBVARIANT defWebV;
- if (!db_get_ws(0, MODULE, "defWeb", &defWebV))
- {
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
- if (!mir_wstrcmp(pasteToWebs[i]->GetName(), defWebV.pwszVal))
- {
+ if (!db_get_ws(0, MODULE, "defWeb", &defWebV)) {
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
+ if (!mir_wstrcmp(pasteToWebs[i]->GetName(), defWebV.pwszVal)) {
defWeb = i;
break;
}
@@ -856,35 +762,31 @@ void Options::Load() autoUTF = db_get_b(0, MODULE, "autoUTF", 1) ? true : false;
confDlg = db_get_b(0, MODULE, "confDlg", 1) ? true : false;
autoSend = db_get_b(0, MODULE, "autoSend", 0) ? true : false;
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
char buf[256];
- TCHAR* name = pasteToWebs[i]->GetName();
int j = 0;
- while (name[j])
{
- buf[j] = (char)name[j];
- ++j;
+ TCHAR *name = pasteToWebs[i]->GetName();
+ while (name[j]) {
+ buf[j] = (char)name[j];
+ ++j;
+ }
+ buf[j++] = '_';
}
- buf[j++] = '_';
mir_strncpy(buf + j, "formats", _countof(buf) - j);
DBVARIANT forms;
- if (!db_get_ws(0, MODULE, buf, &forms))
- {
+ if (!db_get_ws(0, MODULE, buf, &forms)) {
webOptions[i]->formats.clear();
int k = 0;
- wchar_t * id = forms.pwszVal;
- wchar_t * name = NULL;
- while (forms.pwszVal[k])
- {
- if (forms.pwszVal[k] == L'=')
- {
+ wchar_t *id = forms.pwszVal;
+ wchar_t *name = NULL;
+ while (forms.pwszVal[k]) {
+ if (forms.pwszVal[k] == L'=') {
forms.pwszVal[k] = 0;
name = forms.pwszVal + k + 1;
}
- else if (forms.pwszVal[k] == L';')
- {
+ else if (forms.pwszVal[k] == L';') {
forms.pwszVal[k] = 0;
PasteFormat pf;
pf.id = id;
@@ -901,41 +803,34 @@ void Options::Load() mir_strncpy(buf + j, "defFormatId", _countof(buf) - j);
DBVARIANT defForm;
- if (!db_get_ws(0, MODULE, buf, &defForm))
- {
+ if (!db_get_ws(0, MODULE, buf, &defForm)) {
webOptions[i]->defFormatId = defForm.pwszVal;
db_free(&defForm);
}
- if (webOptions[i]->isSendFileName)
- {
+ if (webOptions[i]->isSendFileName) {
mir_strncpy(buf + j, "sendFileName", _countof(buf) - j);
webOptions[i]->sendFileName = db_get_b(0, MODULE, buf, 1) ? true : false;
}
- if (webOptions[i]->isPublicPaste)
- {
+ if (webOptions[i]->isPublicPaste) {
mir_strncpy(buf + j, "publicPaste", _countof(buf) - j);
webOptions[i]->publicPaste = db_get_b(0, MODULE, buf, 0) ? true : false;
}
- if (webOptions[i]->isCombo1)
- {
+ if (webOptions[i]->isCombo1) {
mir_strncpy(buf + j, "combo1", _countof(buf) - j);
DBVARIANT combo1;
- if (!db_get_ws(0, MODULE, buf, &combo1))
- {
+ if (!db_get_ws(0, MODULE, buf, &combo1)) {
webOptions[i]->combo1 = combo1.pwszVal;
db_free(&combo1);
}
}
- if (webOptions[i]->isPastebin)
- {
+ if (webOptions[i]->isPastebin) {
mir_strncpy(buf + j, "pastebinUserKey", _countof(buf) - j);
DBVARIANT pastebinUserKey;
- if (!db_get_ws(0, MODULE, buf, &pastebinUserKey))
- {
+ if (!db_get_ws(0, MODULE, buf, &pastebinUserKey)) {
webOptions[i]->pastebinUserKey = pastebinUserKey.pwszVal;
db_free(&pastebinUserKey);
}
@@ -944,7 +839,7 @@ void Options::Load() }
WebOptions::WebOptions(int serv)
- :server(serv),
+ : server(serv),
formats(pasteToWebs[serv]->GetDefFormats()),
sendFileName(true),
isSendFileName(true),
@@ -956,7 +851,6 @@ WebOptions::WebOptions(int serv) defFormatId = formats.front().id;
}
-
WebOptions::~WebOptions()
{
}
|