-//\r
-\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Flora License, Version 1.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://floralicense.org/license/\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an AS IS BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-//!Internet EditHomePageForm class\r
-/*@file: EditHomePageForm.h\r
- *@brief: Allow user to set any page as Home page.\r
- *\r
- */\r
-\r
-#include <FAppUiApp.h>\r
-#include <FUi.h>\r
-\r
-#include "IntBookmarkData.h"\r
-#include "IntCommonLib.h"\r
-#include "IntEditHomePageForm.h"\r
-#include "IntMultipleWindowPresentationModel.h"\r
-#include "IntSceneRegister.h"\r
-#include "IntSettingPresentationModel.h"\r
-\r
-\r
-using namespace Tizen::App;\r
-using namespace Tizen::Base;\r
-using namespace Tizen::Base::Collection;\r
-using namespace Tizen::Base::Utility;\r
-using namespace Tizen::Graphics;\r
-using namespace Tizen::Ui;\r
-using namespace Tizen::Ui::Controls;\r
-using namespace Tizen::Ui::Scenes;\r
-\r
-const int EditHomePageForm::IDA_BUTTON_DONE = 101;\r
-const int EditHomePageForm::IDA_BUTTON_CANCEL = 102;\r
-\r
-EditHomePageForm::EditHomePageForm(void)\r
-:__pUrlEditField(null)\r
-, __pMsgBox(null)\r
-, __modalMsgBoxResult(0)\r
-{\r
-\r
-}\r
-\r
-EditHomePageForm::~EditHomePageForm(void)\r
-{\r
-\r
-}\r
-\r
-bool\r
-EditHomePageForm::Initialize(void)\r
-{\r
- Construct(L"IDL_EDIT_HOME_PAGE");\r
- SetOrientation(ORIENTATION_AUTOMATIC);\r
- return true;\r
-}\r
-\r
-result\r
-EditHomePageForm::OnInitializing(void)\r
-{\r
- result r = E_SUCCESS;\r
- SetFormBackEventListener(this);\r
- SceneManager* pSceneManager = SceneManager::GetInstance();\r
- AppAssert(pSceneManager);\r
- pSceneManager->AddSceneEventListener(IDSCN_EDIT_HOMEPAGE_VIEW, *this);\r
-\r
- GetHeader()->AddActionEventListener(*this);\r
-\r
- __pUrlEditField = static_cast<EditField*>(GetControl(L"IDC_EDITFIELD"));\r
- if (__pUrlEditField != null)\r
- {\r
- __pUrlEditField->AddTextEventListener(*this);\r
- __pUrlEditField->SetOverlayKeypadCommandButtonVisible(false);\r
- }\r
- return r;\r
-}\r
-\r
-result\r
-EditHomePageForm::OnTerminating(void)\r
-{\r
- result r = E_SUCCESS;\r
- return r;\r
-}\r
-\r
-void\r
-EditHomePageForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)\r
-{\r
- if (__pUrlEditField != null)\r
- {\r
- String favURL = SettingPresentationModel::GetInstance()->GetFavoriteUrl();\r
- AppLogDebug("EditHomePageForm::OnSceneActivatedN favURL %ls",favURL.GetPointer());\r
- __pUrlEditField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteUrl());\r
- __pUrlEditField->SetFocus();\r
- __pUrlEditField->SetCursorPosition(__pUrlEditField->GetTextLength());\r
- __pUrlEditField->ShowKeypad();\r
- __pUrlEditField->Invalidate(true);\r
- }\r
-\r
- Invalidate(true);\r
-\r
- return;\r
-}\r
-\r
-void\r
-EditHomePageForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)\r
-{\r
-\r
-}\r
-\r
-void\r
-EditHomePageForm::OnFormBackRequested(Form& source)\r
-{\r
-\r
-}\r
-\r
-void\r
-EditHomePageForm::OnActionPerformed(const Control& source, int actionId)\r
-{\r
- ArrayList* pArgList = null;\r
- pArgList = new(std::nothrow) ArrayList();\r
- switch(actionId)\r
- {\r
- case IDA_BUTTON_DONE:\r
- {\r
- pArgList->Add(*new(std::nothrow) String(CommonUtil::GetString(L"IDS_BR_SK_DONE")));\r
- String urlText = __pUrlEditField->GetText();\r
- urlText.Trim();\r
- AppLogDebug("set url text is %ls",urlText.GetPointer());\r
-\r
- bool ret = false;\r
- bool flag = false;\r
- String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");\r
- String secondPattern(L"^[A-Za-z0-9\.\+-:#@%/;$~?]+\\.[A-Za-z0-9\+-=:#@%/;$~()_?\\\.&]{2,}$"); // URL of type abc.com (i.e without protocol in front of it)\r
- RegularExpression firstRegex;\r
- RegularExpression secondRegex;\r
-\r
- firstRegex.Construct(firstPattern, REGEX_CASELESS);\r
- secondRegex.Construct(secondPattern, REGEX_CASELESS);\r
-\r
- Uri uri;\r
- uri.SetUri(urlText);\r
- urlText = uri.GetEncodedString();\r
-\r
- // Match\r
- ret = firstRegex.Match(urlText, false); // This returns true value\r
- flag = secondRegex.Match(urlText, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)\r
-\r
-\r
- if (ret == true)\r
- {\r
- //valid Url\r
- SettingPresentationModel::GetInstance()->SetHomepage(urlText);\r
- SettingPresentationModel::GetInstance()->SetFavoriteValue(urlText);\r
- result r = SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(), pArgList);\r
- TryCatch(!IsFailed(r), "EditHomePageForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));\r
- }\r
- else\r
- {\r
- if (flag == true)\r
- {\r
- String validUrl;\r
- validUrl = L"http://";\r
- validUrl.Append(urlText);\r
- // save Url\r
- SettingPresentationModel::GetInstance()->SetHomepage(validUrl);\r
- SettingPresentationModel::GetInstance()->SetFavoriteValue(validUrl);\r
- result r = SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(), pArgList);\r
- TryCatch(!IsFailed(r), "EditHomePageForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));\r
- }\r
- else\r
- {\r
- // show pop up , not a valid URL\r
- String msg = CommonUtil::GetString(L"IDS_BR_POP_INVALIDADDRESS");\r
- CreateMessage(msg);\r
- }\r
- }\r
-\r
- break;\r
- }\r
- case IDA_BUTTON_CANCEL:\r
- {\r
- pArgList->Add(*new(std::nothrow) String(CommonUtil::GetString(L"IDS_BR_SK_CANCEL")));\r
- result r = SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(), pArgList);\r
- TryCatch(!IsFailed(r), "EditHomePageForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));\r
- break;\r
- }\r
- default:\r
- break;\r
- }\r
-\r
- CATCH:\r
- pArgList->RemoveAll(true);\r
- delete pArgList;\r
- return;\r
-}\r
-\r
-void\r
-EditHomePageForm::OnTextValueChanged(const Control& source)\r
-{\r
- String title ;\r
- Header* pHeader = GetHeader();\r
-\r
- if (pHeader == NULL)\r
- {\r
- return;\r
- }\r
-\r
- if (__pUrlEditField == NULL)\r
- {\r
- return;\r
- }\r
-\r
- title = __pUrlEditField->GetText();\r
- title.Trim();\r
-\r
- // To disable done button when folder title edit-field is empty\r
- if (__pUrlEditField && title.IsEmpty() == true)\r
- {\r
- pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);\r
- }\r
- else\r
- {\r
- pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, true);\r
- }\r
- pHeader->Invalidate(true);\r
- return;\r
-}\r
-\r
-void\r
-EditHomePageForm::OnTextValueChangeCanceled(const Control& source)\r
-{\r
- return;\r
-}\r
-\r
-void\r
-EditHomePageForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)\r
-{\r
- return;\r
-}\r
-\r
-void\r
-EditHomePageForm::CreateMessage(String& message)\r
-{\r
-\r
- if (__pMsgBox != null)\r
- {\r
- delete __pMsgBox;\r
- __pMsgBox = null;\r
- __modalMsgBoxResult = 0;\r
- }\r
-\r
- __pMsgBox = new(std::nothrow) MessageBox;\r
- if (__pMsgBox != null)\r
- {\r
- __pMsgBox->Construct(L"", message, MSGBOX_STYLE_OK, 3000);\r
- }\r
-\r
- if (__pMsgBox != null)\r
- {\r
- __pMsgBox->ShowAndWait(__modalMsgBoxResult);\r
- if (__modalMsgBoxResult == MSGBOX_RESULT_OK)\r
- {\r
- if (__pMsgBox != null)\r
- {\r
- delete __pMsgBox;\r
- __pMsgBox = null;\r
- }\r
- }\r
- __modalMsgBoxResult = 0;\r
- }\r
-\r
- return;\r
-}\r
+//
+
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.1 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+//!Internet EditHomePageForm class
+/*@file: EditHomePageForm.h
+ *@brief: Allow user to set any page as Home page.
+ *
+ */
+
+#include <FAppUiApp.h>
+#include <FUi.h>
+
+#include "IntBookmarkData.h"
+#include "IntCommonLib.h"
+#include "IntEditHomePageForm.h"
+#include "IntMultipleWindowPresentationModel.h"
+#include "IntSceneRegister.h"
+#include "IntSettingPresentationModel.h"
+
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Graphics;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Ui::Scenes;
+
+const int EditHomePageForm::IDA_BUTTON_DONE = 101;
+const int EditHomePageForm::IDA_BUTTON_CANCEL = 102;
+
+EditHomePageForm::EditHomePageForm(void)
+:__pUrlEditField(null)
+, __pMsgBox(null)
+, __modalMsgBoxResult(0)
+{
+
+}
+
+EditHomePageForm::~EditHomePageForm(void)
+{
+
+}
+
+bool
+EditHomePageForm::Initialize(void)
+{
+ Construct(L"IDL_EDIT_HOME_PAGE");
+ SetOrientation(ORIENTATION_AUTOMATIC);
+ return true;
+}
+
+result
+EditHomePageForm::OnInitializing(void)
+{
+ result r = E_SUCCESS;
+ SetFormBackEventListener(this);
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ AppAssert(pSceneManager);
+ pSceneManager->AddSceneEventListener(IDSCN_EDIT_HOMEPAGE_VIEW, *this);
+
+ GetHeader()->AddActionEventListener(*this);
+
+ __pUrlEditField = static_cast<EditField*>(GetControl(L"IDC_EDITFIELD"));
+ if (__pUrlEditField != null)
+ {
+ __pUrlEditField->AddTextEventListener(*this);
+ __pUrlEditField->SetOverlayKeypadCommandButtonVisible(false);
+ }
+ return r;
+}
+
+result
+EditHomePageForm::OnTerminating(void)
+{
+ result r = E_SUCCESS;
+ return r;
+}
+
+void
+EditHomePageForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
+{
+ if (__pUrlEditField != null)
+ {
+ String favURL = SettingPresentationModel::GetInstance()->GetFavoriteUrl();
+ AppLogDebug("EditHomePageForm::OnSceneActivatedN favURL %ls",favURL.GetPointer());
+ __pUrlEditField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteUrl());
+ __pUrlEditField->SetFocus();
+ __pUrlEditField->SetCursorPosition(__pUrlEditField->GetTextLength());
+ __pUrlEditField->ShowKeypad();
+ __pUrlEditField->Invalidate(true);
+ }
+
+ Invalidate(true);
+
+ return;
+}
+
+void
+EditHomePageForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
+{
+
+}
+
+void
+EditHomePageForm::OnFormBackRequested(Form& source)
+{
+ ArrayList* pArgList = null;
+ pArgList = new(std::nothrow) ArrayList();
+ pArgList->Construct();
+ pArgList->Add(*new(std::nothrow) String(CommonUtil::GetString(L"IDS_BR_SK_CANCEL")));
+ SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(), pArgList);
+
+}
+
+void
+EditHomePageForm::OnActionPerformed(const Control& source, int actionId)
+{
+ ArrayList* pArgList = null;
+ pArgList = new(std::nothrow) ArrayList();
+ pArgList->Construct();
+ switch(actionId)
+ {
+ case IDA_BUTTON_DONE:
+ {
+ pArgList->Add(*new(std::nothrow) String(CommonUtil::GetString(L"IDS_BR_SK_DONE")));
+ String urlText = __pUrlEditField->GetText();
+ urlText.Trim();
+ AppLogDebug("set url text is %ls",urlText.GetPointer());
+
+ bool ret = false;
+ bool flag = false;
+ String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");//[\w\d:#@%/;$()~_?\+-=\\\.&]*
+ String secondPattern(L"^[A-Za-z0-9\.\+-:#@%/;$~?]+\\.[A-Za-z0-9 !\+-=:#@%/;$~()_?\\\.&]{2,}$"); // URL of type abc.com (i.e without protocol in front of it)
+ RegularExpression firstRegex;
+ RegularExpression secondRegex;
+
+ firstRegex.Construct(firstPattern, REGEX_CASELESS);
+ secondRegex.Construct(secondPattern, REGEX_CASELESS);
+
+// Uri uri;
+// uri.SetUri(urlText);
+// urlText = uri.GetEncodedString();
+
+ // Match
+ ret = firstRegex.Match(urlText, false); // This returns true value
+ flag = secondRegex.Match(urlText, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
+
+
+ if (ret == true)
+ {
+ //valid Url
+ SettingPresentationModel::GetInstance()->SetHomepage(urlText);
+ SettingPresentationModel::GetInstance()->SetFavoriteValue(urlText);
+ result r = SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(), pArgList);
+ TryCatch(!IsFailed(r), "EditHomePageForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
+ }
+ else
+ {
+ if (flag == true)
+ {
+ String validUrl;
+ validUrl = L"http://";
+ validUrl.Append(urlText);
+ // save Url
+ SettingPresentationModel::GetInstance()->SetHomepage(validUrl);
+ SettingPresentationModel::GetInstance()->SetFavoriteValue(validUrl);
+ result r = SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(), pArgList);
+ TryCatch(!IsFailed(r), "EditHomePageForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
+ }
+ else
+ {
+ // show pop up , not a valid URL
+ String msg = CommonUtil::GetString(L"IDS_COM_POP_INVALID_URL");
+ CreateMessage(msg);
+ }
+ }
+
+ break;
+ }
+ case IDA_BUTTON_CANCEL:
+ {
+ pArgList->Add(*new(std::nothrow) String(CommonUtil::GetString(L"IDS_BR_SK_CANCEL")));
+ result r = SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(), pArgList);
+ TryCatch(!IsFailed(r), "EditHomePageForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
+ break;
+ }
+ default:
+ break;
+ }
+
+ CATCH:
+ pArgList->RemoveAll(true);
+ delete pArgList;
+ return;
+}
+
+void
+EditHomePageForm::OnTextValueChanged(const Control& source)
+{
+ String title ;
+ Header* pHeader = GetHeader();
+
+ if (pHeader == NULL)
+ {
+ return;
+ }
+
+ if (__pUrlEditField == NULL)
+ {
+ return;
+ }
+
+ title = __pUrlEditField->GetText();
+ title.Trim();
+
+ // To disable done button when folder title edit-field is empty
+ if (__pUrlEditField && title.IsEmpty() == true)
+ {
+ pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
+ }
+ else
+ {
+ pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
+ }
+ pHeader->Invalidate(true);
+ return;
+}
+
+void
+EditHomePageForm::OnTextValueChangeCanceled(const Control& source)
+{
+ return;
+}
+
+void
+EditHomePageForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
+{
+ return;
+}
+
+void
+EditHomePageForm::CreateMessage(String& message)
+{
+
+ if (__pMsgBox != null)
+ {
+ delete __pMsgBox;
+ __pMsgBox = null;
+ __modalMsgBoxResult = 0;
+ }
+
+ __pMsgBox = new(std::nothrow) MessageBox;
+ if (__pMsgBox != null)
+ {
+ __pMsgBox->Construct(L"", message, MSGBOX_STYLE_OK, 3000);
+ }
+
+ if (__pMsgBox != null)
+ {
+ __pMsgBox->ShowAndWait(__modalMsgBoxResult);
+ if (__modalMsgBoxResult == MSGBOX_RESULT_OK)
+ {
+ if (__pMsgBox != null)
+ {
+ delete __pMsgBox;
+ __pMsgBox = null;
+ }
+ }
+ __modalMsgBoxResult = 0;
+ }
+
+ return;
+}