Ticket #8929: 0001-Add-optional-username-password-fields-to-Web-proxy-s.patch
File 0001-Add-optional-username-password-fields-to-Web-proxy-s.patch, 8.7 KB (added by , 12 years ago) |
---|
-
src/apps/webpositive/SettingsKeys.cpp
From 0e5fd7f6440292dfba03a78b739b7ab5e7abf607 Mon Sep 17 00:00:00 2001 From: Jessica Hamilton <jessica.l.hamilton@gmail.com> Date: Mon, 3 Sep 2012 19:04:45 +1200 Subject: [PATCH] Add optional username/password fields to Web+ proxy settings. --- src/apps/webpositive/SettingsKeys.cpp | 3 + src/apps/webpositive/SettingsKeys.h | 5 ++- src/apps/webpositive/SettingsWindow.cpp | 87 +++++++++++++++++++++++++++---- src/apps/webpositive/SettingsWindow.h | 5 ++- 4 files changed, 88 insertions(+), 12 deletions(-) mode change 100644 => 100755 src/apps/webpositive/SettingsKeys.cpp mode change 100644 => 100755 src/apps/webpositive/SettingsKeys.h mode change 100644 => 100755 src/apps/webpositive/SettingsWindow.cpp mode change 100644 => 100755 src/apps/webpositive/SettingsWindow.h diff --git a/src/apps/webpositive/SettingsKeys.cpp b/src/apps/webpositive/SettingsKeys.cpp old mode 100644 new mode 100755 index b72166c..4e2cf57
a b const char* kDefaultSearchPageURL = "http://www.google.com"; 49 49 const char* kSettingsKeyUseProxy = "use http proxy"; 50 50 const char* kSettingsKeyProxyAddress = "http proxy address"; 51 51 const char* kSettingsKeyProxyPort = "http proxy port"; 52 const char* kSettingsKeyUseProxyAuth = "use http proxy authentication"; 53 const char* kSettingsKeyProxyUsername = "http proxy username"; 54 const char* kSettingsKeyProxyPassword = "http proxy password"; -
src/apps/webpositive/SettingsKeys.h
diff --git a/src/apps/webpositive/SettingsKeys.h b/src/apps/webpositive/SettingsKeys.h old mode 100644 new mode 100755 index 1a95bbf..b3034b0
a b extern const char* kDefaultSearchPageURL; 47 47 48 48 extern const char* kSettingsKeyUseProxy; 49 49 extern const char* kSettingsKeyProxyAddress; 50 extern const char* kSettingsKeyProxyPort; 50 extern const char* kSettingsKeyProxyPort; 51 extern const char* kSettingsKeyUseProxyAuth; 52 extern const char* kSettingsKeyProxyUsername; 53 extern const char* kSettingsKeyProxyPassword; 51 54 52 55 #endif // SETTINGS_KEYS_H -
src/apps/webpositive/SettingsWindow.cpp
diff --git a/src/apps/webpositive/SettingsWindow.cpp b/src/apps/webpositive/SettingsWindow.cpp old mode 100644 new mode 100755 index 39fa27a..552a3b8
a b enum { 85 85 86 86 MSG_USE_PROXY_CHANGED = 'upsc', 87 87 MSG_PROXY_ADDRESS_CHANGED = 'psac', 88 MSG_PROXY_PORT_CHANGED = 'pspc', 88 MSG_PROXY_PORT_CHANGED = 'pspc', 89 MSG_USE_PROXY_AUTH_CHANGED = 'upsa', 90 MSG_PROXY_USERNAME_CHANGED = 'psuc', 91 MSG_PROXY_PASSWORD_CHANGED = 'pswc', 89 92 }; 90 93 91 94 static const int32 kDefaultFontSize = 14; … … SettingsWindow::MessageReceived(BMessage* message) 211 214 case MSG_FIXED_FONT_CHANGED: 212 215 case MSG_USE_PROXY_CHANGED: 213 216 case MSG_PROXY_ADDRESS_CHANGED: 214 case MSG_PROXY_PORT_CHANGED: 217 case MSG_PROXY_PORT_CHANGED: 218 case MSG_USE_PROXY_AUTH_CHANGED: 219 case MSG_PROXY_USERNAME_CHANGED: 220 case MSG_PROXY_PASSWORD_CHANGED: 215 221 // TODO: Some settings could change live, some others not? 216 222 _ValidateControlsEnabledStatus(); 217 223 break; … … SettingsWindow::_CreateProxyPage(float spacing) 463 469 fProxyPortControl->SetModificationMessage( 464 470 new BMessage(MSG_PROXY_PORT_CHANGED)); 465 471 fProxyPortControl->SetText( 466 fSettings->GetValue(kSettingsKeyProxyAddress, "")); 472 fSettings->GetValue(kSettingsKeyProxyAddress, "")); 473 474 fUseProxyAuthCheckBox = new BCheckBox("use authentication", 475 B_TRANSLATE("Proxy server requires authentication"), 476 new BMessage(MSG_USE_PROXY_AUTH_CHANGED)); 477 fUseProxyAuthCheckBox->SetValue(B_CONTROL_ON); 478 479 fProxyUsernameControl = new BTextControl("proxy username", 480 B_TRANSLATE("Proxy username:"), "", 481 new BMessage(MSG_PROXY_USERNAME_CHANGED)); 482 fProxyUsernameControl->SetModificationMessage( 483 new BMessage(MSG_PROXY_USERNAME_CHANGED)); 484 fProxyUsernameControl->SetText( 485 fSettings->GetValue(kSettingsKeyProxyUsername, "")); 486 487 fProxyPasswordControl = new BTextControl("proxy password", 488 B_TRANSLATE("Proxy password:"), "", 489 new BMessage(MSG_PROXY_PASSWORD_CHANGED)); 490 fProxyPasswordControl->SetModificationMessage( 491 new BMessage(MSG_PROXY_PASSWORD_CHANGED)); 492 fProxyPasswordControl->TextView()->HideTyping(true); 493 fProxyPasswordControl->SetText( 494 fSettings->GetValue(kSettingsKeyProxyPassword, "")); 467 495 468 496 BView* view = BGroupLayoutBuilder(B_VERTICAL, spacing / 2) 469 497 .Add(fUseProxyCheckBox) … … SettingsWindow::_CreateProxyPage(float spacing) 473 501 474 502 .Add(fProxyPortControl->CreateLabelLayoutItem(), 0, 1) 475 503 .Add(fProxyPortControl->CreateTextViewLayoutItem(), 1, 1) 504 ) 505 .Add(fUseProxyAuthCheckBox) 506 .Add(BGridLayoutBuilder(spacing / 2, spacing / 2) 507 .Add(fProxyUsernameControl->CreateLabelLayoutItem(), 0, 0) 508 .Add(fProxyUsernameControl->CreateTextViewLayoutItem(), 1, 0) 509 510 .Add(fProxyPasswordControl->CreateLabelLayoutItem(), 0, 1) 511 .Add(fProxyPasswordControl->CreateTextViewLayoutItem(), 1, 1) 476 512 ) 477 513 .Add(BSpaceLayoutItem::CreateGlue()) 478 514 … … SettingsWindow::_CanApplySettings() const 599 635 fSettings->GetValue(kSettingsKeyProxyAddress, "")) != 0); 600 636 601 637 canApply = canApply || (_ProxyPort() 602 != fSettings->GetValue(kSettingsKeyProxyPort, (uint32)0)); 638 != fSettings->GetValue(kSettingsKeyProxyPort, (uint32)0)); 639 640 canApply = canApply || ((fUseProxyAuthCheckBox->Value() == B_CONTROL_ON) 641 != fSettings->GetValue(kSettingsKeyUseProxyAuth, false)); 642 643 canApply = canApply || (strcmp(fProxyUsernameControl->Text(), 644 fSettings->GetValue(kSettingsKeyProxyUsername, "")) != 0); 645 646 canApply = canApply || (strcmp(fProxyPasswordControl->Text(), 647 fSettings->GetValue(kSettingsKeyProxyPassword, "")) != 0); 603 648 604 649 return canApply; 605 650 } … … SettingsWindow::_ApplySettings() 648 693 fSettings->SetValue(kSettingsKeyProxyAddress, 649 694 fProxyAddressControl->Text()); 650 695 uint32 proxyPort = _ProxyPort(); 651 fSettings->SetValue(kSettingsKeyProxyPort, proxyPort); 696 fSettings->SetValue(kSettingsKeyProxyPort, proxyPort); 697 fSettings->SetValue(kSettingsKeyUseProxyAuth, 698 fUseProxyAuthCheckBox->Value() == B_CONTROL_ON); 699 fSettings->SetValue(kSettingsKeyProxyUsername, 700 fProxyUsernameControl->Text()); 701 fSettings->SetValue(kSettingsKeyProxyPassword, 702 fProxyPasswordControl->Text()); 652 703 653 704 fSettings->Save(); 654 705 … … SettingsWindow::_ApplySettings() 660 711 BWebSettings::Default()->SetDefaultStandardFontSize(standardFontSize); 661 712 BWebSettings::Default()->SetDefaultFixedFontSize(fixedFontSize); 662 713 663 if (fUseProxyCheckBox->Value() == B_CONTROL_ON) { 664 BWebSettings::Default()->SetProxyInfo(fProxyAddressControl->Text(), 665 proxyPort, B_PROXY_TYPE_HTTP, "", ""); 714 if (fUseProxyCheckBox->Value() == B_CONTROL_ON) { 715 if (fUseProxyAuthCheckBox->Value() == B_CONTROL_ON) { 716 BWebSettings::Default()->SetProxyInfo(fProxyAddressControl->Text(), 717 proxyPort, B_PROXY_TYPE_HTTP, fProxyUsernameControl->Text(), 718 fProxyPasswordControl->Text()); 719 } else { 720 BWebSettings::Default()->SetProxyInfo(fProxyAddressControl->Text(), 721 proxyPort, B_PROXY_TYPE_HTTP, "", ""); 722 } 666 723 } else 667 724 BWebSettings::Default()->SetProxyInfo(); 668 725 … … SettingsWindow::_RevertSettings() 760 817 "")); 761 818 text = ""; 762 819 text << fSettings->GetValue(kSettingsKeyProxyPort, (uint32)0); 763 fProxyPortControl->SetText(text.String()); 820 fProxyPortControl->SetText(text.String()); 821 fUseProxyAuthCheckBox->SetValue(fSettings->GetValue(kSettingsKeyUseProxyAuth, 822 false)); 823 fProxyUsernameControl->SetText(fSettings->GetValue(kSettingsKeyProxyUsername, 824 "")); 825 fProxyPasswordControl->SetText(fSettings->GetValue(kSettingsKeyProxyPassword, 826 "")); 764 827 765 828 _ValidateControlsEnabledStatus(); 766 829 } … … SettingsWindow::_ValidateControlsEnabledStatus() 778 841 779 842 bool useProxy = fUseProxyCheckBox->Value() == B_CONTROL_ON; 780 843 fProxyAddressControl->SetEnabled(useProxy); 781 fProxyPortControl->SetEnabled(useProxy); 844 fProxyPortControl->SetEnabled(useProxy); 845 fUseProxyAuthCheckBox->SetEnabled(useProxy); 846 bool useProxyAuth = useProxy && fUseProxyAuthCheckBox->Value() == B_CONTROL_ON; 847 fProxyUsernameControl->SetEnabled(useProxyAuth); 848 fProxyPasswordControl->SetEnabled(useProxyAuth); 782 849 } 783 850 784 851 -
src/apps/webpositive/SettingsWindow.h
diff --git a/src/apps/webpositive/SettingsWindow.h b/src/apps/webpositive/SettingsWindow.h old mode 100644 new mode 100755 index 251d844..0de4a5b
a b private: 107 107 108 108 BCheckBox* fUseProxyCheckBox; 109 109 BTextControl* fProxyAddressControl; 110 BTextControl* fProxyPortControl; 110 BTextControl* fProxyPortControl; 111 BCheckBox* fUseProxyAuthCheckBox; 112 BTextControl* fProxyUsernameControl; 113 BTextControl* fProxyPasswordControl; 111 114 112 115 BButton* fApplyButton; 113 116 BButton* fCancelButton;