Tizen 2.2.1
[framework/osp/web.git] / src / controls / FWebCtrl_AuthConfirmPopup.cpp
index ae32ed0..eeaa139 100755 (executable)
@@ -28,6 +28,7 @@
 #include <FUiCtrlEditField.h>
 #include <FUiCtrlLabel.h>
 #include <FUiCtrlPanel.h>
+#include <FUiKeyEventInfo.h>
 #include <FUiLayout.h>
 #include <FUiVerticalBoxLayout.h>
 #include <FWebCtrlAuthenticationChallenge.h>
@@ -35,8 +36,8 @@
 #include <FSys_VibratorImpl.h>
 #include <FUi_ControlManager.h>
 #include <FUi_ResourceManager.h>
-#include "FWebCtrl_WebImpl.h"
 #include "FWebCtrl_AuthConfirmPopup.h"
+#include "FWebCtrl_WebImpl.h"
 
 
 using namespace Tizen::Base;
@@ -47,13 +48,13 @@ using namespace Tizen::Ui;
 using namespace Tizen::Ui::Controls;
 
 
-static const int AUTH_POPUP_TMP_LABLE_HEIGHT = 10;
-
-
 namespace Tizen { namespace Web { namespace Controls
 {
 
 
+static const int EDIT_TEXT_SIZE = 35;
+
+
 _AuthConfirmPopup::_AuthConfirmPopup(void)
        : __pIdEditField(null)
        , __pPwdEditField(null)
@@ -64,6 +65,10 @@ _AuthConfirmPopup::_AuthConfirmPopup(void)
 
 _AuthConfirmPopup::~_AuthConfirmPopup(void)
 {
+       if (IsModalPopup())
+       {
+               __pAuthHandler->Cancel();
+       }
 }
 
 
@@ -84,11 +89,11 @@ _AuthConfirmPopup::Construct(const String& host, const String& realm, Authentica
 
        Rectangle rect(0, 0, 0, 0);
        rect.width = pPopupData->popupDim.width;
-       rect.height = (5*pPopupData->spacePad) + (pPopupData->editDim.height*2) + pPopupData->btnDim.height + 2*pPopupData->labelDim.height;
+       rect.height = (2*pPopupData->spacePad) + (pPopupData->editDim.height*2) + pPopupData->panelHeight + (2*pPopupData->labelDim.height);
        r = _WebPopup::Construct(true, Dimension(rect.width, rect.height));
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       SetTitleText("Authentication Required");
+       SetTitleText(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_TPLATFORM_HEADER_ENTER_CREDENTIALS_ABB"));
 
        //host realm label
        rect.height = 2*pPopupData->labelDim.height;
@@ -96,11 +101,9 @@ _AuthConfirmPopup::Construct(const String& host, const String& realm, Authentica
        std::unique_ptr<Label> pLabel(new (std::nothrow) Label());
        SysTryReturnResult(NID_WEB_CTRL, pLabel.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
 
-       String hostRealm(L"A username and password are being requested by ");
-       hostRealm.Append(host);
-       hostRealm.Append(L". The site says: \"");
+       String hostRealm(host);
+       hostRealm.Append(L": \n ");
        hostRealm.Append(realm);
-       hostRealm.Append(L"\"");
        r = pLabel->Construct(rect, hostRealm);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -123,9 +126,9 @@ _AuthConfirmPopup::Construct(const String& host, const String& realm, Authentica
        r = pIdEditField->Construct(rect, EDIT_FIELD_STYLE_NORMAL);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       pIdEditField->SetGuideText(L"User name");
+       pIdEditField->SetGuideText(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_WIFI_BODY_ENTER_YOUR_ID"));
        pIdEditField->SetGuideTextColor(Color::GetColor(COLOR_ID_GREY));
-       pIdEditField->SetTextSize(35);;
+       pIdEditField->SetTextSize(EDIT_TEXT_SIZE);;
 
        r = AddControl(*pIdEditField);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
@@ -138,9 +141,9 @@ _AuthConfirmPopup::Construct(const String& host, const String& realm, Authentica
        r = pPwdEditField->Construct(rect, EDIT_FIELD_STYLE_PASSWORD);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       pPwdEditField->SetGuideText(L"Password");
+       pPwdEditField->SetGuideText(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_TPLATFORM_BODY_ENTER_YOUR_PASSWORD_ABB"));
        pPwdEditField->SetGuideTextColor(Color::GetColor(COLOR_ID_GREY));
-       pPwdEditField->SetTextSize(35);;
+       pPwdEditField->SetTextSize(EDIT_TEXT_SIZE);;
 
        r = AddControl(*pPwdEditField);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
@@ -155,14 +158,14 @@ _AuthConfirmPopup::Construct(const String& host, const String& realm, Authentica
        ArrayList idList;
        r = idList.Construct();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-       idList.Add(*(new Integer(ID_BUTTON_AUTH_PROCESS)));
        idList.Add(*(new Integer(ID_BUTTON_AUTH_CANCEL)));
+       idList.Add(*(new Integer(ID_BUTTON_AUTH_PROCESS)));
 
        ArrayList titleList;
        r = titleList.Construct();
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-       titleList.Add(*(new String(pSysResource->GetString("sys_string", "IDS_COM_SK_OK"))));
-       titleList.Add(*(new String(pSysResource->GetString("sys_string", "IDS_COM_POP_CANCEL"))));
+       titleList.Add(*(new String(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_TPLATFORM_BUTTON_CANCEL_ABB"))));
+       titleList.Add(*(new String(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_TPLATFORM_BUTTON_CONTINUE_ABB"))));
 
        r = CreateAndAddButtons(idList, titleList, pButtonPanel);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
@@ -173,11 +176,12 @@ _AuthConfirmPopup::Construct(const String& host, const String& realm, Authentica
        pLayout->SetHorizontalAlignment(*pHostLabel, LAYOUT_HORIZONTAL_ALIGN_CENTER);
        pLayout->SetHorizontalAlignment(*__pIdEditField, LAYOUT_HORIZONTAL_ALIGN_CENTER);
        pLayout->SetHorizontalAlignment(*__pPwdEditField, LAYOUT_HORIZONTAL_ALIGN_CENTER);
-       pLayout->SetHorizontalAlignment(*pButtonPanel, LAYOUT_HORIZONTAL_ALIGN_CENTER);
 
        pLayout->SetSpacing(*__pPwdEditField, pPopupData->spacePad);
        pLayout->SetSpacing(*pButtonPanel, pPopupData->spacePad);
 
+       SetPropagatedKeyEventListener(this);
+
        return E_SUCCESS;
 }
 
@@ -187,6 +191,9 @@ _AuthConfirmPopup::OnActionPerformed(const Control& source, int actionId)
 {
        result r = E_SUCCESS;
 
+       r = HidePopup();
+       SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
        switch (actionId)
        {
        case ID_BUTTON_AUTH_PROCESS:
@@ -200,9 +207,47 @@ _AuthConfirmPopup::OnActionPerformed(const Control& source, int actionId)
        default:
                break;
        }
+}
 
-       r = HidePopup();
-       SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+bool
+_AuthConfirmPopup::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
+{
+       return false;
+}
+
+bool
+_AuthConfirmPopup::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
+{
+       result r = E_SUCCESS;
+       if ((keyEventInfo.GetKeyCode() == KEY_ESC || keyEventInfo.GetKeyCode() == KEY_BACK) && source.GetShowState() == true)
+       {
+               __pAuthHandler->Cancel();
+               r = HidePopup();
+               if (IsFailed(r))
+               {
+                       SysLogException(NID_WEB_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+       }
+
+       return false;
+}
+
+bool
+_AuthConfirmPopup::OnPreviewKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
+{
+       return false;
+}
+
+bool
+_AuthConfirmPopup::OnPreviewKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
+{
+       return false;
+}
+
+bool
+_AuthConfirmPopup::TranslateKeyEventInfo(Control& source, KeyEventInfo& keyEventInfo)
+{
+       return false;
 }