2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 //!Internet MainForm class
19 *@brief: The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,
20 * loading,handling events etc.
24 #include <FGraphics.h>
29 #include "IntBookmarkData.h"
30 #include "IntBookmarkPresentationModel.h"
31 #include "IntCommonLib.h"
32 #include "IntFaviconManager.h"
33 #include "IntMainForm.h"
34 #include "IntNotificationPanel.h"
35 #include "IntSceneRegister.h"
36 #include "IntSettingPresentationModel.h"
38 using namespace Tizen::App;
39 using namespace Tizen::Base;
40 using namespace Tizen::Base::Collection;
41 using namespace Tizen::Base::Runtime;
42 using namespace Tizen::Base::Utility;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Io;
45 using namespace Tizen::Locales;
46 using namespace Tizen::Media;
47 using namespace Tizen::Ui;
48 using namespace Tizen::Ui::Controls;
49 using namespace Tizen::Content;
50 using namespace Tizen::Ui::Scenes;
51 using namespace Tizen::System;
52 using namespace Tizen::Web;
53 using namespace Tizen::Web::Controls;
55 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
56 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
57 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
58 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
59 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
64 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
65 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
66 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
67 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
68 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
69 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
70 static const wchar_t* IDS_APPID = L"AppID";
71 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
72 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
74 const int IDA_BACKBTN_CLICKED = 101;
75 const int IDA_BOOKMARKBTN_CLICKED = 102;
76 const int IDA_MOREBTN_CLICKED = 103;
77 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
78 const int IDA_NEWWINDOWBTN_CLICKED = 105;
79 const int IDA_FORWARD_CLICKED = 106;
80 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
81 const int IDA_SHARE_CLICKED = 108;
82 const int IDA_FINDONPAGE_CLICKED = 109;
83 const int IDA_PRIVATEON_CLICKED = 110;
84 const int IDA_SETTINGS_CLICKED = 111;
85 const int IDA_READER_CLOSE_CLICKED = 112;
86 const int IDA_SMALLFONT_BTN_CLICKED = 113;
87 const int IDA_LARGEFONT_BTN_CLICKED = 114;
88 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
89 const int IDA_HISTORY_CLICKED = 116;
90 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
91 const int IDA_ADD_TO_HOME_CLICKED = 118;
92 const int IDA_SAVED_PAGES_CLICKED = 119;
93 const int IDA_DESKTOP_VIEW_CLICKED = 120;
94 const int IDA_SAVE_CLICKED = 121;
96 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
97 const int IDA_FINDWORD_NEXT_CLICKED = 202;
98 const int IDA_FINDWORD_PREV_CLICKED = 203;
99 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
100 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
102 const int IDA_COPY_IMAGE_CLICKED = 206;
103 const int IDA_VIEW_IMAGE_CLICKED = 207;
104 const int IDA_SAVE_IMAGE_CLICKED = 208;
105 const int IDA_SHARE_IMAGE_CLICKED = 209;
107 const int IDA_COPY_TEXT_CLICKED = 210;
108 const int IDA_PASTE_TEXT_CLICKED = 211;
109 const int IDA_FIND_TEXT__CLICKED = 212;
110 const int IDA_SHARE_TEXT_CLICKED = 213;
112 const int IDA_GO_BACK = 214;
113 const int IDA_GO_FORWARD = 215;
114 const int IDA_REFRESH_BTN_CLICKED = 216;
115 const int IDA_STOP_BTN_CLICKED = 217;
116 const int IDA_CLEAR_URL = 218;
118 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
120 const int MainForm::IDA_FORMAT_BITMAP = 500;
121 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
122 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
123 const int MainForm::IDA_FORMAT_URL_STRING = 503;
124 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
126 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
127 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
128 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
130 MainForm::MainForm(void)
132 __isLongPressedDone = false;
133 __pAddressbar = null;
134 // __pMostVisitedSitesPanel = null;
135 __pMostVisitedListView = null;
136 __pFooterPanel = null;
137 __pHitElementResult = null;
138 __pWindowInfo = null;
142 __pFindWordControl = null;
143 __pFindWordPanel = null;
144 __pFindWordBgLabel = null;
145 __pFindWordEditField = null;
146 __pFindWordClear = null;
147 __pFindWordCountLabel = null;
148 __pFindWordNext = null;
149 __pFindWordPrev = null;
150 __previousZoomLevel = 1.0;
152 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
155 __currentSearchStr = L"";
156 __currentSelectedStr = L"";
157 __maxOccurrances = 0;
158 __currentWordIndex = 0;
161 __inputEventToBeSupressed = false;
162 __isLoadingData = false;
163 __isLoadingCompleted = false;
164 __progressPercentage = 0;
165 __touchPoint1 = Point(-1,-1);
166 __touchPoint2 = Point(-1,-1);
168 // __pReaderPopup = null;
169 __pReaderData = null;
171 __pReaderCloseBtn = null;
172 //__pNewWindowButton = null;
173 __pMoreButton = null;
174 __pMultiWindowButton = null;
175 __pArticleReaderPanel = null;
176 __pBlankPanel = null;
177 __pArticleReaderLabel = null;
178 __webControlHeight = 0;
179 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
180 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
181 __pMostVisitedSites = null;
182 __pFooterUrlField = null;
184 __pGoForwardBtn = null;
185 __pRefreshBtn = null;
186 __pProgressbarLabel = null;
187 __pFooterLabel = null;
192 MainForm::~MainForm(void)
194 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
198 __pAddressbar->SetAddressbarEventListener(null);
200 if (__pReaderData != null)
202 delete __pReaderData;
203 __pReaderData = null;
206 if (__pPopUp != null)
212 if (__pHitElementResult != null)
214 delete __pHitElementResult;
215 __pHitElementResult = null;
217 String* pSelectedScene = NULL;
218 Object* pValue = NULL;
219 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
220 pSelectedScene = (String*) pValue;
222 /*if (pSelectedScene != null)
224 delete pSelectedScene;
226 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
230 MainForm::Initialize(void)
232 Construct(L"IDL_FORM");
237 MainForm::OnInitializing(void)
239 AppLog("get client area width = %d",GetClientAreaBounds().width);
240 AppLog("get client area height = %d",GetClientAreaBounds().height);
241 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
242 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
244 Panel* pFooterPanel = null;
246 __pSaveImage = new Image();
247 __pSaveImage->Construct();
249 // Setup back event listener
250 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
251 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
252 AddOrientationEventListener(*this);
253 AppLogDebug(" MainForm::OnInitializing ended");
254 if (__pMostVisitedSites == null)
256 __pMostVisitedSites = new(std::nothrow) ArrayList();
257 __pMostVisitedSites->Construct();
259 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
261 __pItemContext= new(std::nothrow) ListContextItem();
262 __pItemContext->Construct();
263 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
264 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
266 if (pBitmapNormal != null && pBitmapPressed != null)
268 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
271 if (pBitmapNormal != null)
273 delete pBitmapNormal;
276 if (pBitmapPressed != null)
278 delete pBitmapPressed;
281 __pItemContextLandscape= new(std::nothrow) ListContextItem();
282 __pItemContextLandscape->Construct();
283 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
284 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
286 if (pBitmapNormal != null && pBitmapPressed != null)
288 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
291 if (pBitmapNormal != null)
293 delete pBitmapNormal;
296 if (pBitmapPressed != null)
298 delete pBitmapPressed;
305 MainForm::InitAddressbar(void)
307 AppLogDebug("MainForm::InitAddressbar entered");
309 result r = E_SUCCESS;
311 if (__pAddressbar != null)
315 __pAddressbar = new(std::nothrow) Addressbar();
316 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
317 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
320 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
323 __pAddressbar->SetAddressbarEventListener(this);
324 AddControl(*__pAddressbar);
325 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
326 SetControlAlwaysOnTop(*__pAddressbar, true);
327 __adressPanelPosition = __pAddressbar->GetPosition();
329 AppLogDebug("MainForm::InitAddressbar exit");
335 MainForm::CreateReaderPanel(void)
337 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
338 result r = E_FAILURE;
340 Button *pSmallFontBtn = null;
341 Button *pLargeFontBtn = null;
343 __pBlankPanel = new (std::nothrow) Panel();
344 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
346 __pArticleReaderPanel = new (std::nothrow) Panel();
347 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
349 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
350 if (__pReaderCloseBtn)
352 AppLogDebug("CreateReaderPanel() 6");
353 __pReaderCloseBtn->AddActionEventListener(*this);
354 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
357 __pWebReader = new (std::nothrow) Web();
358 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
360 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
361 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
363 r = __pWebReader->SetSetting(settings);
365 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
368 __pArticleReaderLabel = new Label();
369 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
371 __pBlankPanel->AddControl(*__pArticleReaderLabel);
372 __pBlankPanel->AddControl(*__pArticleReaderPanel);
373 AddControl(*__pBlankPanel);
375 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
376 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
377 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
379 __pArticleReaderPanel->AddControl(*__pWebReader);
380 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
381 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
382 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
384 if (pBitmap != null && pSrcBitmap != null)
386 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
388 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
390 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
393 pSmallFontBtn->AddActionEventListener(*this);
394 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
397 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
400 pLargeFontBtn->AddActionEventListener(*this);
401 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
410 if (pSrcBitmap != null)
416 SetControlAlwaysOnTop(*__pBlankPanel, true);
417 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
424 MainForm::InitWebControl()
426 AppLogDebug("MainForm::InitWebControl enter");
427 result r = E_SUCCESS;
428 AppLogDebug("InitWebControl");
430 if (__pAddressbar == null || __pFooterPanel == null)
433 const int Y_WEBCONTROL_POSITION = 0;
434 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
435 if (__pMostVisitedListView)
437 __pMostVisitedListView->SetShowState(false);
439 if (__pWebViewer != null)
441 AppLogDebug("Already initialized");
444 __pWebViewer = new(std::nothrow) Web();
445 if(__pWebViewer == NULL)
447 AppLogDebug("Initialization failed");
450 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));
454 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
459 r = AddControl(*__pWebViewer);
463 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
466 __webControlPosition = __pWebViewer->GetPosition();
467 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
470 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
474 __pWebViewer->SetLoadingListener(this);
475 __pWebViewer->SetWebUiEventListener(this);
476 __pWebViewer->SetWebKeypadEventListener(this);
477 __pWebViewer->SetFocus();
478 __pWebViewer->AddTouchEventListener(*this);
480 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
481 __pWebViewer->SetTextSearchListener(this);
484 AppLogDebug("MainForm :before return");
486 AppLogDebug("MainForm::InitWebControl Exit");
492 MainForm::SetJavascriptEnabled()
494 WebSetting settings = __pWebViewer->GetSetting();
495 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
496 __pWebViewer->SetSetting(settings);
500 MainForm::SetImageLoadEnabled()
502 WebSetting settings = __pWebViewer->GetSetting();
503 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
504 __pWebViewer->SetSetting(settings);
508 MainForm::InitFooter(void)
510 AppLogDebug("MainForm::InitFooter entered");
511 Button* pBackButton = null;
512 Button* pBookmarkButton = null;
513 Button* pMultiWindowButton = null;
514 Bitmap *pIconBitmap = null;
515 Bitmap *pBGBitmap = null;
516 Label *pBGLabel = null;
518 if (__pFooterPanel == null)
520 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
523 if (__pFooterPanel == null)
528 SetControlAlwaysOnTop(*__pFooterPanel, true);
530 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
531 if ( __pFooterLabel == NULL )
535 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
536 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
539 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
543 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
545 if ( __pMultiWindowButton == NULL )
550 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
552 if ( __pMoreButton == NULL )
557 if (__pMultiWindowButton != null)
559 Bitmap* pBitmap = null;
560 Bitmap* pPressedBitmap = null;
561 String imagePath = "I01_toolbar_icon_windows_manager_0";
562 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
563 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
564 imagePath.Append(totalCount);
565 imagePath.Append(".png");
567 pressedImagePath.Append(totalCount);
568 pressedImagePath.Append("_press.png");
570 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
571 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
572 if ( pBitmap == null )
577 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
580 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
581 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
586 __pMultiWindowButton->AddActionEventListener(*this);
587 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
592 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
593 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
596 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
597 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
598 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
602 __pMoreButton->AddActionEventListener(*this);
603 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
606 //Add the editfield for url
607 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
608 if (__pFooterUrlField == NULL)
610 return E_INVALID_KEY;
613 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
614 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
615 //__pFooterUrlField->AddFocusEventListener(*this);
616 __pFooterUrlField->AddKeypadEventListener(*this);
618 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
620 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
622 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
624 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
628 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
629 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
632 //Add the go Back Button
633 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
634 if (__pGoBackBtn == NULL)
636 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
637 return E_INVALID_KEY;
639 __pGoBackBtn->SetActionId(IDA_GO_BACK);
640 __pGoBackBtn->AddActionEventListener(*this);
642 //Add the go forward Button
643 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
644 if (__pGoForwardBtn == NULL)
646 AppLogDebug("Control not found returning E_INVALID_KEY");
647 return E_INVALID_KEY;
649 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
650 __pGoForwardBtn->AddActionEventListener(*this);
651 __pGoForwardBtn->SetEnabled(false);
653 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
654 if (__pRefreshBtn == NULL)
656 AppLogDebug("Control not found returning E_INVALID_KEY");
657 return E_INVALID_KEY;
660 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
661 __pRefreshBtn->AddActionEventListener(*this);
662 __pRefreshBtn->SetShowState(true);
664 //Add the backround label for displaying progressbar
665 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
666 if (__pProgressbarLabel == NULL)
668 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
669 return E_INVALID_KEY;
671 __pProgressbarLabel->SetShowState(false);
673 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
674 if (__pStopBtn == NULL)
676 AppLogDebug("Control not found returning E_INVALID_KEY");
677 return E_INVALID_KEY;
679 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
680 __pStopBtn->AddActionEventListener(*this);
681 __pStopBtn->SetShowState(false);
683 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
684 if (__pClearBtn == NULL)
686 AppLogDebug("Control not found returning E_INVALID_KEY");
687 return E_INVALID_KEY;
689 __pClearBtn->SetActionId(IDA_CLEAR_URL);
690 __pClearBtn->AddActionEventListener(*this);
691 __pClearBtn->SetShowState(false);
693 // __pFooterPanel->Invalidate(true);
694 AppLogDebug("MainForm::InitFooter exit");
700 MainForm::InitContextMenu(Point& p)
702 result r = E_SUCCESS;
703 bool isPrivateBrowsing = false;
704 Bitmap* pBitmap = null;
708 __pMenu->SetAnchorPosition(p);
709 __pMenu->Invalidate(true);
713 __pMenu = new(std::nothrow) ContextMenu();
714 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);
715 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
717 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
720 if (isPrivateBrowsing == true)
722 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
726 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
729 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
731 if ( pBitmap != NULL)
733 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
736 r = __pMenu->AddItem(L"History"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_HISTORY_CLICKED);
737 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
738 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
741 __pMenu->SetMaxVisibleItemsCount(6);
742 __pMenu->SetShowState(false);
743 __pMenu->AddActionEventListener(*this);
744 SetControlAlwaysOnTop(*__pMenu, true);
750 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
752 result r = E_SUCCESS;
753 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
755 AppLog("MainForm::InitImageContextMenu clicked on image");
756 if (__pImageMenu != null)
762 p.y = p.y + __pAddressbar->GetHeight() + 12;
765 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
769 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
771 __pImageMenu = new (std::nothrow) ContextMenu();
772 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
773 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
775 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
776 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
777 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
778 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
779 __pImageMenu->SetMaxVisibleItemsCount(4);
780 __pImageMenu->AddActionEventListener(*this);
781 SetControlAlwaysOnTop(*__pImageMenu, true);
786 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
788 result r = E_SUCCESS;
789 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
791 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
792 if (__pImageMenu != null)
797 p.y = p.y + __pAddressbar->GetHeight() + 12;
800 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
804 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
806 __pImageMenu = new (std::nothrow) ContextMenu();
807 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
808 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
810 if(onlyPasteOption == false)
812 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
814 if (pasteOption || onlyPasteOption)
816 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
818 if(onlyPasteOption == false)
820 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
821 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
824 __pImageMenu->SetMaxVisibleItemsCount(3);
825 __pImageMenu->AddActionEventListener(*this);
826 SetControlAlwaysOnTop(*__pImageMenu, true);
833 MainForm::InitFindWordPanel(void)
835 result r = E_SUCCESS;
836 Bitmap *pIconBitmap = null;
838 if (__pFindWordPanel != null)
840 AppLogDebug("Findword panel already initialized");
841 if (__pFindWordBgLabel != null)
843 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
846 AppLogDebug("InitFindWordPanel: Coming here");
847 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
854 __pFindWordPanel = static_cast<Panel*>(GetControl(L"IDC_FIND_ON_PAGE_PANEL"));
855 if (__pFindWordPanel == null)
857 AppLogException("There is some problem in the xml file. Please check.");
861 __pFindWordControl = new (std::nothrow) Panel();
862 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
865 AppLogException("There is some problem in the xml file. Please check.");
868 __pFindWordPanel->AddControl(*__pFindWordControl);
869 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
870 SetControlAlwaysOnTop(*__pFindWordPanel,true);
871 __pFindWordPanel->SetShowState(false);
872 __pFindWordPanel->Invalidate(false);
874 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
875 if (__pFindWordBgLabel != null)
877 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
878 Rectangle pRect = pPanel1->GetBounds();
879 pRect.x = pRect.y = 0;
880 __pFindWordBgLabel->SetBounds(pRect);
881 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
884 AppLogDebug("InitFindWordPanel: Coming here");
885 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
890 AppLogDebug("InitFindWordPanel: shouldn't Come here");
894 Button* pfindWordCancel = null;
895 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
896 if (pfindWordCancel == null)
898 AppLogException("There is some problem in the xml file. Please check.");
901 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
902 pfindWordCancel->AddActionEventListener(*this);
904 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
905 if (__pFindWordClear == null)
907 AppLogException("There is some problem in the xml file. Please check.");
911 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
912 __pFindWordClear->AddActionEventListener(*this);
914 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
915 if (__pFindWordNext == null)
917 AppLogException("There is some problem in the xml file. Please check.");
921 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
922 __pFindWordNext->AddActionEventListener(*this);
924 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
925 if (__pFindWordPrev == null)
927 AppLogException("There is some problem in the xml file. Please check.");
931 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
932 __pFindWordPrev->AddActionEventListener(*this);
934 __pFindWordNext->SetEnabled(false);
935 __pFindWordPrev->SetEnabled(false);
937 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
938 if (__pFindWordCountLabel == null)
940 AppLogException("There is some problem in the xml file. Please check.");
944 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
945 if (__pFindWordEditField == null)
947 AppLogException("There is some problem in the xml file. Please check.");
950 __pFindWordEditField->AddTextEventListener(*this);
951 __pFindWordEditField->AddKeypadEventListener(*this);
952 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
958 MainForm::CreateItem (int index, int itemWidth)
960 Rectangle listImageRect;
961 Rectangle pagetTitleRect;
962 Rectangle pageURLRect;
963 Rectangle deleteImageRect;
964 String pageTitle(L"");
966 result r = E_SUCCESS;
967 Bitmap* pListIconImage = null;
970 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
975 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
976 if ( pAppResource == NULL )
980 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
982 CustomItem* pItem = new(std::nothrow) CustomItem();
983 pageTitle = pHistory->GetHistoryTitle();
984 pageURL = pHistory->GetHistoryUrl();
986 if (pageURL.GetLength() == 0)
989 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
990 pageURL = L"<"+ nourl +">";
994 Rectangle screenBounds = GetBounds();
997 r = pItem->Construct(Dimension(itemWidth, 128), style);
1006 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1008 if ( pBitmap != NULL)
1010 pListIconImage = new Bitmap();
1011 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1015 if(pListIconImage == null)
1017 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1020 if ( pListIconImage != NULL)
1022 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1023 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1024 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1027 if (pItem != null && pListIconImage != NULL)
1029 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1033 if (pageTitle.CompareTo(L"") != 0)
1037 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1041 if (pageURL.CompareTo(L"") != 0)
1045 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1050 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1052 if ( __pItemContext!= NULL)
1056 pItem->SetContextItem(__pItemContext);
1062 if ( __pItemContextLandscape!= NULL)
1066 pItem->SetContextItem(__pItemContextLandscape);
1070 if( pListIconImage != NULL)
1072 delete pListIconImage;
1073 pListIconImage = null;
1080 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1087 MainForm::GetItemCount (void)
1089 if(__pMostVisitedSites != null)
1091 __pMostVisitedSites->RemoveAll(true);
1093 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1094 if(__pMostVisitedSites != null)
1096 return __pMostVisitedSites->GetCount();
1103 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1105 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1106 String url = pHistory->GetHistoryUrl();
1107 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1108 __pMostVisitedListView->UpdateList();
1112 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1114 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1115 String url = pHistory->GetHistoryUrl();
1123 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1129 MainForm::OnTerminating(void)
1131 result r = E_SUCCESS;
1134 delete __pItemContext;
1136 if(__pItemContextLandscape)
1138 delete __pItemContextLandscape;
1144 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1146 result r = E_SUCCESS;
1148 AppLogDebug("Clicked : %d", actionId);
1151 case IDA_BACKBTN_CLICKED:
1153 if (__pWebViewer && __pWebViewer->CanGoBack())
1155 __pWebViewer->GoBack();
1160 pApp = UiApp::GetInstance();
1163 r = pApp->Terminate();
1166 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1174 case IDA_FORWARD_CLICKED:
1175 if (__pWebViewer == null)
1178 if (__pWebViewer->CanGoForward())
1180 __pWebViewer->GoForward();
1182 __pMenu->SetShowState(false);
1183 __pMenu->Invalidate(false);
1186 case IDA_FINDONPAGE_CLICKED:
1188 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1189 __currentSearchStr.Clear();
1191 InitFindWordPanel();
1192 __pMenu->SetShowState(false);
1193 __pMenu->Invalidate(false);
1195 __pFindWordEditField->SetFocus();
1196 ShowFindWordPanel(true);
1199 case IDA_PRIVATEON_CLICKED:
1201 result r = E_SUCCESS;
1203 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1204 Bitmap* pBitmap = null;
1205 if (isPrivateBrowsing == true)
1207 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1210 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1214 if (__pWebViewer != NULL)
1216 __pWebViewer->SetPrivateBrowsingEnabled(false);
1219 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1221 if (__pAddressbar != null)
1223 __pAddressbar->UpdateFaviconBitmap(false);
1229 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1232 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1236 if (__pWebViewer != NULL)
1238 __pWebViewer->SetPrivateBrowsingEnabled(true);
1241 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1243 if (__pAddressbar != null)
1245 __pAddressbar->UpdateFaviconBitmap(true);
1250 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1251 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1252 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1253 __pMenu->Invalidate(true);
1255 if ( pBitmap != NULL )
1262 case IDA_SETTINGS_CLICKED:
1265 ArrayList* pArgList = new(std::nothrow) ArrayList();
1268 pArgList->Construct();
1269 pArgList->Add(*__pWindowInfo);
1270 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1272 __pMenu->SetShowState(false);
1273 __pMenu->Invalidate(false);
1274 if (pArgList != null)
1283 case IDA_ADDTOBOOKMARK_CLICKED:
1286 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1288 int bookmarkCount=0;
1291 url=__pWindowInfo->pageUrl;
1292 result r = E_SUCCESS;
1293 Bitmap* pBitmap = null;
1294 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1302 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1303 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1304 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1306 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1307 if (pNotification != null)
1309 pNotification->SetText(message);
1310 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1311 pNotification->ShowNotification();
1316 String title=__pWindowInfo->pageTitle;
1317 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1318 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1320 pBookmark->SetBookmarkTitle(title);
1321 pBookmark->SetUrl(url);
1322 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1324 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1326 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1327 pBookmark->SetFaviconId(id);
1328 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1329 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1332 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1333 if (pNotification != null)
1335 pNotification->SetText(message);
1336 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1337 pNotification->ShowNotification();
1338 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1341 if (pBitmap != null)
1343 r = __pMenu->SetItemAt(0,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1347 __pMenu->Invalidate(true);
1351 case IDA_SHARE_CLICKED:
1353 if(__pPopUp != null)
1358 __pPopUp = new(std::nothrow) SharePopup();
1359 __pPopUp->Initialize();
1360 if (__pWindowInfo != null)
1362 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1363 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1364 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1365 pShareInfo->SetImageAttached(false);
1366 __pPopUp->RemoveAllShareInfo();
1367 __pPopUp->AddShareInfo(pShareInfo);
1369 __pPopUp->SetShowState(true);
1373 case IDA_BOOKMARKBTN_CLICKED:
1375 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1376 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1379 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1384 case IDA_MOREBTN_CLICKED:
1386 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1387 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1388 AppLog("Anchot pos: %d %d", p.x, p.y);
1390 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1392 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1393 int bookmarkCount=0;
1396 url=__pWindowInfo->pageUrl;
1397 result r = E_SUCCESS;
1398 Bitmap* pBitmap = null;
1400 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1403 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1408 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1412 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1414 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1416 if (__pMenu->GetItemCount() == 9)
1418 r = __pMenu->SetItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1422 r = __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1427 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1431 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1432 if (__pMenu->GetItemCount() != 9)
1434 __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADDTOBOOKMARK_CLICKED);
1436 __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1437 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1438 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1439 __pMenu->SetMaxVisibleItemsCount(6);
1441 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1443 AppLog(" Orientation landscape");
1444 __pMenu->SetMaxVisibleItemsCount(5);
1448 AppLog(" Orientation potrait");
1449 __pMenu->SetMaxVisibleItemsCount(6);
1452 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1455 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1456 __pMenu->SetShowState(true);
1457 __pMenu->Invalidate(true);
1461 case IDA_HISTORY_CLICKED:
1463 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1464 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1467 case IDA_SAVED_PAGES_CLICKED:
1472 case IDA_DESKTOP_VIEW_CLICKED:
1477 case IDA_SAVE_CLICKED:
1482 case IDA_MULTIWINDOWBTN_CLICKED:
1484 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1485 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1489 case IDA_NEWWINDOWBTN_CLICKED:
1491 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1493 if (pNewWindowInfo == null)
1497 result r = E_SUCCESS;
1498 SceneManager* pSceneManager = SceneManager::GetInstance();
1500 if (pSceneManager == NULL)
1504 ArrayList* pArgList = new(std::nothrow) ArrayList();
1505 if (pArgList == NULL)
1509 r = pArgList->Construct();
1512 pArgList->Add(*pNewWindowInfo);
1513 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1519 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1524 case IDA_SMALLFONT_BTN_CLICKED:
1526 WebSetting setting = __pWebReader->GetSetting();
1527 setting.SetFontSize(15);
1528 __pWebReader->SetSetting(setting);
1531 case IDA_LARGEFONT_BTN_CLICKED:
1533 WebSetting setting = __pWebReader->GetSetting();
1534 setting.SetFontSize(25);
1535 __pWebReader->SetSetting(setting);
1538 case IDA_READER_CLOSE_CLICKED:
1540 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1542 //__pArticleReaderPanel->SetShowState(false);
1543 //__pArticleReaderPanel->Show();
1544 RemoveControl(*__pBlankPanel);
1545 //RemoveControl(*__pArticleReaderPanel);
1546 __pArticleReaderPanel = null;
1547 __pBlankPanel = null;
1548 __pArticleReaderLabel = null;
1550 //if (__pAddressbar)
1551 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1552 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1555 case IDA_FINDWORD_CANCEL_CLICKED:
1557 __currentSearchStr = L"";
1558 __currentWordIndex = 0;
1559 __maxOccurrances = 0;
1560 __pFindWordEditField->SetText(L"");
1561 __pFindWordNext->SetEnabled(false);
1562 __pFindWordPrev->SetEnabled(false);
1563 __pFindWordCountLabel->SetText(L"0/0");
1564 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1565 ShowFindWordPanel(false);
1568 case IDA_FINDWORD_SEARCH_CLICKED:
1570 __currentSearchStr = __pFindWordEditField->GetText();
1571 if (__currentSearchStr.GetLength() > 0)
1577 AppLogDebug("Enter something");
1581 case IDA_FINDWORD_CLEAR_CLICKED:
1583 __pFindWordCountLabel->SetText(L"0/0");
1584 __pFindWordEditField->SetText(L"");
1585 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1587 __currentSearchStr = L"";
1588 __pFindWordNext->SetEnabled(false);
1589 __pFindWordPrev->SetEnabled(false);
1590 __pFindWordPanel->Invalidate(true);
1593 case IDA_FINDWORD_NEXT_CLICKED:
1598 case IDA_FINDWORD_PREV_CLICKED:
1600 FindNextWord(false);
1603 case IDA_BRIGHTNESS_BTN_CLICKED:
1605 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1606 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1609 case IDA_COPY_IMAGE_CLICKED:
1611 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1612 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1614 const Bitmap* pBitmap = null;
1615 if (__pHitElementResult != null)
1617 pBitmap = __pHitElementResult->GetImage();
1620 String resourcePath = App::GetInstance()->GetAppResourcePath();
1621 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1623 // copying the item to clipboard
1624 Clipboard* pClipboard = Clipboard::GetInstance();
1625 if (pClipboard != null)
1627 pClipboard->CopyItem(item);
1631 case IDA_VIEW_IMAGE_CLICKED:
1633 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1634 WindowInfo* pNewWindowInfo = null;
1635 if (__pHitElementResult != null)
1637 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1638 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1644 case IDA_SAVE_IMAGE_CLICKED:
1646 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1647 const Bitmap* pSaveBitmap = null;
1648 String imageName = GetImagePath();
1649 AppLog("Content manager image name %ls",imageName.GetPointer());
1652 imagePath.Append(imageName);
1653 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1654 AppLog("Content manager image path %ls",imagePath.GetPointer());
1655 if (__pHitElementResult != null)
1657 pSaveBitmap = __pHitElementResult->GetImage();
1659 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1663 UpdateImageContent(pBuffer, imageName);
1665 NotificationPanel *pNotification = new NotificationPanel(*this);
1667 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1668 msg.Append(imagePath);
1669 if (pNotification != null)
1671 pNotification->SetText(msg);
1672 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1673 pNotification->ShowNotification();
1678 int __modalMsgBoxResult;
1679 MessageBox* pMsgBox = new MessageBox();
1680 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1681 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1684 __modalMsgBoxResult = 0;
1688 case IDA_SHARE_IMAGE_CLICKED:
1690 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1691 if (__pPopUp != null)
1696 __pPopUp = new(std::nothrow) SharePopup();
1697 __pPopUp->Initialize();
1698 if (__pHitElementResult != null)
1700 const Bitmap* pSaveBitmap = null;
1701 String imageName = GetImagePath();
1702 AppLog("Content manager image name %ls",imageName.GetPointer());
1705 imagePath.Append(imageName);
1706 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1707 AppLog("Content manager image path %ls",imagePath.GetPointer());
1708 if (__pHitElementResult != null)
1710 pSaveBitmap = __pHitElementResult->GetImage();
1712 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1714 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1715 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1717 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1718 pShareInfo->SetPageTitle(L"");
1719 pShareInfo->SetPageUrl(srcUrl);
1720 pShareInfo->SetImageAttached(true);
1721 pShareInfo->SetImagePath(imagePath);
1722 __pPopUp->RemoveAllShareInfo();
1723 __pPopUp->AddShareInfo(pShareInfo);
1724 __pPopUp->SetShowState(true);
1729 case IDA_FIND_TEXT__CLICKED:
1731 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1732 __currentSearchStr.Clear();
1733 __currentSearchStr.Append(__currentSelectedStr);
1734 InitFindWordPanel();
1737 __pMenu->SetShowState(false);
1738 __pMenu->Invalidate(false);
1741 __adressPanelPosition.y = 0;
1743 if (__pAddressbar != null && __pWebViewer != NULL)
1745 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1746 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1747 //__pAddressbar->Invalidate(true);
1748 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
1750 if (__pFooterPanel->GetShowState() == false)
1751 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
1753 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
1754 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1755 __pWebViewer->Invalidate(true);
1758 ShowFindWordPanel(true);
1759 if (__currentSearchStr.GetLength() > 0)
1765 AppLogDebug("Enter something");
1769 case IDA_SHARE_TEXT_CLICKED:
1771 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
1772 if(__pPopUp != null)
1777 __pPopUp = new(std::nothrow) SharePopup();
1778 __pPopUp->Initialize();
1779 if (__pHitElementResult != null)
1781 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1782 pShareInfo->SetPageTitle(L"");
1783 pShareInfo->SetPageUrl(__currentSelectedStr);
1784 pShareInfo->SetImageAttached(false);
1785 __pPopUp->RemoveAllShareInfo();
1786 __pPopUp->AddShareInfo(pShareInfo);
1787 __pPopUp->SetShowState(true);
1792 case IDA_COPY_TEXT_CLICKED:
1794 // need to implement
1795 //__currentSelectedStr
1796 // Sets data to a clip board item
1798 String resourcePath = App::GetInstance()->GetAppResourcePath();
1799 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
1801 // copying the item to clipboard
1802 Clipboard* pClipboard = Clipboard::GetInstance();
1803 if (pClipboard != null)
1805 pClipboard->CopyItem(item);
1809 case IDA_PASTE_TEXT_CLICKED:
1811 Clipboard* pClipboard = Clipboard::GetInstance();
1813 if(pClipboard == null)
1817 // Retrieves a latest item
1818 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1824 //Gets data from the clipboard item
1825 String* pString = dynamic_cast<String*>(pItem->GetData());
1827 if (pString != null)
1829 String idElement = __pHitElementResult->GetAttributeValue(L"id");
1830 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
1831 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
1832 String script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } ";
1833 if(idElement.GetLength() != 0)
1835 script.Append("insertAtCursor(");
1836 script.Append(idElement);
1838 script.Append("\"");
1839 script.Append(*pString);
1840 script.Append("\");");
1842 else if (nameElement.GetLength() != 0)
1844 script.Append("insertAtCursor(document.getElementsByName('");
1845 script.Append(nameElement);
1846 script.Append("')[0],");
1847 script.Append("\"");
1848 script.Append(*pString);
1849 script.Append("\");");
1851 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
1852 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
1863 case IDA_GO_FORWARD:
1868 case IDA_REFRESH_BTN_CLICKED:
1870 __isLoadingCompleted = false;
1871 __isLoadingData = true;
1872 __progressPercentage = 0;
1873 __displayUrl = __pFooterUrlField->GetText();
1875 String url = __pFooterUrlField->GetText();
1876 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
1880 UpdateProgressBitmap();
1883 case IDA_STOP_BTN_CLICKED:
1885 __isLoadingCompleted = false;
1886 __isLoadingData = false;
1887 __progressPercentage = 0;
1888 __pFooterUrlField->HideKeypad();
1889 __displayUrl = __pFooterUrlField->GetText();
1893 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1894 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1895 __pWebViewer->StopLoading();
1896 RequestRedraw(true);
1899 UpdateProgressBitmap();
1904 if (__pFooterUrlField->GetText().IsEmpty() == false)
1906 //__displayUrl = __pUrlField->GetText();
1907 __pFooterUrlField->Clear();
1917 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1920 UiApp* pApp = UiApp::GetInstance();
1929 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1930 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
1932 String* pSelectedScene = NULL;
1933 Object* pValue = NULL;
1934 String* pUrl = null;
1935 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
1936 pSelectedScene = (String*) pValue;
1938 if (pSelectedScene != null)
1940 delete pSelectedScene;
1942 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
1943 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
1944 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
1945 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
1947 // setting the current scene ID
1948 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
1950 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
1952 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
1954 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1955 if(__pWindowInfo == null)
1957 // if(__pWindowInfo == null)
1959 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
1962 else if ( pArgs != null && pArgs->GetCount() == 1)
1964 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1970 // hiding the address bar
1971 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
1972 __pAddressbar->SetShowState(false);
1973 if(__pWebViewer != null)
1975 __pWebViewer->Resume();
1978 if(pUrl != null && pUrl->GetLength() > 0)
1982 else if(__pWindowInfo != null)
1984 if(__pWindowInfo->pageUrl.GetLength() > 0 && previousSceneId != IDSCN_MULTIPLE_WINDOW && previousSceneId != IDSCN_MULTIPLE_WINDOW_GRID && previousSceneId != IDSCN_BOOKMARK_VIEW && previousSceneId != IDSCN_SETTINGS && previousSceneId != IDSCN_MAIN_VIEW)
1986 LoadUrl(__pWindowInfo->pageUrl);
1988 else if (__pWindowInfo->isJavascriptInitiated == true)
1992 __pWindowInfo->pCurrentWeb = __pWebViewer;
1996 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
1997 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
1998 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2000 InitMostVisitedSitesView(GetOrientationStatus());
2003 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2005 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2007 if (pBookmarkUrl == null)
2009 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2010 //__pAddressbar->SetUrl(*pBookmarkUrl);
2011 SetUrl(*pBookmarkUrl);
2013 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2014 __pWebViewer->LoadUrl(*pBookmarkUrl);
2015 delete pBookmarkUrl;
2018 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2019 Bitmap* pBitmap = null;
2020 if (isPrivateBrowsing == true)
2022 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2024 if (__pWebViewer != null)
2026 __pWebViewer->SetPrivateBrowsingEnabled(true);
2029 if (__pAddressbar != null)
2031 // __pAddressbar->UpdateFaviconBitmap(true);
2037 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2039 if (__pWebViewer != null)
2041 __pWebViewer->SetPrivateBrowsingEnabled(false);
2044 if (__pAddressbar != null)
2046 // __pAddressbar->UpdateFaviconBitmap(false);
2050 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2052 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2054 else if (__pMenu != null )
2056 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2059 if (pBitmap != null)
2064 AppLog("ABC: OnSceneActivatedN started exit");
2069 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2070 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2072 Canvas* pWebCanvas = null;
2073 if (__pWebViewer != null)
2075 pWebCanvas = __pWebViewer->GetCanvasN();
2076 __pWebViewer->Pause();
2079 if (pWebCanvas == null)
2083 if (__pWindowInfo != null)
2085 if (__pWindowInfo->pWebCanvasBitmap != null)
2087 delete __pWindowInfo->pWebCanvasBitmap;
2089 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2090 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2091 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2093 Bitmap* pBitmap = GetCapturedBitmapN();
2094 AppLog("Coming here");
2095 Canvas* pCanvas = new(std::nothrow) Canvas();
2096 pCanvas->Construct(GetClientAreaBounds());
2099 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2102 if(__pWebViewer != null && __pWindowInfo != null)
2103 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2105 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2106 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2108 AppLog("Coming here");
2112 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2113 const Tizen::Base::String& realm,
2114 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2120 MainForm::OnHttpAuthenticationCanceled(void)
2125 MainForm::OnLoadingStarted(void)
2127 AppLogDebug("MainForm::OnLoadingStarted entered");
2129 if(__pAddressbar == NULL)
2133 String url = __pWebViewer->GetUrl();
2134 if(url.Contains(IDS_TIZEN_SERVICE))
2137 String delim(L":;");
2139 // Creates a StringTokenizer instance
2140 StringTokenizer strTok(url, delim);
2142 int count = strTok.GetTokenCount(); // count == 4
2144 HashMap *pMap = new HashMap();
2149 while (strTok.HasMoreTokens())
2151 AppLog("Token: %ls", token.GetPointer());
2152 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2153 if(token.Contains(IDS_APPID))
2155 token.SubString(6, appId);
2156 AppLog("AppID:%ls", appId.GetPointer());
2158 else if(token.Contains("="))
2160 String *pKey = new String();
2161 String *pValue = new String();
2163 token.IndexOf("=", 0, index);
2166 token.SubString(0, index, *pKey);
2167 token.SubString(index + 1, *pValue);
2168 pMap->Add(pKey, pValue);
2174 AppControl *pAppControl = null;
2175 String operationId = L"http://tizen.org/appcontrol/operation/main";
2176 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2179 AppLog("Starting AppControl");
2180 result r = pAppControl->Start(null, null, pMap, null);
2181 AppLog("Result of Start %s", GetErrorMessage(r));
2185 AppLogException("AppControl not found");
2190 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2193 __pAddressbar->SetFaviconBitmap(*pBitmap);
2196 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2198 // updating the address bar position with respect to web control
2199 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2200 __distanceMoved = 0;
2204 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2205 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2208 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2209 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2210 SetUrl(__pWebViewer->GetUrl());
2211 if (__pWindowInfo != NULL)
2213 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2215 __pAddressbar->Invalidate(true);
2221 MainForm::OnLoadingCanceled(void)
2228 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2230 AppLog("MainForm::OnKeypadWillOpen");
2231 if (__pAddressbar != null)
2233 OnAddressBarKeypadWillOpen(*__pAddressbar);
2239 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2241 if(__pAddressbar != null)
2243 OnAddressBarKeypadOpened(*__pAddressbar);
2249 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2251 if (__pAddressbar != null)
2253 OnAddressBarKeypadClosed(*__pAddressbar);
2258 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2260 AppLog("KeypadBoundsChanged");
2261 RelayoutControls(false);
2265 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2266 const Tizen::Base::String& reason)
2268 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2272 MainForm::OnLoadingCompleted(void)
2274 AppLog("MainForm::OnLoadingCompleted start");
2276 result r = E_SUCCESS;
2278 if (__pWebViewer == null)
2283 if (__pAddressbar == null)
2287 if (__pWebViewer->CanGoForward())
2289 //__pAddressbar->SetForwardButtonEnabled(true);
2290 SetForwardButtonEnabled(true);
2294 //__pAddressbar->SetForwardButtonEnabled(false);
2295 SetForwardButtonEnabled(false);
2298 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2300 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2302 //__pAddressbar->UpdateProgress(0);
2306 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2308 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2312 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2313 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2314 if (isPrivateBrowsing == false)
2316 History* pHistory = new(std::nothrow) History;
2318 HistoryPresentationModel::GetCurrentDateTime(date);
2321 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2322 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2324 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2325 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2327 pHistory->SetVisitedTime(date);
2330 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2331 pHistory->SetFaviconId(id);*/
2333 if (__pWebViewer != null)
2335 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2337 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2338 if (pTempBitmap != null)
2340 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2341 pHistory->SetFavIconBitmap(*pTempBitmap);
2344 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2347 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2348 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2349 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2351 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2352 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2353 pHistory->SetThumbnail(pBitmap);
2355 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2358 pHistory->SetFavIconBitmap(*pFavIcon);
2362 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2369 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2371 // temperary fixed (webpage can be not loaded)
2374 AppLog("MainForm::OnLoadingCompleted done");
2378 MainForm::OnEstimatedProgress(int progress)
2380 AppLogDebug("MainForm::OnEstimatedProgress entered");
2381 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2382 progress = DEFAULT_PROGRESS_PERCENTAGE;
2384 // __pAddressbar->UpdateProgress(progress);
2385 UpdateProgress(progress);
2388 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2390 AppLog("MainForm::OnFaviconReceived");
2391 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2393 if (pFavIconBitmap != null)
2395 pFavIconBitmap->GetWidth();
2396 pFavIconBitmap->GetHeight();
2401 MainForm::OnUrlValueChanged(Addressbar&)
2407 MainForm::OnUrlSubmitted(Addressbar& addBar)
2409 AppLog("MainForm::OnUrlSubmitted");
2410 String url = addBar.GetUrl();
2411 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2413 __pFooterPanel->SetShowState(true);
2414 // __pAddressbar->SetShowState(false);
2415 // RelayoutControls(false);
2420 MainForm::LoadUrl(String& url)
2423 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2424 AppLogDebug("MainForm::LoadUrl enter");
2426 if (__pWebViewer != null)
2428 __pWebViewer->SetShowState(true);
2429 __pWebViewer->Invalidate(true);
2432 if (url.CompareTo(L"") == 0)
2436 if(__pFooterPanel != null)
2438 __pFooterPanel->SetShowState(true);
2439 __pFooterPanel->Invalidate(true);
2446 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2447 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)
2449 RegularExpression firstRegex;
2450 RegularExpression secondRegex;
2452 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2453 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2456 ret = firstRegex.Match(url, false); // This returns true value
2457 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2459 if (ret == true && __pWebViewer != null)
2461 __pWebViewer->LoadUrl(url);
2463 else if(__pWebViewer != null)
2465 String tempUrl = L"http://";
2466 tempUrl.Append(url);
2470 __pWebViewer->LoadUrl(tempUrl);
2474 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2475 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2478 if (__pAddressbar != null)
2480 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2481 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2484 AppLogDebug("MainForm::LoadUrl exit");
2491 MainForm::OnStopClicked(Addressbar& addBar)
2493 AppLogDebug("MainForm::OnStopClicked called");
2496 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2497 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2498 __pWebViewer->StopLoading();
2499 RequestRedraw(true);
2504 MainForm::OnReaderClicked(const Addressbar& addBar)
2506 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2508 CreateReaderPanel();
2509 AppLogDebug("MainScene::OnReaderClicked entered");
2512 /*if (__pArticleReaderPanel)
2514 AppLogDebug("showstate true for reader panel");
2515 __pArticleReaderPanel->SetShowState(true);
2516 __pArticleReaderPanel->Show();
2518 int xPos = __pArticleReaderPanel->GetX();
2519 int yPos = __pArticleReaderPanel->GetY();
2520 AppLog("OnReaderClicked() xPos = %d",xPos);
2521 AppLog("OnReaderClicked() yPos = %d",yPos);
2523 if (__pReaderData == null)
2528 String loadData = L"<html>\
2530 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2535 background-color: transparent;\
2554 <body style='width:'";
2555 loadData.Append(bodyWidth);
2556 loadData.Append(L"px'>");
2557 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2558 loadData.Append(*__pReaderData);
2559 loadData.Append(L"</body></html>");
2562 buf.Construct(loadData.GetLength());
2563 AppLogDebug("data->GetLength %d",loadData.GetLength());
2564 for (int z=0;z<loadData.GetLength();z++)
2567 loadData.GetCharAt(z,b);
2568 buf.SetByte((byte)b);
2572 if (__pWebReader != null)
2574 __pWebReader->LoadData(L"",buf,L"text/html");
2575 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2579 AppLogDebug("cannot LoadData __pWebReader is null");
2585 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2587 AppLog("MainForm::OnBackClicked");
2588 result r = E_FAILURE;
2590 if (__pWebViewer != null && __pWebViewer->CanGoBack())
2592 __pWebViewer->GoBack();
2597 pApp = UiApp::GetInstance();
2600 r = pApp->Terminate();
2610 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
2612 AppLog("MainForm::OnForwardClicked");
2613 if (__pWebViewer == null)
2616 if (__pWebViewer->CanGoForward())
2618 __pWebViewer->GoForward();
2623 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2625 result r = E_SUCCESS;
2626 // hiding the address bar
2627 __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2628 __pAddressbar->SetShowState(false);
2630 if (__pMostVisitedListView != null && __pMostVisitedListView->GetShowState() == true)
2632 AppLog("MainForm::OnAddressCancelledClicked 1");
2633 if (__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2634 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2636 if (__pMostVisitedListView != null)
2637 __pMostVisitedListView->Invalidate(true);
2640 __pFooterPanel->SetShowState(true);
2641 __pFooterPanel->Invalidate(false);
2645 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
2647 __prevAddressBarMode = __curAddressBarMode;
2649 if (__pAddressbar != null)
2651 __curAddressBarMode = GetAddressbarMode();
2654 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
2656 __adressPanelPosition.y = 0;
2657 if (__pAddressbar != null)
2659 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2660 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2661 __pAddressbar->Invalidate(true);
2663 if (__pWebViewer != null)
2665 __pWebViewer->StopLoading();
2668 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
2670 __adressPanelPosition.y = 0;
2671 if (__pAddressbar != null)
2673 __webControlPosition.y = 0;
2674 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
2675 __pAddressbar->Invalidate(true);
2681 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
2683 __pFooterPanel->SetShowState(true);
2684 RelayoutControls(false);
2688 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
2690 if (__pFindWordPanel && __pFindWordPanel->GetShowState() == true)
2692 __pAddressbar->SetShowState(false);
2696 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
2698 __pAddressbar->SetShowState(true);
2699 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2700 __pAddressbar->SetAddressbarURLFocus();
2704 RelayoutControls(false);
2708 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
2710 __pFooterPanel->SetShowState(false);
2714 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
2716 AppLog("KeypadBoundsChanged");
2717 RelayoutControls(false);
2721 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
2725 __pWindowInfo->pageTitle = title;
2726 if (__pWebViewer != null)
2728 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2731 if (__pAddressbar != null && __pWebViewer != null)
2733 SetUrl(__pWebViewer->GetUrl());
2734 __pAddressbar->Invalidate(true);
2739 MainForm::UpdateFavicon(void)
2741 bool urlImageType = false;
2742 String *tempPath = __pWebViewer->EvaluateJavascriptN(L"var getFavicon = function() { var favicon = '/favicon.ico'; var nodeList = document.getElementsByTagName('link'); if(nodeList) { for (var i = 0; i < nodeList.length; i++) { if ((nodeList[i].getAttribute('rel') == 'icon')||(nodeList[i].getAttribute('rel') == 'shortcut icon')) { favicon = nodeList[i].getAttribute('href'); } } } return favicon; }; getFavicon();");
2743 Bitmap* pBitmap = null;
2745 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
2747 if (__pWindowInfo != null)
2750 url.SetUri(*tempPath);
2751 if (url.GetHost().GetLength() == 0)
2754 webUrl.SetUri(__pWebViewer->GetUrl());
2755 result r = url.SetHost(webUrl.GetHost());
2762 if (url.GetScheme().GetLength() == 0)
2765 webUrl.SetUri(__pWebViewer->GetUrl());
2766 url.SetScheme(webUrl.GetScheme());
2768 __pWindowInfo->faviconUrl = url.ToString();
2770 pBitmap = __pWebViewer->GetFaviconN();
2772 if (pBitmap != null)
2774 if (__pWindowInfo->pFavicon != NULL)
2776 __pWindowInfo->pFavicon = null;
2778 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
2779 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
2781 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2783 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2785 else if(__pWindowInfo->pFavicon != null)
2787 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2791 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
2792 if(pDefaultBmp != null)
2794 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
2803 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
2810 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
2811 Tizen::Web::Controls::WebNavigationType type)
2813 // when load new page if find word panel is open its show state is false
2814 ShowFindWordPanel(false);
2815 AppLog("__pAddressbar->GetAddressbarURL() is %ls",__pAddressbar->GetAddressbarURL().GetPointer());
2817 __pFooterPanel->Invalidate(true);
2820 uriInfo.SetUri(url);
2822 if(url.Contains(IDS_TIZEN_SERVICE))
2825 String delim(L":;");
2827 // Creates a StringTokenizer instance
2828 StringTokenizer strTok(url, delim);
2830 int count = strTok.GetTokenCount(); // count == 4
2832 HashMap *pMap = new HashMap();
2838 while (strTok.HasMoreTokens())
2840 AppLog("Token: %ls", token.GetPointer());
2841 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2842 if(token.Contains(IDS_APPID))
2844 token.SubString(6, appId);
2845 AppLog("AppID:%ls", appId.GetPointer());
2847 else if(token.Contains("="))
2849 String *pKey = new String();
2850 String *pValue = new String();
2852 token.IndexOf("=", 0, index);
2855 token.SubString(0, index, *pKey);
2856 token.SubString(index + 1, *pValue);
2857 pMap->Add(pKey, pValue);
2863 AppControl *pAppControl = null;
2864 String operationId = L"http://tizen.org/appcontrol/operation/main";
2865 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2868 result r = pAppControl->Start(null, null, pMap, null);
2872 AppLogException("AppControl not found");
2878 if (__pWebViewer && __pAddressbar)
2880 __pAddressbar->SetShowState(false);
2881 /*AppLog("__pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2882 __pAddressbar->SetUrl(__pWebViewer->GetUrl());
2883 __pAddressbar->UpdateProgress(DEFAULT_PROGRESS_PERCENTAGE);
2887 __pWindowInfo->pageTitle = CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK");
2888 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2889 __pWindowInfo->faviconUrl = "";
2890 __pWindowInfo->faviconFilePath = "";
2892 if (__pWindowInfo->pFavicon != NULL)
2894 // delete __pWindowInfo->pFavicon;
2895 __pWindowInfo->pFavicon = null ;
2897 __pWindowInfo->pFavicon = FaviconManager::GetInstance()->GetDefaultFaviconN();
2901 __pAddressbar->Invalidate(true);
2907 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
2908 const Tizen::Net::Http::HttpHeader& httpHeader)
2910 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
2915 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
2917 AppLog("MainForm::OnWebPageBlockSelected");
2918 if (__pHitElementResult != null)
2920 delete __pHitElementResult;
2921 __pHitElementResult = null;
2924 if (__pWebViewer != null)
2926 AppLog("MainForm::OnWebPageBlockSelected web not null");
2927 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
2930 if (__pHitElementResult == null)
2935 if (__pHitElementResult->HasImage() != true)
2937 String tagName = __pHitElementResult->GetTagName();
2938 String type = __pHitElementResult->GetAttributeValue("type");
2940 __currentSelectedStr.Clear();
2941 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
2942 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
2943 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
2945 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
2947 AppLog("MainForm::OnWebPageBlockSelected show paste option");
2949 InitSelectTextContextMenu(endPoint,true);
2950 __pImageMenu->SetShowState(true);
2951 __pImageMenu->Show();
2952 __pImageMenu->Invalidate(true);
2954 else if(__isLongPressedDone == true)
2956 AppLog("MainForm::OnWebPageBlockSelected no paste option");
2958 if(__pHitElementResult->GetUrl().GetLength() > 0)
2960 __currentSelectedStr.Clear();
2961 __currentSelectedStr = __pHitElementResult->GetUrl();
2963 InitSelectTextContextMenu(endPoint,false);
2964 __pImageMenu->SetShowState(true);
2965 __pImageMenu->Show();
2966 __pImageMenu->Invalidate(true);
2969 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
2970 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
2971 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
2977 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
2983 MainForm::OnWebWindowCreateRequested(void)
2985 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
2987 if (pNewWindowInfo == null)
2991 result r = E_SUCCESS;
2992 SceneManager* pSceneManager = SceneManager::GetInstance();
2993 if (pSceneManager == NULL)
2997 ArrayList* pArgList = new(std::nothrow) ArrayList();
2998 if (pArgList == NULL)
3002 r = pArgList->Construct();
3005 pNewWindowInfo->isJavascriptInitiated = true;
3006 pArgList->Add(*pNewWindowInfo);
3007 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3011 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3018 return pNewWindowInfo->pCurrentWeb;
3022 MainForm::RelayoutControls(bool showAddressbar)
3024 __webControlPosition.y = 0;
3025 __webControlHeight = GetClientAreaBounds().height;
3027 AppLog("Client area height: %d", __webControlHeight);
3028 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3030 __webControlPosition.y += __pAddressbar->GetHeight();
3031 __webControlHeight -= __pAddressbar->GetHeight();
3033 else if(__pFindWordPanel != null && __pFindWordPanel->GetShowState() == true)
3035 __webControlPosition.y += __pFindWordPanel->GetHeight();
3036 __webControlHeight -= __pFindWordPanel->GetHeight();
3039 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
3041 __webControlHeight -= __pFooterPanel->GetHeight();
3043 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3045 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3046 __pWebViewer->Invalidate(false);
3048 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3049 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3054 void MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3056 if (__pFindWordPanel == null)
3062 InitFindWordPanel();
3063 __pFindWordEditField->SetText(__currentSearchStr);
3064 //__pFindWordCountLabel->SetText(L"");
3065 __pFindWordCountLabel->SetText(L"0/0");
3066 __pFindWordPanel->SetShowState(true);
3070 if(__pFindWordPanel != null)
3072 __pFindWordPanel->SetShowState(false);
3076 AppLog("MainForm::ShowFindWordPanel %d",show);
3077 if (show && !isTouchPressed)
3079 if (__pFindWordEditField)
3081 __pFindWordEditField->SetFocus();
3082 __pFindWordEditField->ShowKeypad();
3087 if (__pFindWordEditField)
3088 __pFindWordEditField->HideKeypad();
3091 RelayoutControls(false);
3095 MainForm::StartWordSearch()
3097 //Get the count of occurances of the word in the current page
3098 __maxOccurrances = 0;
3099 __currentWordIndex = 0;
3101 __pFindWordPrev->SetEnabled(false);
3102 String *pCountStr = null;
3103 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3104 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3105 if (pCountStr != null)
3107 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3111 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3116 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3118 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3119 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3121 if(totalCount == -1 || totalCount == 0)
3123 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),64,__pFindWordCountLabel->GetHeight());
3124 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3127 else if(totalCount > 100)
3129 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3130 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3133 __maxOccurrances = totalCount;
3134 __currentWordIndex = currentOrdinal;
3136 //Reset the UI controls as per the maxOccurrance value
3137 if (totalCount <= 0)
3139 AppLog("Word not found");
3140 //Show error notification to user
3141 __pFindWordNext->SetEnabled(false);
3142 __pFindWordCountLabel->SetText(L"0/0");
3143 __pFindWordNext->Invalidate(false);
3144 __pFindWordPrev->Invalidate(false);
3145 __pFindWordCountLabel->Invalidate(false);
3149 if (totalCount == 1)
3151 __pFindWordNext->SetEnabled(false);
3155 __pFindWordNext->SetEnabled(true);
3158 String countStr = L"";
3159 countStr.Append(__currentWordIndex);
3160 countStr.Append(L"/");
3161 countStr.Append(__maxOccurrances);
3162 __pFindWordCountLabel->SetText(countStr);
3163 // __pFindWordCountLabel->SetShowState(true);
3164 __pFindWordCountLabel->Invalidate(false);
3166 //FindNextWord(true);
3167 //Update the controls
3168 __pFindWordNext->Invalidate(false);
3169 __pFindWordPrev->Invalidate(false);
3170 __pFindWordCountLabel->Invalidate(false);
3174 MainForm::FindNextWord(bool next)
3178 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3180 if(__currentWordIndex < __maxOccurrances)
3182 __currentWordIndex++;
3188 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3190 if(__currentWordIndex > 1)
3192 __currentWordIndex--;
3197 String countStr = L"";
3198 countStr.Append(__currentWordIndex);
3199 countStr.Append(L"/");
3200 countStr.Append(__maxOccurrances);
3201 __pFindWordCountLabel->SetText(countStr);
3202 // __pFindWordCountLabel->SetShowState(true);
3203 __pFindWordCountLabel->Invalidate(false);
3204 if (__currentWordIndex >= __maxOccurrances)
3206 __pFindWordNext->SetEnabled(false);
3210 __pFindWordNext->SetEnabled(true);
3212 if (__currentWordIndex <= 1)
3214 __pFindWordPrev->SetEnabled(false);
3218 __pFindWordPrev->SetEnabled(true);
3220 __pFindWordPrev->Invalidate(false);
3221 __pFindWordNext->Invalidate(false);
3222 __pFindWordCountLabel->Invalidate(false);
3223 __pFindWordPanel->Invalidate(true);
3226 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3228 AppLog("MainForm::OnWebKeypadWillOpen");
3229 // OnAddressBarKeypadOpened(*__pAddressbar);
3233 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3236 if (__pWebViewer != null && __pFooterPanel != null)
3238 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3240 // __pFooterPanel->SetShowState(false);
3241 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
3244 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
3249 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3251 OnAddressBarKeypadClosed(*__pAddressbar);
3255 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3257 Control* temp = const_cast< Control* >(&source);
3258 Header* pHeader = dynamic_cast< Header* >(temp);
3259 if (pHeader != null)
3261 //Header double - clicked
3262 AppLog("Header double clicked");
3264 if(__pFindWordPanel)
3266 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3267 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3271 AppLog("MainScene::OnTouchDoublePressed");
3272 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3273 if (isReaderEnabled == true)
3277 delete __pReaderData;
3278 __pReaderData = null;
3280 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3281 filePath.Append(L"data/reader.js");
3287 result r = E_SUCCESS;
3288 FileAttributes attr;
3290 File::GetAttributes(filePath,attr);
3292 r = file.Construct(filePath, L"r+");
3295 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3298 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3301 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3304 file.Read(pScript,attr.GetFileSize());
3306 AppLogDebug("scipt length %d",strlen(pScript));
3307 String strScript = L"";
3308 strScript.Append(pScript);
3309 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3312 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3315 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3316 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3318 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3319 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3325 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3327 AppLog("MainForm::OnTouchLongPressed");
3329 if (__pHitElementResult != null)
3331 delete __pHitElementResult;
3332 __pHitElementResult = null;
3335 if (__pWebViewer != null)
3337 AppLog("MainForm::OnTouchLongPressed web not null");
3338 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3341 if (__pHitElementResult == null)
3346 if (__pHitElementResult->HasImage() == true)
3348 InitImageContextMenu(currentPosition);
3349 __pImageMenu->SetShowState(true);
3350 __pImageMenu->Show();
3351 __pImageMenu->Invalidate(true);
3355 String tagName = __pHitElementResult->GetTagName();
3356 String type = __pHitElementResult->GetAttributeValue("type");
3357 String value = __pHitElementResult->GetAttributeValue(L"value");
3358 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3360 __currentSelectedStr.Clear();
3361 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3363 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0)
3365 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3367 InitSelectTextContextMenu(currentPosition,true, true);
3368 __pImageMenu->SetShowState(true);
3369 __pImageMenu->Show();
3370 __pImageMenu->Invalidate(true);
3372 __isLongPressedDone = true;
3373 __pWebViewer->SetBlockSelectionPosition(currentPosition);
3378 __inputEventToBeSupressed = true;
3382 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3384 AppLog("MainForm::OnTouchReleased");
3386 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3387 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3389 __pWebViewer->ConsumeInputEvent();
3391 if(pHitElement != null)
3395 __inputEventToBeSupressed = false;
3399 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3401 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3402 int widthContextItem = 0;
3404 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3405 if (pBitmap != null && __pFooterLabel != null)
3407 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3412 __pMenu->SetShowState(false);
3413 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3415 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3419 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3422 if (__pFindWordBgLabel != null)
3424 // __pFindWordBgLabel->SetSize(GetClientAreaBounds().width,GetClientAreaBounds().height);
3425 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3426 if (pBitmap != null)
3428 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3434 AppLog("__pFooterPanel->GetShowState() is true");
3436 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3437 __pFooterPanel->Invalidate(true);
3441 if(__pMoreButton && __pMenu)
3443 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3444 __pMenu->SetAnchorPosition(p);
3445 __pMenu->Invalidate(true);
3448 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3449 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3451 InitMostVisitedSitesView(orientationStatus);
3454 RelayoutControls(false);
3455 if (__pArticleReaderPanel != null)
3457 if (__pArticleReaderPanel->GetShowState() == true)
3459 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3461 if (__pBlankPanel != null)
3462 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3464 if (__pWebReader != null)
3466 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3468 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3469 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3471 if ( pBitmap != null && pSrcBitmap != null)
3473 AppLog("CreateReaderPanel ninepatchbitmap found");
3474 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3477 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3478 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3479 if (pBitmap != null)
3484 if (pSrcBitmap != null)
3492 if(__pAddressbar != null)
3494 __pAddressbar->OrientationChanged();
3499 MainForm::OnSettingsChange(int settingvalue)
3501 AppLogDebug("MainForm::OnSettingsChange entered");
3502 if (__pWebViewer == null)
3504 AppLogDebug("Webviewer is not initialized yet.");
3507 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3509 WebSetting settings = __pWebViewer->GetSetting();
3510 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3512 settings.SetAutoFittingEnabled(true);
3514 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3516 settings.SetAutoFittingEnabled(false);
3518 __pWebViewer->SetSetting(settings);
3520 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
3522 WebSetting settings = __pWebViewer->GetSetting();
3523 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
3524 __pWebViewer->SetSetting(settings);
3526 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
3528 WebSetting settings = __pWebViewer->GetSetting();
3529 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
3530 __pWebViewer->SetSetting(settings);
3532 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
3534 WebSetting settings = __pWebViewer->GetSetting();
3535 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
3536 __pWebViewer->SetSetting(settings);
3538 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
3542 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3546 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
3548 WebSetting settings = __pWebViewer->GetSetting();
3549 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
3551 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
3555 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
3557 __pWebViewer->SetSetting(settings);
3559 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
3563 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
3564 WebSetting settings = __pWebReader->GetSetting();
3565 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
3566 __pWebReader->SetSetting(settings);
3572 MainForm::OnSettingsReset()
3576 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3577 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
3582 MainForm::OnClearCache()
3584 result r = E_SUCCESS;
3586 if (__pWebViewer != NULL)
3588 r = __pWebViewer->ClearCache();
3591 AppLogDebug("Cache cleared success");
3595 AppLogDebug("Cache cleared fail");
3601 MainForm::OnClearCookie()
3603 result r = E_SUCCESS;
3605 if (__pWebViewer != NULL)
3607 __pWebViewer->ClearCookie();
3611 AppLogDebug("Cookie cleared success");
3615 AppLogDebug("Cache cleared fail");
3620 MainForm::findDistance(int x1,int y1,int x2, int y2)
3622 int deltaX = Math::Abs(x2 - x1);
3623 int deltaY = Math::Abs(y2 - y1);
3624 double num = deltaX*deltaX + deltaY*deltaY;
3630 for (i = 0; i < 20; i++)
3632 x = (((x*x)+ num)/(2*x));
3643 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3645 if(__pFindWordPanel)
3647 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3648 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3650 __isLongPressedDone = false;
3653 IList* pList = null;
3654 pList = touch.GetTouchInfoListN(source);
3658 int count = pList->GetCount();
3661 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3662 __touchPoint1 = pTouchInfo->position;
3664 /*if (__pAddressbar != null)
3666 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3668 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3670 __pAddressbar->SaveAddressbarEditText();
3672 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3675 __pAddressbar->Invalidate(true);
3677 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3679 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3681 //__pAddressbar->SaveAddressbarEditText();
3683 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3686 else if (count == 2)
3688 AppLogDebug("MainForm::OnTouchPressed count is two");
3689 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3690 __touchPoint1 = pTouchInfo->position;
3692 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3693 __touchPoint2 = pTouchInfo->position;
3699 pList->RemoveAll(true);
3706 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3708 __currentWordIndex = 0;
3709 __isLongPressedDone = false;
3714 MainForm::MoveUiControls()
3719 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
3721 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
3723 if(__pFooterUrlField->GetTextLength() == 0)
3725 __pFooterUrlField->SetKeypadActionEnabled(false);
3729 __pFooterUrlField->SetKeypadActionEnabled(true);
3732 if (__pFindWordEditField != null)
3734 __currentSearchStr = __pFindWordEditField->GetText();
3735 __pFindWordNext->SetEnabled(false);
3736 __pFindWordPrev->SetEnabled(false);
3737 __pFindWordNext->Invalidate(true);
3738 __pFindWordPrev->Invalidate(true);
3739 __pFindWordCountLabel->SetText(L"0/0");
3740 __pFindWordCountLabel->Invalidate(true);
3742 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
3743 if (__currentSearchStr.GetLength() > 0)
3749 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
3751 AppLogDebug("Enter something");
3756 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
3763 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
3765 if(__pWebViewer != null)
3768 AppLog("MainForm::InitMostVisitedSitesView");
3769 result r = E_SUCCESS;
3772 if (__pWebViewer != null && __pMostVisitedListView != null)
3777 if (__pMostVisitedListView != null)
3779 RemoveControl(*__pMostVisitedListView);
3781 if(__pMostVisitedSites != null)
3783 __pMostVisitedSites->RemoveAll(true);
3786 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
3788 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
3789 __pMostVisitedListView = new(std::nothrow) ListView();
3791 int height = GetClientAreaBounds().height;
3793 if(__pFooterPanel->GetShowState() == true)
3795 height = height - __pFooterPanel->GetHeight();
3797 if(__pAddressbar->GetShowState() == true)
3799 height -= __pAddressbar->GetHeight();
3802 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
3806 delete __pMostVisitedListView;
3807 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
3810 __pMostVisitedListView->SetItemProvider(*this);
3811 __pMostVisitedListView->AddListViewItemEventListener(*this);
3812 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
3813 AddControl(*__pMostVisitedListView);
3814 __pMostVisitedListView->UpdateList();
3821 MainForm::GetImagePath(void)
3825 String formattedTime;
3826 DateTime currentTime;
3827 LocaleManager localManager;
3828 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
3830 localManager.Construct();
3831 Locale locale = localManager.GetSystemLocale();
3832 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
3834 // Get date formatter
3835 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
3839 pTimeFormatter->Format(currentTime, formattedTime);
3842 AppLog("current time stamp is %ls", formattedTime.GetPointer());
3843 String delim(L" :");
3844 StringTokenizer strTok(formattedTime, delim);
3847 String str1("GMT+00");
3848 while (strTok.HasMoreTokens())
3850 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
3851 if(token.Equals(str1))
3853 AppLog("token is %ls", token.GetPointer());
3854 imageName.Append(token);
3860 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
3862 result r = E_FAILURE;
3863 AppLog("Content manager 1");
3864 ContentId contentId;
3865 ContentManager contentManager;
3866 r = contentManager.Construct();
3869 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
3872 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
3873 contentPath.Append(imageName);
3874 contentPath.Append(".jpg");
3875 contentId = contentManager.CreateContent(*aBuffer, contentPath);
3876 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
3880 MainForm::SetForwardButtonEnabled(bool isEnabled)
3882 __pGoForwardBtn->SetEnabled(isEnabled);
3883 __pGoBackBtn->Invalidate(true);
3887 MainForm::SetBackButtonEnabled(bool isEnabled)
3889 __pGoBackBtn->SetEnabled(isEnabled);
3890 __pGoBackBtn->Invalidate(true);
3894 MainForm::UpdateProgress(int percentage)
3896 __progressPercentage = percentage;
3897 if (percentage == 0 || percentage == 100)
3899 __isLoadingData = false;
3900 if (percentage == 100)
3902 __isLoadingCompleted = true;
3903 __progressPercentage = 0;
3907 __isLoadingCompleted = false;
3912 __isLoadingData = true;
3914 UpdateProgressBitmap();
3918 MainForm::GetProgress(void)
3920 return __progressPercentage;
3924 MainForm::UpdateProgressBitmap(void)
3926 result r = E_SUCCESS;
3927 if (__pProgressbarLabel == null)
3929 int w = __pProgressbarLabel->GetWidth();
3930 int h = __pProgressbarLabel->GetHeight();
3932 int progressWidth = 0;
3933 Bitmap* pRetBitmap = null;
3935 if (__progressPercentage == 0 || __progressPercentage == 100)
3937 __pProgressbarLabel->SetShowState(false);
3938 __pProgressbarLabel->Invalidate(false);
3943 __pProgressbarLabel->SetShowState(true);
3944 __pProgressbarLabel->Invalidate(false);
3947 r = canvas.Construct(Rectangle(0, 0, w, h));
3951 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
3956 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
3960 pBgBmp->Scale(Dimension(w, h));
3961 canvas.DrawBitmap(Point(0,0), *pBgBmp);
3965 progressWidth = (double) (w) * __progressPercentage / 100;
3966 AppLogDebug("progressWidth: %d", progressWidth);
3967 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
3969 if (pProgressBmp != null)
3971 pProgressBmp->Scale(Dimension(progressWidth, h));
3972 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
3973 delete pProgressBmp;
3976 pRetBitmap = new (std::nothrow) Bitmap();
3978 if (pRetBitmap == null)
3980 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
3984 pRetBitmap->Construct(canvas, canvas.GetBounds());
3986 if (__pProgressbarLabel != null && pRetBitmap != null)
3988 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
3989 __pProgressbarLabel->Invalidate(false);
3992 if (pRetBitmap != null)
4000 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4002 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4004 __currentAddMode = addMode;
4008 case ADDRESSBAR_MODE_INVALID:
4013 case ADDRESSBAR_MODE_READER:
4015 __pStopBtn->SetShowState(false);
4016 __pClearBtn->SetShowState(false);
4019 case ADDRESSBAR_MODE_LOADING:
4021 __pRefreshBtn->SetShowState(false);
4022 __pStopBtn->SetShowState(true);
4023 __pClearBtn->SetShowState(false);
4026 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4028 // SetUrl(__pAddressbar->GetUrl());
4030 __pRefreshBtn->SetShowState(true);
4031 __pStopBtn->SetShowState(false);
4032 __pClearBtn->SetShowState(false);
4035 case ADDRESSBAR_MODE_EDIT:
4037 __pRefreshBtn->SetShowState(false);
4038 __pStopBtn->SetShowState(false);
4039 __pClearBtn->SetShowState(true);
4046 OnAddressBarModeChanged();
4049 AddressBarMode MainForm::GetAddressbarMode(void)
4051 return __currentAddMode;
4054 void MainForm::SetUrl(const String& url)
4058 if (__pFooterUrlField != NULL)
4060 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4061 if (removedHttpUrl.IsEmpty() == false)
4063 __pFooterUrlField->SetText(removedHttpUrl);
4064 __pAddressbar->SetUrl(__displayUrl);
4068 __pFooterUrlField->SetText(__displayUrl);
4069 __pAddressbar->SetUrl(__displayUrl);
4072 __pFooterUrlField->Invalidate(false);
4073 __pAddressbar->Invalidate(true);
4074 __pFooterUrlField->SetCursorPosition(0);
4079 MainForm::RemoveHttpTextFromDisplayURL(void)
4081 bool isHttpText = __displayUrl.Contains(L"http://");
4082 String updatedDisplayUrl;
4083 updatedDisplayUrl.Clear();
4085 if (isHttpText == true)
4087 __displayUrl.SubString(7,updatedDisplayUrl);
4089 return updatedDisplayUrl;