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_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
57 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
58 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
59 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
65 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
66 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
67 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
68 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
69 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
70 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
71 static const wchar_t* IDS_APPID = L"AppID";
72 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
73 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
75 const int IDA_BACKBTN_CLICKED = 101;
76 const int IDA_BOOKMARKBTN_CLICKED = 102;
77 const int IDA_MOREBTN_CLICKED = 103;
78 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
79 const int IDA_NEWWINDOWBTN_CLICKED = 105;
80 const int IDA_FORWARD_CLICKED = 106;
81 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
82 const int IDA_SHARE_CLICKED = 108;
83 const int IDA_FINDONPAGE_CLICKED = 109;
84 const int IDA_PRIVATEON_CLICKED = 110;
85 const int IDA_SETTINGS_CLICKED = 111;
86 const int IDA_READER_CLOSE_CLICKED = 112;
87 const int IDA_SMALLFONT_BTN_CLICKED = 113;
88 const int IDA_LARGEFONT_BTN_CLICKED = 114;
89 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
90 const int IDA_HISTORY_CLICKED = 116;
91 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
92 const int IDA_ADD_TO_HOME_CLICKED = 118;
93 const int IDA_SAVED_PAGES_CLICKED = 119;
94 const int IDA_DESKTOP_VIEW_CLICKED = 120;
95 const int IDA_SAVE_CLICKED = 121;
97 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
98 const int IDA_FINDWORD_NEXT_CLICKED = 202;
99 const int IDA_FINDWORD_PREV_CLICKED = 203;
100 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
101 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
103 const int IDA_COPY_IMAGE_CLICKED = 206;
104 const int IDA_VIEW_IMAGE_CLICKED = 207;
105 const int IDA_SAVE_IMAGE_CLICKED = 208;
106 const int IDA_SHARE_IMAGE_CLICKED = 209;
108 const int IDA_COPY_TEXT_CLICKED = 210;
109 const int IDA_PASTE_TEXT_CLICKED = 211;
110 const int IDA_FIND_TEXT__CLICKED = 212;
111 const int IDA_SHARE_TEXT_CLICKED = 213;
113 const int IDA_GO_BACK = 214;
114 const int IDA_GO_FORWARD = 215;
115 const int IDA_REFRESH_BTN_CLICKED = 216;
116 const int IDA_STOP_BTN_CLICKED = 217;
117 const int IDA_CLEAR_URL = 218;
119 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
121 const int MainForm::IDA_FORMAT_BITMAP = 500;
122 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
123 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
124 const int MainForm::IDA_FORMAT_URL_STRING = 503;
125 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
127 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
128 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
129 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
131 MainForm::MainForm(void)
133 __isLongPressedDone = false;
134 __pAddressbar = null;
135 // __pMostVisitedSitesPanel = null;
136 __pMostVisitedListView = null;
137 __pFooterPanel = null;
138 __pHitElementResult = null;
139 __pWindowInfo = null;
143 __pFindWordControl = null;
144 __pFindWordPanel = null;
145 __pFindWordBgLabel = null;
146 __pFindWordEditField = null;
147 __pFindWordClear = null;
148 __pFindWordCountLabel = null;
149 __pFindWordNext = null;
150 __pFindWordPrev = null;
151 __previousZoomLevel = 1.0;
153 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
156 __currentSearchStr = L"";
157 __currentSelectedStr = L"";
158 __maxOccurrances = 0;
159 __currentWordIndex = 0;
162 __inputEventToBeSupressed = false;
163 __isLoadingData = false;
164 __isLoadingCompleted = false;
165 __progressPercentage = 0;
166 __touchPoint1 = Point(-1,-1);
167 __touchPoint2 = Point(-1,-1);
169 // __pReaderPopup = null;
170 __pReaderData = null;
172 __pReaderCloseBtn = null;
173 //__pNewWindowButton = null;
174 __pMoreButton = null;
175 __pMultiWindowButton = null;
176 __pArticleReaderPanel = null;
177 __pBlankPanel = null;
178 __pArticleReaderLabel = null;
179 __webControlHeight = 0;
180 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
181 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
182 __pMostVisitedSites = null;
183 __pFooterUrlField = null;
185 __pGoForwardBtn = null;
186 __pRefreshBtn = null;
187 __pProgressbarLabel = null;
188 __pFooterLabel = null;
193 MainForm::~MainForm(void)
195 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
199 __pAddressbar->SetAddressbarEventListener(null);
201 if (__pReaderData != null)
203 delete __pReaderData;
204 __pReaderData = null;
207 if (__pPopUp != null)
213 if (__pHitElementResult != null)
215 delete __pHitElementResult;
216 __pHitElementResult = null;
218 String* pSelectedScene = NULL;
219 Object* pValue = NULL;
220 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
221 pSelectedScene = (String*) pValue;
223 /*if (pSelectedScene != null)
225 delete pSelectedScene;
227 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
231 MainForm::Initialize(void)
233 Construct(L"IDL_FORM");
238 MainForm::OnInitializing(void)
240 AppLog("get client area width = %d",GetClientAreaBounds().width);
241 AppLog("get client area height = %d",GetClientAreaBounds().height);
242 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
243 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
245 Panel* pFooterPanel = null;
247 __pSaveImage = new Image();
248 __pSaveImage->Construct();
250 // Setup back event listener
251 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
252 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
253 AddOrientationEventListener(*this);
254 AppLogDebug(" MainForm::OnInitializing ended");
255 if (__pMostVisitedSites == null)
257 __pMostVisitedSites = new(std::nothrow) ArrayList();
258 __pMostVisitedSites->Construct();
260 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
262 __pItemContext= new(std::nothrow) ListContextItem();
263 __pItemContext->Construct();
264 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
265 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
267 if (pBitmapNormal != null && pBitmapPressed != null)
269 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
272 if (pBitmapNormal != null)
274 delete pBitmapNormal;
277 if (pBitmapPressed != null)
279 delete pBitmapPressed;
282 __pItemContextLandscape= new(std::nothrow) ListContextItem();
283 __pItemContextLandscape->Construct();
284 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
285 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
287 if (pBitmapNormal != null && pBitmapPressed != null)
289 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
292 if (pBitmapNormal != null)
294 delete pBitmapNormal;
297 if (pBitmapPressed != null)
299 delete pBitmapPressed;
306 MainForm::InitAddressbar(void)
308 AppLogDebug("MainForm::InitAddressbar entered");
310 result r = E_SUCCESS;
312 if (__pAddressbar != null)
316 __pAddressbar = new(std::nothrow) Addressbar();
317 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
318 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
321 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
324 __pAddressbar->SetAddressbarEventListener(this);
325 AddControl(*__pAddressbar);
326 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
327 SetControlAlwaysOnTop(*__pAddressbar, true);
328 __adressPanelPosition = __pAddressbar->GetPosition();
330 AppLogDebug("MainForm::InitAddressbar exit");
336 MainForm::CreateReaderPanel(void)
338 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
339 result r = E_FAILURE;
341 Button *pSmallFontBtn = null;
342 Button *pLargeFontBtn = null;
344 __pBlankPanel = new (std::nothrow) Panel();
345 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
347 __pArticleReaderPanel = new (std::nothrow) Panel();
348 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
350 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
351 if (__pReaderCloseBtn)
353 AppLogDebug("CreateReaderPanel() 6");
354 __pReaderCloseBtn->AddActionEventListener(*this);
355 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
358 __pWebReader = new (std::nothrow) Web();
359 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
361 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
362 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
364 r = __pWebReader->SetSetting(settings);
366 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
369 __pArticleReaderLabel = new Label();
370 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
372 __pBlankPanel->AddControl(*__pArticleReaderLabel);
373 __pBlankPanel->AddControl(*__pArticleReaderPanel);
374 AddControl(*__pBlankPanel);
376 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
377 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
378 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
380 __pArticleReaderPanel->AddControl(*__pWebReader);
381 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
382 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
383 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
385 if (pBitmap != null && pSrcBitmap != null)
387 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
389 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
391 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
394 pSmallFontBtn->AddActionEventListener(*this);
395 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
398 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
401 pLargeFontBtn->AddActionEventListener(*this);
402 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
411 if (pSrcBitmap != null)
417 SetControlAlwaysOnTop(*__pBlankPanel, true);
418 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
425 MainForm::InitWebControl()
427 AppLogDebug("MainForm::InitWebControl enter");
428 result r = E_SUCCESS;
429 AppLogDebug("InitWebControl");
431 if (__pAddressbar == null || __pFooterPanel == null)
434 const int Y_WEBCONTROL_POSITION = 0;
435 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
436 if (__pMostVisitedListView)
438 __pMostVisitedListView->SetShowState(false);
440 if (__pWebViewer != null)
442 AppLogDebug("Already initialized");
445 __pWebViewer = new(std::nothrow) Web();
446 if(__pWebViewer == NULL)
448 AppLogDebug("Initialization failed");
451 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));
455 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
462 r = AddControl(*__pWebViewer);
466 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
469 __webControlPosition = __pWebViewer->GetPosition();
470 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
473 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
477 __pWebViewer->SetLoadingListener(this);
478 __pWebViewer->SetWebUiEventListener(this);
479 __pWebViewer->SetWebKeypadEventListener(this);
480 __pWebViewer->SetFocus();
481 __pWebViewer->AddTouchEventListener(*this);
483 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
484 __pWebViewer->SetTextSearchListener(this);
487 AppLogDebug("MainForm :before return");
489 AppLogDebug("MainForm::InitWebControl Exit");
495 MainForm::OnFocusGained(const Control& source)
497 if(__pAddressbar != null)
499 __pFooterUrlField->SetFocusable(false);
500 __pAddressbar->SetAddressbarURLFocus();
507 MainForm::SetJavascriptEnabled()
509 WebSetting settings = __pWebViewer->GetSetting();
510 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
511 __pWebViewer->SetSetting(settings);
515 MainForm::SetImageLoadEnabled()
517 WebSetting settings = __pWebViewer->GetSetting();
518 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
519 __pWebViewer->SetSetting(settings);
523 MainForm::InitFooter(void)
525 AppLogDebug("MainForm::InitFooter entered");
526 Button* pBackButton = null;
527 Button* pBookmarkButton = null;
528 Button* pMultiWindowButton = null;
529 Bitmap *pIconBitmap = null;
530 Bitmap *pBGBitmap = null;
531 Label *pBGLabel = null;
533 if (__pFooterPanel == null)
535 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
538 if (__pFooterPanel == null)
543 SetControlAlwaysOnTop(*__pFooterPanel, true);
545 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
546 if ( __pFooterLabel == NULL )
550 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
551 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
554 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
558 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
560 if ( __pMultiWindowButton == NULL )
565 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
567 if ( __pMoreButton == NULL )
572 if (__pMultiWindowButton != null)
574 Bitmap* pBitmap = null;
575 Bitmap* pPressedBitmap = null;
576 String imagePath = "I01_toolbar_icon_windows_manager_0";
577 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
578 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
579 imagePath.Append(totalCount);
580 imagePath.Append(".png");
582 pressedImagePath.Append(totalCount);
583 pressedImagePath.Append("_press.png");
585 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
586 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
587 if ( pBitmap == null )
592 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
595 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
596 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
601 __pMultiWindowButton->AddActionEventListener(*this);
602 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
607 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
608 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
611 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
612 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
613 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
617 __pMoreButton->AddActionEventListener(*this);
618 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
621 //Add the editfield for url
622 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
623 if (__pFooterUrlField == NULL)
625 return E_INVALID_KEY;
628 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
629 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
630 //__pFooterUrlField->AddFocusEventListener(*this);
631 __pFooterUrlField->AddKeypadEventListener(*this);
632 __pFooterUrlField->AddFocusEventListener(*this);
634 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
636 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
638 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
640 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
644 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
645 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
648 //Add the go Back Button
649 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
650 if (__pGoBackBtn == NULL)
652 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
653 return E_INVALID_KEY;
655 __pGoBackBtn->SetActionId(IDA_GO_BACK);
656 __pGoBackBtn->AddActionEventListener(*this);
658 //Add the go forward Button
659 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
660 if (__pGoForwardBtn == NULL)
662 AppLogDebug("Control not found returning E_INVALID_KEY");
663 return E_INVALID_KEY;
665 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
666 __pGoForwardBtn->AddActionEventListener(*this);
667 __pGoForwardBtn->SetEnabled(false);
669 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
670 if (__pRefreshBtn == NULL)
672 AppLogDebug("Control not found returning E_INVALID_KEY");
673 return E_INVALID_KEY;
676 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
677 __pRefreshBtn->AddActionEventListener(*this);
678 __pRefreshBtn->SetShowState(true);
680 //Add the backround label for displaying progressbar
681 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
682 if (__pProgressbarLabel == NULL)
684 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
685 return E_INVALID_KEY;
687 __pProgressbarLabel->SetShowState(false);
689 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
690 if (__pStopBtn == NULL)
692 AppLogDebug("Control not found returning E_INVALID_KEY");
693 return E_INVALID_KEY;
695 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
696 __pStopBtn->AddActionEventListener(*this);
697 __pStopBtn->SetShowState(false);
699 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
700 if (__pClearBtn == NULL)
702 AppLogDebug("Control not found returning E_INVALID_KEY");
703 return E_INVALID_KEY;
705 __pClearBtn->SetActionId(IDA_CLEAR_URL);
706 __pClearBtn->AddActionEventListener(*this);
707 __pClearBtn->SetShowState(false);
709 // __pFooterPanel->Invalidate(true);
710 AppLogDebug("MainForm::InitFooter exit");
716 MainForm::InitContextMenu(Point& p)
718 result r = E_SUCCESS;
719 bool isPrivateBrowsing = false;
720 Bitmap* pBitmap = null;
724 __pMenu->SetAnchorPosition(p);
725 __pMenu->Invalidate(true);
729 __pMenu = new(std::nothrow) ContextMenu();
730 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);
731 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
733 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
736 if (isPrivateBrowsing == true)
738 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
742 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
745 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
747 if ( pBitmap != NULL)
749 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
752 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
753 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
754 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
757 __pMenu->SetMaxVisibleItemsCount(6);
758 __pMenu->SetShowState(false);
759 __pMenu->AddActionEventListener(*this);
760 SetControlAlwaysOnTop(*__pMenu, true);
766 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
768 result r = E_SUCCESS;
769 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
771 AppLog("MainForm::InitImageContextMenu clicked on image");
772 if (__pImageMenu != null)
778 p.y = p.y + __pAddressbar->GetHeight() + 12;
781 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
785 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
787 __pImageMenu = new (std::nothrow) ContextMenu();
788 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
789 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
791 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
792 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
793 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
794 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
795 __pImageMenu->SetMaxVisibleItemsCount(4);
796 __pImageMenu->AddActionEventListener(*this);
797 SetControlAlwaysOnTop(*__pImageMenu, true);
802 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
804 result r = E_SUCCESS;
805 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
807 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
808 if (__pImageMenu != null)
813 p.y = p.y + __pAddressbar->GetHeight() + 12;
816 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
820 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
822 __pImageMenu = new (std::nothrow) ContextMenu();
823 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
824 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
826 if(onlyPasteOption == false)
828 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
830 if (pasteOption || onlyPasteOption)
832 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
834 if(onlyPasteOption == false)
836 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
837 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
840 __pImageMenu->SetMaxVisibleItemsCount(3);
841 __pImageMenu->AddActionEventListener(*this);
842 SetControlAlwaysOnTop(*__pImageMenu, true);
849 MainForm::InitFindWordPanel(void)
851 result r = E_SUCCESS;
852 Bitmap *pIconBitmap = null;
854 if (__pFindWordPanel != null)
856 AppLogDebug("Findword panel already initialized");
857 if (__pFindWordBgLabel != null)
859 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
862 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
869 __pFindWordPanel = static_cast<Panel*>(GetControl(L"IDC_FIND_ON_PAGE_PANEL"));
870 if (__pFindWordPanel == null)
872 AppLogException("There is some problem in the xml file. Please check.");
876 __pFindWordControl = new (std::nothrow) Panel();
877 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
880 AppLogException("There is some problem in the xml file. Please check.");
883 AddControl(*__pFindWordControl);
884 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
885 SetControlAlwaysOnTop(*__pFindWordControl,true);
886 __pFindWordPanel->SetShowState(false);
887 __pFindWordPanel->Invalidate(false);
889 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
890 if (__pFindWordBgLabel != null)
892 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
893 Rectangle pRect = pPanel1->GetBounds();
894 pRect.x = pRect.y = 0;
895 __pFindWordBgLabel->SetBounds(pRect);
896 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
899 AppLogDebug("InitFindWordPanel: Coming here");
900 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
905 AppLogDebug("InitFindWordPanel: shouldn't Come here");
909 Button* pfindWordCancel = null;
910 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
911 if (pfindWordCancel == null)
913 AppLogException("There is some problem in the xml file. Please check.");
916 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
917 pfindWordCancel->AddActionEventListener(*this);
919 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
920 if (__pFindWordClear == null)
922 AppLogException("There is some problem in the xml file. Please check.");
926 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
927 __pFindWordClear->AddActionEventListener(*this);
929 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
930 if (__pFindWordNext == null)
932 AppLogException("There is some problem in the xml file. Please check.");
936 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
937 __pFindWordNext->AddActionEventListener(*this);
939 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
940 if (__pFindWordPrev == null)
942 AppLogException("There is some problem in the xml file. Please check.");
946 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
947 __pFindWordPrev->AddActionEventListener(*this);
949 __pFindWordNext->SetEnabled(false);
950 __pFindWordPrev->SetEnabled(false);
952 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
953 if (__pFindWordCountLabel == null)
955 AppLogException("There is some problem in the xml file. Please check.");
959 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
960 if (__pFindWordEditField == null)
962 AppLogException("There is some problem in the xml file. Please check.");
965 __pFindWordEditField->AddTextEventListener(*this);
966 __pFindWordEditField->AddKeypadEventListener(*this);
967 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
973 MainForm::CreateItem (int index, int itemWidth)
975 Rectangle listImageRect;
976 Rectangle pagetTitleRect;
977 Rectangle pageURLRect;
978 Rectangle deleteImageRect;
979 String pageTitle(L"");
981 result r = E_SUCCESS;
982 Bitmap* pListIconImage = null;
985 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
990 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
991 if ( pAppResource == NULL )
995 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
997 CustomItem* pItem = new(std::nothrow) CustomItem();
998 pageTitle = pHistory->GetHistoryTitle();
999 pageURL = pHistory->GetHistoryUrl();
1001 if (pageURL.GetLength() == 0)
1004 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1005 pageURL = L"<"+ nourl +">";
1009 Rectangle screenBounds = GetBounds();
1012 r = pItem->Construct(Dimension(itemWidth, 128), style);
1021 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1023 if ( pBitmap != NULL)
1025 pListIconImage = new Bitmap();
1026 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1030 if(pListIconImage == null)
1032 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1035 if ( pListIconImage != NULL)
1037 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1038 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1039 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1042 if (pItem != null && pListIconImage != NULL)
1044 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1048 if (pageTitle.CompareTo(L"") != 0)
1052 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1056 if (pageURL.CompareTo(L"") != 0)
1060 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1065 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1067 if ( __pItemContext!= NULL)
1071 pItem->SetContextItem(__pItemContext);
1077 if ( __pItemContextLandscape!= NULL)
1081 pItem->SetContextItem(__pItemContextLandscape);
1085 if( pListIconImage != NULL)
1087 delete pListIconImage;
1088 pListIconImage = null;
1095 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1102 MainForm::GetItemCount (void)
1104 if(__pMostVisitedSites != null)
1106 __pMostVisitedSites->RemoveAll(true);
1108 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1109 if(__pMostVisitedSites != null)
1111 return __pMostVisitedSites->GetCount();
1118 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1120 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1121 String url = pHistory->GetHistoryUrl();
1122 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1123 __pMostVisitedListView->UpdateList();
1127 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1129 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1130 String url = pHistory->GetHistoryUrl();
1138 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1144 MainForm::OnTerminating(void)
1146 result r = E_SUCCESS;
1149 delete __pItemContext;
1151 if(__pItemContextLandscape)
1153 delete __pItemContextLandscape;
1159 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1161 result r = E_SUCCESS;
1163 AppLogDebug("Clicked : %d", actionId);
1166 case IDA_BACKBTN_CLICKED:
1168 if (__pWebViewer && __pWebViewer->CanGoBack())
1170 __pWebViewer->GoBack();
1175 pApp = UiApp::GetInstance();
1178 r = pApp->Terminate();
1181 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1189 case IDA_FORWARD_CLICKED:
1190 if (__pWebViewer == null)
1193 if (__pWebViewer->CanGoForward())
1195 __pWebViewer->GoForward();
1197 __pMenu->SetShowState(false);
1198 __pMenu->Invalidate(false);
1201 case IDA_FINDONPAGE_CLICKED:
1203 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1204 __currentSearchStr.Clear();
1206 InitFindWordPanel();
1207 __pMenu->SetShowState(false);
1208 __pMenu->Invalidate(false);
1210 __pFindWordEditField->SetFocus();
1212 if (__pWebViewer != null)
1214 // releasing the set block
1215 __pWebViewer->ReleaseBlock();
1218 ShowFindWordPanel(true);
1221 case IDA_PRIVATEON_CLICKED:
1223 result r = E_SUCCESS;
1225 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1226 Bitmap* pBitmap = null;
1227 if (isPrivateBrowsing == true)
1229 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1232 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1236 if (__pWebViewer != NULL)
1238 __pWebViewer->SetPrivateBrowsingEnabled(false);
1241 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1243 if (__pAddressbar != null)
1245 __pAddressbar->UpdateFaviconBitmap(false);
1251 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1254 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1258 if (__pWebViewer != NULL)
1260 __pWebViewer->SetPrivateBrowsingEnabled(true);
1263 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1265 if (__pAddressbar != null)
1267 __pAddressbar->UpdateFaviconBitmap(true);
1272 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1273 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1274 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1275 __pMenu->Invalidate(true);
1277 if ( pBitmap != NULL )
1284 case IDA_SETTINGS_CLICKED:
1287 ArrayList* pArgList = new(std::nothrow) ArrayList();
1290 pArgList->Construct();
1291 pArgList->Add(*__pWindowInfo);
1292 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1294 __pMenu->SetShowState(false);
1295 __pMenu->Invalidate(false);
1296 if (pArgList != null)
1305 case IDA_ADDTOBOOKMARK_CLICKED:
1308 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1310 int bookmarkCount=0;
1313 url=__pWindowInfo->pageUrl;
1314 result r = E_SUCCESS;
1315 Bitmap* pBitmap = null;
1316 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1324 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1325 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1326 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1328 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1329 if (pNotification != null)
1331 pNotification->SetText(message);
1332 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1333 pNotification->ShowNotification();
1338 String title=__pWindowInfo->pageTitle;
1339 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1340 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1342 pBookmark->SetBookmarkTitle(title);
1343 pBookmark->SetUrl(url);
1344 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1346 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1348 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1349 pBookmark->SetFaviconId(id);
1350 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1351 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1354 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1355 if (pNotification != null)
1357 pNotification->SetText(message);
1358 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1359 pNotification->ShowNotification();
1360 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1363 if (pBitmap != null)
1365 r = __pMenu->SetItemAt(0,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1369 __pMenu->Invalidate(true);
1373 case IDA_SHARE_CLICKED:
1375 if(__pPopUp != null)
1380 __pPopUp = new(std::nothrow) SharePopup();
1381 __pPopUp->Initialize();
1382 if (__pWindowInfo != null)
1384 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1385 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1386 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1387 pShareInfo->SetImageAttached(false);
1388 __pPopUp->RemoveAllShareInfo();
1389 __pPopUp->AddShareInfo(pShareInfo);
1391 __pPopUp->SetShowState(true);
1395 case IDA_BOOKMARKBTN_CLICKED:
1397 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1398 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1401 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1406 case IDA_MOREBTN_CLICKED:
1408 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1409 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1410 AppLog("Anchot pos: %d %d", p.x, p.y);
1412 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1414 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1415 int bookmarkCount=0;
1418 url=__pWindowInfo->pageUrl;
1419 result r = E_SUCCESS;
1420 Bitmap* pBitmap = null;
1422 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1425 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1430 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1434 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1436 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1438 if (__pMenu->GetItemCount() == 8)
1440 r = __pMenu->SetItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1444 r = __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1449 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1453 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1454 if (__pMenu->GetItemCount() != 8)
1456 __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADDTOBOOKMARK_CLICKED);
1458 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1459 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1460 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1461 __pMenu->SetMaxVisibleItemsCount(6);
1463 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1465 AppLog(" Orientation landscape");
1466 __pMenu->SetMaxVisibleItemsCount(5);
1470 AppLog(" Orientation potrait");
1471 __pMenu->SetMaxVisibleItemsCount(6);
1474 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1477 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1478 __pMenu->SetShowState(true);
1479 __pMenu->Invalidate(true);
1483 case IDA_HISTORY_CLICKED:
1485 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1486 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1489 case IDA_SAVED_PAGES_CLICKED:
1494 case IDA_DESKTOP_VIEW_CLICKED:
1499 case IDA_SAVE_CLICKED:
1504 case IDA_MULTIWINDOWBTN_CLICKED:
1506 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1507 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1511 case IDA_NEWWINDOWBTN_CLICKED:
1513 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1515 if (pNewWindowInfo == null)
1519 result r = E_SUCCESS;
1520 SceneManager* pSceneManager = SceneManager::GetInstance();
1522 if (pSceneManager == NULL)
1526 ArrayList* pArgList = new(std::nothrow) ArrayList();
1527 if (pArgList == NULL)
1531 r = pArgList->Construct();
1534 pArgList->Add(*pNewWindowInfo);
1535 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1541 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1546 case IDA_SMALLFONT_BTN_CLICKED:
1548 WebSetting setting = __pWebReader->GetSetting();
1549 setting.SetFontSize(15);
1550 __pWebReader->SetSetting(setting);
1553 case IDA_LARGEFONT_BTN_CLICKED:
1555 WebSetting setting = __pWebReader->GetSetting();
1556 setting.SetFontSize(25);
1557 __pWebReader->SetSetting(setting);
1560 case IDA_READER_CLOSE_CLICKED:
1562 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1564 //__pArticleReaderPanel->SetShowState(false);
1565 //__pArticleReaderPanel->Show();
1566 RemoveControl(*__pBlankPanel);
1567 //RemoveControl(*__pArticleReaderPanel);
1568 __pArticleReaderPanel = null;
1569 __pBlankPanel = null;
1570 __pArticleReaderLabel = null;
1572 //if (__pAddressbar)
1573 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1574 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1577 case IDA_FINDWORD_CANCEL_CLICKED:
1579 __currentSearchStr = L"";
1580 __currentWordIndex = 0;
1581 __maxOccurrances = 0;
1582 __pFindWordEditField->SetText(L"");
1583 __pFindWordNext->SetEnabled(false);
1584 __pFindWordPrev->SetEnabled(false);
1585 __pFindWordCountLabel->SetText(L"0/0");
1586 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1587 ShowFindWordPanel(false);
1590 case IDA_FINDWORD_SEARCH_CLICKED:
1592 __currentSearchStr = __pFindWordEditField->GetText();
1593 if (__currentSearchStr.GetLength() > 0)
1599 AppLogDebug("Enter something");
1603 case IDA_FINDWORD_CLEAR_CLICKED:
1605 __pFindWordCountLabel->SetText(L"0/0");
1606 __pFindWordEditField->SetText(L"");
1607 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1609 __currentSearchStr = L"";
1610 __pFindWordNext->SetEnabled(false);
1611 __pFindWordPrev->SetEnabled(false);
1612 __pFindWordPanel->Invalidate(true);
1615 case IDA_FINDWORD_NEXT_CLICKED:
1620 case IDA_FINDWORD_PREV_CLICKED:
1622 FindNextWord(false);
1625 case IDA_BRIGHTNESS_BTN_CLICKED:
1627 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1628 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1631 case IDA_COPY_IMAGE_CLICKED:
1633 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1634 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1636 const Bitmap* pBitmap = null;
1637 if (__pHitElementResult != null)
1639 pBitmap = __pHitElementResult->GetImage();
1642 String resourcePath = App::GetInstance()->GetAppResourcePath();
1643 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1645 // copying the item to clipboard
1646 Clipboard* pClipboard = Clipboard::GetInstance();
1647 if (pClipboard != null)
1649 pClipboard->CopyItem(item);
1653 case IDA_VIEW_IMAGE_CLICKED:
1655 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1656 WindowInfo* pNewWindowInfo = null;
1657 if (__pHitElementResult != null)
1659 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1660 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1666 case IDA_SAVE_IMAGE_CLICKED:
1668 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1669 const Bitmap* pSaveBitmap = null;
1670 String imageName = GetImagePath();
1671 AppLog("Content manager image name %ls",imageName.GetPointer());
1674 imagePath.Append(imageName);
1675 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1676 AppLog("Content manager image path %ls",imagePath.GetPointer());
1677 if (__pHitElementResult != null)
1679 pSaveBitmap = __pHitElementResult->GetImage();
1681 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1685 UpdateImageContent(pBuffer, imageName);
1687 NotificationPanel *pNotification = new NotificationPanel(*this);
1689 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1690 msg.Append(imagePath);
1691 if (pNotification != null)
1693 pNotification->SetText(msg);
1694 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1695 pNotification->ShowNotification();
1700 int __modalMsgBoxResult;
1701 MessageBox* pMsgBox = new MessageBox();
1702 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1703 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1706 __modalMsgBoxResult = 0;
1710 case IDA_SHARE_IMAGE_CLICKED:
1712 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1713 if (__pPopUp != null)
1718 __pPopUp = new(std::nothrow) SharePopup();
1719 __pPopUp->Initialize();
1720 if (__pHitElementResult != null)
1722 const Bitmap* pSaveBitmap = null;
1723 String imageName = GetImagePath();
1724 AppLog("Content manager image name %ls",imageName.GetPointer());
1727 imagePath.Append(imageName);
1728 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1729 AppLog("Content manager image path %ls",imagePath.GetPointer());
1730 if (__pHitElementResult != null)
1732 pSaveBitmap = __pHitElementResult->GetImage();
1734 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1736 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1737 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1739 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1740 pShareInfo->SetPageTitle(L"");
1741 pShareInfo->SetPageUrl(srcUrl);
1742 pShareInfo->SetImageAttached(true);
1743 pShareInfo->SetImagePath(imagePath);
1744 __pPopUp->RemoveAllShareInfo();
1745 __pPopUp->AddShareInfo(pShareInfo);
1746 __pPopUp->SetShowState(true);
1751 case IDA_FIND_TEXT__CLICKED:
1753 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1754 __currentSearchStr.Clear();
1755 __currentSearchStr.Append(__currentSelectedStr);
1756 InitFindWordPanel();
1759 __pMenu->SetShowState(false);
1760 __pMenu->Invalidate(false);
1763 __adressPanelPosition.y = 0;
1765 if (__pAddressbar != null && __pWebViewer != NULL)
1767 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1768 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1769 //__pAddressbar->Invalidate(true);
1770 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
1772 if (__pFooterPanel->GetShowState() == false)
1773 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
1775 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
1776 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1777 __pWebViewer->Invalidate(true);
1780 ShowFindWordPanel(true);
1781 if (__currentSearchStr.GetLength() > 0)
1787 AppLogDebug("Enter something");
1790 if (__pWebViewer != null)
1792 // releasing the set block
1793 __pWebViewer->ReleaseBlock();
1798 case IDA_SHARE_TEXT_CLICKED:
1800 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
1801 if(__pPopUp != null)
1806 __pPopUp = new(std::nothrow) SharePopup();
1807 __pPopUp->Initialize();
1808 if (__pHitElementResult != null)
1810 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1811 pShareInfo->SetPageTitle(L"");
1812 pShareInfo->SetPageUrl(__currentSelectedStr);
1813 pShareInfo->SetImageAttached(false);
1814 __pPopUp->RemoveAllShareInfo();
1815 __pPopUp->AddShareInfo(pShareInfo);
1816 __pPopUp->SetShowState(true);
1821 case IDA_COPY_TEXT_CLICKED:
1823 // need to implement
1824 //__currentSelectedStr
1825 // Sets data to a clip board item
1827 String resourcePath = App::GetInstance()->GetAppResourcePath();
1828 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
1830 // copying the item to clipboard
1831 Clipboard* pClipboard = Clipboard::GetInstance();
1832 if (pClipboard != null)
1834 pClipboard->CopyItem(item);
1838 case IDA_PASTE_TEXT_CLICKED:
1840 Clipboard* pClipboard = Clipboard::GetInstance();
1842 if(pClipboard == null)
1846 // Retrieves a latest item
1847 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1853 //Gets data from the clipboard item
1854 String* pString = dynamic_cast<String*>(pItem->GetData());
1856 if (pString != null)
1858 String idElement = __pHitElementResult->GetAttributeValue(L"id");
1859 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
1860 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
1861 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; } } ";
1862 if(idElement.GetLength() != 0)
1864 script.Append("insertAtCursor(");
1865 script.Append(idElement);
1867 script.Append("\"");
1868 script.Append(*pString);
1869 script.Append("\");");
1871 else if (nameElement.GetLength() != 0)
1873 script.Append("insertAtCursor(document.getElementsByName('");
1874 script.Append(nameElement);
1875 script.Append("')[0],");
1876 script.Append("\"");
1877 script.Append(*pString);
1878 script.Append("\");");
1880 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
1881 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
1892 case IDA_GO_FORWARD:
1897 case IDA_REFRESH_BTN_CLICKED:
1899 __isLoadingCompleted = false;
1900 __isLoadingData = true;
1901 __progressPercentage = 0;
1902 __displayUrl = __pFooterUrlField->GetText();
1904 String url = __pFooterUrlField->GetText();
1905 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
1909 UpdateProgressBitmap();
1912 case IDA_STOP_BTN_CLICKED:
1914 __isLoadingCompleted = false;
1915 __isLoadingData = false;
1916 __progressPercentage = 0;
1917 __pFooterUrlField->HideKeypad();
1918 __displayUrl = __pFooterUrlField->GetText();
1922 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1923 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1924 __pWebViewer->StopLoading();
1925 RequestRedraw(true);
1928 UpdateProgressBitmap();
1933 if (__pFooterUrlField->GetText().IsEmpty() == false)
1935 //__displayUrl = __pUrlField->GetText();
1936 __pFooterUrlField->Clear();
1946 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1949 UiApp* pApp = UiApp::GetInstance();
1958 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1959 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
1961 String* pSelectedScene = NULL;
1962 Object* pValue = NULL;
1963 String* pUrl = null;
1964 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
1965 pSelectedScene = (String*) pValue;
1967 if (pSelectedScene != null)
1969 delete pSelectedScene;
1971 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
1972 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
1973 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
1974 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
1976 // setting the current scene ID
1977 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
1979 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
1981 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
1983 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1984 if(__pWindowInfo == null)
1986 // if(__pWindowInfo == null)
1988 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
1991 else if ( pArgs != null && pArgs->GetCount() == 1)
1993 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1999 // hiding the address bar
2000 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2001 __pAddressbar->SetShowState(false);
2002 if(__pWebViewer != null)
2004 __pWebViewer->Resume();
2007 if(pUrl != null && pUrl->GetLength() > 0)
2011 else if(__pWindowInfo != null)
2013 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)
2015 LoadUrl(__pWindowInfo->pageUrl);
2017 else if (__pWindowInfo->isJavascriptInitiated == true)
2021 __pWindowInfo->pCurrentWeb = __pWebViewer;
2025 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2026 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2027 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2029 InitMostVisitedSitesView(GetOrientationStatus());
2032 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2034 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2036 if (pBookmarkUrl == null)
2038 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2039 //__pAddressbar->SetUrl(*pBookmarkUrl);
2040 SetUrl(*pBookmarkUrl);
2042 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2043 __pWebViewer->LoadUrl(*pBookmarkUrl);
2044 delete pBookmarkUrl;
2047 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2048 Bitmap* pBitmap = null;
2049 if (isPrivateBrowsing == true)
2051 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2053 if (__pWebViewer != null)
2055 __pWebViewer->SetPrivateBrowsingEnabled(true);
2058 if (__pAddressbar != null)
2060 // __pAddressbar->UpdateFaviconBitmap(true);
2066 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2068 if (__pWebViewer != null)
2070 __pWebViewer->SetPrivateBrowsingEnabled(false);
2073 if (__pAddressbar != null)
2075 // __pAddressbar->UpdateFaviconBitmap(false);
2079 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2081 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2083 else if (__pMenu != null )
2085 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2088 if (pBitmap != null)
2093 AppLog("ABC: OnSceneActivatedN started exit");
2098 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2099 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2101 Canvas* pWebCanvas = null;
2102 if (__pWebViewer != null)
2104 pWebCanvas = __pWebViewer->GetCanvasN();
2105 __pWebViewer->Pause();
2108 if (pWebCanvas == null)
2112 if (__pWindowInfo != null)
2114 if (__pWindowInfo->pWebCanvasBitmap != null)
2116 delete __pWindowInfo->pWebCanvasBitmap;
2118 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2119 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2120 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2122 Bitmap* pBitmap = GetCapturedBitmapN();
2123 AppLog("Coming here");
2124 Canvas* pCanvas = new(std::nothrow) Canvas();
2125 pCanvas->Construct(GetClientAreaBounds());
2128 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2131 if(__pWebViewer != null && __pWindowInfo != null)
2132 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2134 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2135 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2137 AppLog("Coming here");
2141 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2142 const Tizen::Base::String& realm,
2143 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2149 MainForm::OnHttpAuthenticationCanceled(void)
2154 MainForm::OnLoadingStarted(void)
2156 AppLogDebug("MainForm::OnLoadingStarted entered");
2158 if(__pAddressbar == NULL || __pWebViewer == null)
2162 String url = __pWebViewer->GetUrl();
2163 if(url.Contains(IDS_TIZEN_SERVICE))
2166 String delim(L":;");
2168 // Creates a StringTokenizer instance
2169 StringTokenizer strTok(url, delim);
2171 int count = strTok.GetTokenCount(); // count == 4
2173 HashMap *pMap = new HashMap();
2178 while (strTok.HasMoreTokens())
2180 AppLog("Token: %ls", token.GetPointer());
2181 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2182 if(token.Contains(IDS_APPID))
2184 token.SubString(6, appId);
2185 AppLog("AppID:%ls", appId.GetPointer());
2187 else if(token.Contains("="))
2189 String *pKey = new String();
2190 String *pValue = new String();
2192 token.IndexOf("=", 0, index);
2195 token.SubString(0, index, *pKey);
2196 token.SubString(index + 1, *pValue);
2197 pMap->Add(pKey, pValue);
2203 AppControl *pAppControl = null;
2204 String operationId = L"http://tizen.org/appcontrol/operation/main";
2205 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2208 AppLog("Starting AppControl");
2209 result r = pAppControl->Start(null, null, pMap, null);
2210 AppLog("Result of Start %s", GetErrorMessage(r));
2214 AppLogException("AppControl not found");
2219 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2222 __pAddressbar->SetFaviconBitmap(*pBitmap);
2225 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2227 // updating the address bar position with respect to web control
2228 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2229 __distanceMoved = 0;
2233 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2234 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2235 if (__pWebViewer != null)
2237 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2238 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2239 SetUrl(__pWebViewer->GetUrl());
2240 if (__pWindowInfo != NULL)
2242 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2244 __pAddressbar->Invalidate(true);
2250 MainForm::OnLoadingCanceled(void)
2257 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2259 AppLog("MainForm::OnKeypadWillOpen");
2260 if (__pAddressbar != null)
2262 OnAddressBarKeypadWillOpen(*__pAddressbar);
2268 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2270 if(__pAddressbar != null)
2272 OnAddressBarKeypadOpened(*__pAddressbar);
2278 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2280 if (__pAddressbar != null)
2282 OnAddressBarKeypadClosed(*__pAddressbar);
2287 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2289 AppLog("KeypadBoundsChanged");
2290 RelayoutControls(false);
2294 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2295 const Tizen::Base::String& reason)
2297 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2301 MainForm::OnLoadingCompleted(void)
2303 AppLog("MainForm::OnLoadingCompleted start");
2305 result r = E_SUCCESS;
2307 if (__pWebViewer == null)
2312 if (__pAddressbar == null)
2316 if (__pWebViewer->CanGoForward())
2318 //__pAddressbar->SetForwardButtonEnabled(true);
2319 SetForwardButtonEnabled(true);
2323 //__pAddressbar->SetForwardButtonEnabled(false);
2324 SetForwardButtonEnabled(false);
2327 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2329 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2331 //__pAddressbar->UpdateProgress(0);
2335 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2337 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2341 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2342 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2343 if (isPrivateBrowsing == false)
2345 History* pHistory = new(std::nothrow) History;
2347 HistoryPresentationModel::GetCurrentDateTime(date);
2350 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2351 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2353 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2354 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2356 pHistory->SetVisitedTime(date);
2359 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2360 pHistory->SetFaviconId(id);*/
2362 if (__pWebViewer != null)
2364 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2366 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2367 if (pTempBitmap != null)
2369 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2370 pHistory->SetFavIconBitmap(*pTempBitmap);
2373 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2376 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2377 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2378 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2380 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2381 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2382 pHistory->SetThumbnail(pBitmap);
2384 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2387 pHistory->SetFavIconBitmap(*pFavIcon);
2391 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2398 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2400 // temperary fixed (webpage can be not loaded)
2403 AppLog("MainForm::OnLoadingCompleted done");
2407 MainForm::OnEstimatedProgress(int progress)
2409 AppLogDebug("MainForm::OnEstimatedProgress entered");
2410 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2411 progress = DEFAULT_PROGRESS_PERCENTAGE;
2413 // __pAddressbar->UpdateProgress(progress);
2414 UpdateProgress(progress);
2417 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2419 AppLog("MainForm::OnFaviconReceived");
2420 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2422 if (pFavIconBitmap != null)
2424 pFavIconBitmap->GetWidth();
2425 pFavIconBitmap->GetHeight();
2430 MainForm::OnUrlValueChanged(Addressbar&)
2436 MainForm::OnUrlSubmitted(Addressbar& addBar)
2438 AppLog("MainForm::OnUrlSubmitted");
2439 String url = addBar.GetUrl();
2440 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2442 __pFooterPanel->SetShowState(true);
2443 // __pAddressbar->SetShowState(false);
2444 // RelayoutControls(false);
2449 MainForm::LoadUrl(String& url)
2452 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2453 AppLogDebug("MainForm::LoadUrl enter");
2455 if (__pWebViewer != null)
2457 __pWebViewer->SetShowState(true);
2458 __pWebViewer->Invalidate(true);
2461 if (url.CompareTo(L"") == 0)
2465 if(__pFooterPanel != null)
2467 __pFooterPanel->SetShowState(true);
2468 __pFooterPanel->Invalidate(true);
2475 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2476 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)
2478 RegularExpression firstRegex;
2479 RegularExpression secondRegex;
2481 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2482 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2485 ret = firstRegex.Match(url, false); // This returns true value
2486 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2488 if (ret == true && __pWebViewer != null)
2490 __pWebViewer->LoadUrl(url);
2492 else if(__pWebViewer != null)
2494 String tempUrl = L"http://";
2495 tempUrl.Append(url);
2499 __pWebViewer->LoadUrl(tempUrl);
2503 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2504 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2507 if (__pAddressbar != null)
2509 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2510 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2513 AppLogDebug("MainForm::LoadUrl exit");
2520 MainForm::OnStopClicked(Addressbar& addBar)
2522 AppLogDebug("MainForm::OnStopClicked called");
2525 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2526 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2527 __pWebViewer->StopLoading();
2528 RequestRedraw(true);
2533 MainForm::OnReaderClicked(const Addressbar& addBar)
2535 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2537 CreateReaderPanel();
2538 AppLogDebug("MainScene::OnReaderClicked entered");
2541 /*if (__pArticleReaderPanel)
2543 AppLogDebug("showstate true for reader panel");
2544 __pArticleReaderPanel->SetShowState(true);
2545 __pArticleReaderPanel->Show();
2547 int xPos = __pArticleReaderPanel->GetX();
2548 int yPos = __pArticleReaderPanel->GetY();
2549 AppLog("OnReaderClicked() xPos = %d",xPos);
2550 AppLog("OnReaderClicked() yPos = %d",yPos);
2552 if (__pReaderData == null)
2557 String loadData = L"<html>\
2559 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2564 background-color: transparent;\
2583 <body style='width:'";
2584 loadData.Append(bodyWidth);
2585 loadData.Append(L"px'>");
2586 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2587 loadData.Append(*__pReaderData);
2588 loadData.Append(L"</body></html>");
2591 buf.Construct(loadData.GetLength());
2592 AppLogDebug("data->GetLength %d",loadData.GetLength());
2593 for (int z=0;z<loadData.GetLength();z++)
2596 loadData.GetCharAt(z,b);
2597 buf.SetByte((byte)b);
2601 if (__pWebReader != null)
2603 __pWebReader->LoadData(L"",buf,L"text/html");
2604 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2608 AppLogDebug("cannot LoadData __pWebReader is null");
2614 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2616 AppLog("MainForm::OnBackClicked");
2617 result r = E_FAILURE;
2619 if (__pWebViewer != null && __pWebViewer->CanGoBack())
2621 __pWebViewer->GoBack();
2626 pApp = UiApp::GetInstance();
2629 r = pApp->Terminate();
2639 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
2641 AppLog("MainForm::OnForwardClicked");
2642 if (__pWebViewer == null)
2645 if (__pWebViewer->CanGoForward())
2647 __pWebViewer->GoForward();
2652 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2654 result r = E_SUCCESS;
2655 // hiding the address bar
2656 __pAddressbar->SetShowState(false);
2657 __pFooterPanel->SetShowState(true);
2659 __pWebViewer->SetFocus();
2661 __pMostVisitedListView->SetFocus();
2662 __pFooterUrlField->SetFocusable(true);
2663 __pMoreButton->SetFocus();
2665 RelayoutControls(false);
2669 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
2671 __prevAddressBarMode = __curAddressBarMode;
2673 if (__pAddressbar != null)
2675 __curAddressBarMode = GetAddressbarMode();
2678 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
2680 __adressPanelPosition.y = 0;
2681 if (__pAddressbar != null)
2683 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2684 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2685 __pAddressbar->Invalidate(true);
2687 if (__pWebViewer != null)
2689 __pWebViewer->StopLoading();
2692 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
2694 __adressPanelPosition.y = 0;
2695 if (__pAddressbar != null)
2697 __webControlPosition.y = 0;
2698 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
2699 __pAddressbar->Invalidate(true);
2705 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
2708 __pAddressbar->SetShowState(false);
2710 __pFooterPanel->SetShowState(true);
2712 __pWebViewer->SetFocus();
2713 if(__pFooterUrlField)
2714 __pFooterUrlField->SetFocusable(true);
2715 RelayoutControls(false);
2719 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
2721 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
2723 __pAddressbar->SetShowState(false);
2727 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
2729 __pAddressbar->SetShowState(true);
2730 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2731 // __pAddressbar->SetAddressbarURLFocus();
2735 RelayoutControls(false);
2739 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
2741 __pFooterPanel->SetShowState(false);
2745 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
2747 AppLog("KeypadBoundsChanged");
2748 RelayoutControls(false);
2752 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
2756 __pWindowInfo->pageTitle = title;
2757 if (__pWebViewer != null)
2759 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2762 if (__pAddressbar != null && __pWebViewer != null)
2764 SetUrl(__pWebViewer->GetUrl());
2765 __pAddressbar->Invalidate(true);
2770 MainForm::UpdateFavicon(void)
2772 bool urlImageType = false;
2773 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();");
2774 Bitmap* pBitmap = null;
2776 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
2778 if (__pWindowInfo != null)
2781 url.SetUri(*tempPath);
2782 if (url.GetHost().GetLength() == 0)
2785 webUrl.SetUri(__pWebViewer->GetUrl());
2786 result r = url.SetHost(webUrl.GetHost());
2793 if (url.GetScheme().GetLength() == 0)
2796 webUrl.SetUri(__pWebViewer->GetUrl());
2797 url.SetScheme(webUrl.GetScheme());
2799 __pWindowInfo->faviconUrl = url.ToString();
2801 pBitmap = __pWebViewer->GetFaviconN();
2803 if (pBitmap != null)
2805 if (__pWindowInfo->pFavicon != NULL)
2807 __pWindowInfo->pFavicon = null;
2809 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
2810 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
2812 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2814 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2816 else if(__pWindowInfo->pFavicon != null)
2818 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2822 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
2823 if(pDefaultBmp != null)
2825 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
2834 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
2841 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
2842 Tizen::Web::Controls::WebNavigationType type)
2844 // when load new page if find word panel is open its show state is false
2845 ShowFindWordPanel(false);
2847 __pFooterPanel->Invalidate(true);
2850 uriInfo.SetUri(url);
2852 if(url.Contains(IDS_TIZEN_SERVICE))
2855 String delim(L":;");
2857 // Creates a StringTokenizer instance
2858 StringTokenizer strTok(url, delim);
2860 int count = strTok.GetTokenCount(); // count == 4
2862 HashMap *pMap = new HashMap();
2868 while (strTok.HasMoreTokens())
2870 AppLog("Token: %ls", token.GetPointer());
2871 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2872 if(token.Contains(IDS_APPID))
2874 token.SubString(6, appId);
2875 AppLog("AppID:%ls", appId.GetPointer());
2877 else if(token.Contains("="))
2879 String *pKey = new String();
2880 String *pValue = new String();
2882 token.IndexOf("=", 0, index);
2885 token.SubString(0, index, *pKey);
2886 token.SubString(index + 1, *pValue);
2887 pMap->Add(pKey, pValue);
2893 AppControl *pAppControl = null;
2894 String operationId = L"http://tizen.org/appcontrol/operation/main";
2895 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2898 result r = pAppControl->Start(null, null, pMap, null);
2902 AppLogException("AppControl not found");
2908 if ( __pAddressbar != null)
2910 __pAddressbar->SetShowState(false);
2911 __pAddressbar->Invalidate(true);
2917 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
2918 const Tizen::Net::Http::HttpHeader& httpHeader)
2920 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
2925 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
2927 AppLog("MainForm::OnWebPageBlockSelected");
2928 if (__pHitElementResult != null)
2930 delete __pHitElementResult;
2931 __pHitElementResult = null;
2934 if (__pWebViewer != null)
2936 AppLog("MainForm::OnWebPageBlockSelected web not null");
2937 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
2940 if (__pHitElementResult == null)
2945 if (__pHitElementResult->HasImage() != true)
2947 String tagName = __pHitElementResult->GetTagName();
2948 String type = __pHitElementResult->GetAttributeValue("type");
2950 __currentSelectedStr.Clear();
2951 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
2952 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
2953 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
2955 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
2957 AppLog("MainForm::OnWebPageBlockSelected show paste option");
2959 InitSelectTextContextMenu(endPoint,true);
2960 __pImageMenu->SetShowState(true);
2961 __pImageMenu->Show();
2962 __pImageMenu->Invalidate(true);
2964 else if(__isLongPressedDone == true)
2966 AppLog("MainForm::OnWebPageBlockSelected no paste option");
2968 if(__pHitElementResult->GetUrl().GetLength() > 0)
2970 __currentSelectedStr.Clear();
2971 __currentSelectedStr = __pHitElementResult->GetUrl();
2973 InitSelectTextContextMenu(endPoint,false);
2974 __pImageMenu->SetShowState(true);
2975 __pImageMenu->Show();
2976 __pImageMenu->Invalidate(true);
2979 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
2980 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
2981 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
2987 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
2993 MainForm::OnWebWindowCreateRequested(void)
2995 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
2997 if (pNewWindowInfo == null)
3001 result r = E_SUCCESS;
3002 SceneManager* pSceneManager = SceneManager::GetInstance();
3003 if (pSceneManager == NULL)
3007 ArrayList* pArgList = new(std::nothrow) ArrayList();
3008 if (pArgList == NULL)
3012 r = pArgList->Construct();
3015 pNewWindowInfo->isJavascriptInitiated = true;
3016 pArgList->Add(*pNewWindowInfo);
3017 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3021 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3028 return pNewWindowInfo->pCurrentWeb;
3032 MainForm::RelayoutControls(bool showAddressbar)
3034 __webControlPosition.y = 0;
3035 __webControlHeight = GetClientAreaBounds().height;
3036 AppLog("Client area height: %d", __webControlHeight);
3038 AppLog("Client area height: %d", __webControlHeight);
3039 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3041 __webControlPosition.y += __pAddressbar->GetHeight();
3042 __webControlHeight -= __pAddressbar->GetHeight();
3043 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3045 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3047 __webControlPosition.y += __pFindWordControl->GetHeight();
3048 __webControlHeight -= __pFindWordControl->GetHeight();
3049 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3052 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
3054 __webControlHeight -= __pFooterPanel->GetHeight();
3055 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3057 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3059 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3060 __pWebViewer->Invalidate(false);
3062 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3064 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3071 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3073 if (__pFindWordControl == null)
3079 InitFindWordPanel();
3080 __pFindWordEditField->SetText(__currentSearchStr);
3081 //__pFindWordCountLabel->SetText(L"");
3082 __pFindWordCountLabel->SetText(L"0/0");
3083 __pFindWordPanel->SetShowState(true);
3087 if(__pFindWordControl != null)
3089 __pFindWordControl->SetShowState(false);
3093 AppLog("MainForm::ShowFindWordPanel %d",show);
3094 if (show && !isTouchPressed)
3096 if (__pFindWordEditField)
3098 __pFindWordEditField->SetFocus();
3099 __pFindWordEditField->ShowKeypad();
3104 if (__pFindWordEditField)
3105 __pFindWordEditField->HideKeypad();
3108 RelayoutControls(false);
3112 MainForm::StartWordSearch()
3114 //Get the count of occurances of the word in the current page
3115 __maxOccurrances = 0;
3116 __currentWordIndex = 0;
3118 __pFindWordPrev->SetEnabled(false);
3119 String *pCountStr = null;
3120 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3121 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3122 if (pCountStr != null)
3124 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3128 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3133 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3135 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3136 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3138 if(totalCount == -1 || totalCount == 0)
3140 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),64,__pFindWordCountLabel->GetHeight());
3141 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3144 else if(totalCount > 100)
3146 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3147 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3150 __maxOccurrances = totalCount;
3151 __currentWordIndex = currentOrdinal;
3153 //Reset the UI controls as per the maxOccurrance value
3154 if (totalCount <= 0)
3156 AppLog("Word not found");
3157 //Show error notification to user
3158 __pFindWordNext->SetEnabled(false);
3159 __pFindWordCountLabel->SetText(L"0/0");
3160 __pFindWordNext->Invalidate(false);
3161 __pFindWordPrev->Invalidate(false);
3162 __pFindWordCountLabel->Invalidate(false);
3166 if (totalCount == 1)
3168 __pFindWordNext->SetEnabled(false);
3172 __pFindWordNext->SetEnabled(true);
3175 String countStr = L"";
3176 countStr.Append(__currentWordIndex);
3177 countStr.Append(L"/");
3178 countStr.Append(__maxOccurrances);
3179 __pFindWordCountLabel->SetText(countStr);
3180 // __pFindWordCountLabel->SetShowState(true);
3181 __pFindWordCountLabel->Invalidate(false);
3183 //FindNextWord(true);
3184 //Update the controls
3185 __pFindWordNext->Invalidate(false);
3186 __pFindWordPrev->Invalidate(false);
3187 __pFindWordCountLabel->Invalidate(false);
3191 MainForm::FindNextWord(bool next)
3195 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3197 if(__currentWordIndex < __maxOccurrances)
3199 __currentWordIndex++;
3205 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3207 if(__currentWordIndex > 1)
3209 __currentWordIndex--;
3214 String countStr = L"";
3215 countStr.Append(__currentWordIndex);
3216 countStr.Append(L"/");
3217 countStr.Append(__maxOccurrances);
3218 __pFindWordCountLabel->SetText(countStr);
3219 // __pFindWordCountLabel->SetShowState(true);
3220 __pFindWordCountLabel->Invalidate(false);
3221 if (__currentWordIndex >= __maxOccurrances)
3223 __pFindWordNext->SetEnabled(false);
3227 __pFindWordNext->SetEnabled(true);
3229 if (__currentWordIndex <= 1)
3231 __pFindWordPrev->SetEnabled(false);
3235 __pFindWordPrev->SetEnabled(true);
3237 __pFindWordPrev->Invalidate(false);
3238 __pFindWordNext->Invalidate(false);
3239 __pFindWordCountLabel->Invalidate(false);
3240 __pFindWordPanel->Invalidate(true);
3243 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3245 AppLog("MainForm::OnWebKeypadWillOpen");
3246 // OnAddressBarKeypadOpened(*__pAddressbar);
3250 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3253 if (__pWebViewer != null && __pFooterPanel != null)
3255 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3256 if(__pAddressbar != null)
3258 __pAddressbar->SetShowState(false);
3260 if(__pFindWordControl != null)
3262 __pFindWordControl->SetShowState(false);
3264 __pFooterPanel->SetShowState(false);
3265 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3271 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3273 __pFooterPanel->SetShowState(true);
3274 OnAddressBarKeypadClosed(*__pAddressbar);
3278 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3280 Control* temp = const_cast< Control* >(&source);
3281 Header* pHeader = dynamic_cast< Header* >(temp);
3282 if (pHeader != null)
3284 //Header double - clicked
3285 AppLog("Header double clicked");
3287 if(__pFindWordPanel)
3289 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3290 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3294 AppLog("MainScene::OnTouchDoublePressed");
3295 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3296 if (isReaderEnabled == true)
3300 delete __pReaderData;
3301 __pReaderData = null;
3303 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3304 filePath.Append(L"data/reader.js");
3310 result r = E_SUCCESS;
3311 FileAttributes attr;
3313 File::GetAttributes(filePath,attr);
3315 r = file.Construct(filePath, L"r+");
3318 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3321 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3324 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3327 file.Read(pScript,attr.GetFileSize());
3329 AppLogDebug("scipt length %d",strlen(pScript));
3330 String strScript = L"";
3331 strScript.Append(pScript);
3332 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3335 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3338 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3339 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3341 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3342 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3348 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3350 AppLog("MainForm::OnTouchLongPressed");
3352 if (__pHitElementResult != null)
3354 delete __pHitElementResult;
3355 __pHitElementResult = null;
3358 if (__pWebViewer != null)
3360 AppLog("MainForm::OnTouchLongPressed web not null");
3361 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3364 if (__pHitElementResult == null)
3369 if (__pHitElementResult->HasImage() == true)
3371 InitImageContextMenu(currentPosition);
3372 __pImageMenu->SetShowState(true);
3373 __pImageMenu->Show();
3374 __pImageMenu->Invalidate(true);
3378 String tagName = __pHitElementResult->GetTagName();
3379 String type = __pHitElementResult->GetAttributeValue("type");
3380 String value = __pHitElementResult->GetAttributeValue(L"value");
3381 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3383 __currentSelectedStr.Clear();
3384 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3386 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0)
3388 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3390 InitSelectTextContextMenu(currentPosition,true, true);
3391 __pImageMenu->SetShowState(true);
3392 __pImageMenu->Show();
3393 __pImageMenu->Invalidate(true);
3395 __isLongPressedDone = true;
3396 __pWebViewer->SetBlockSelectionPosition(currentPosition);
3399 __inputEventToBeSupressed = true;
3403 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3405 AppLog("MainForm::OnTouchReleased");
3407 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3408 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3410 __pWebViewer->ConsumeInputEvent();
3412 if(pHitElement != null)
3416 __inputEventToBeSupressed = false;
3420 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3422 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3423 int widthContextItem = 0;
3424 if(__pFindWordPanel != null)
3425 ShowFindWordPanel(__pFindWordPanel->GetShowState(), false);
3426 if ( __pFooterLabel != null)
3428 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3431 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3436 if (__pFindWordBgLabel != null)
3438 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3439 if (pBitmap != null)
3441 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3447 __pMenu->SetShowState(false);
3448 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3450 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3454 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3459 AppLog("__pFooterPanel->GetShowState() is true");
3461 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3462 __pFooterPanel->Invalidate(true);
3466 if(__pMoreButton && __pMenu)
3468 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3469 __pMenu->SetAnchorPosition(p);
3470 __pMenu->Invalidate(true);
3473 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3474 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3476 InitMostVisitedSitesView(orientationStatus);
3479 RelayoutControls(false);
3480 if (__pArticleReaderPanel != null)
3482 if (__pArticleReaderPanel->GetShowState() == true)
3484 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3486 if (__pBlankPanel != null)
3487 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3489 if (__pWebReader != null)
3491 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3493 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3494 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3496 if ( pBitmap != null && pSrcBitmap != null)
3498 AppLog("CreateReaderPanel ninepatchbitmap found");
3499 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3502 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3503 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3504 if (pBitmap != null)
3509 if (pSrcBitmap != null)
3518 if (__pAddressbar != null)
3520 int width = GetClientAreaBounds().width;
3521 __pAddressbar->OrientationChanged(width);
3526 MainForm::OnSettingsChange(int settingvalue)
3528 AppLogDebug("MainForm::OnSettingsChange entered");
3529 if (__pWebViewer == null)
3531 AppLogDebug("Webviewer is not initialized yet.");
3534 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3536 WebSetting settings = __pWebViewer->GetSetting();
3537 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3539 settings.SetAutoFittingEnabled(true);
3541 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3543 settings.SetAutoFittingEnabled(false);
3545 __pWebViewer->SetSetting(settings);
3547 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
3549 WebSetting settings = __pWebViewer->GetSetting();
3550 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
3551 __pWebViewer->SetSetting(settings);
3553 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
3555 WebSetting settings = __pWebViewer->GetSetting();
3556 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
3557 __pWebViewer->SetSetting(settings);
3559 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
3561 WebSetting settings = __pWebViewer->GetSetting();
3562 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
3563 __pWebViewer->SetSetting(settings);
3565 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
3569 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3573 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
3575 WebSetting settings = __pWebViewer->GetSetting();
3576 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
3578 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
3582 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
3584 __pWebViewer->SetSetting(settings);
3586 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
3590 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
3591 WebSetting settings = __pWebReader->GetSetting();
3592 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
3593 __pWebReader->SetSetting(settings);
3599 MainForm::OnSettingsReset()
3603 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3604 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
3609 MainForm::OnClearCache()
3611 result r = E_SUCCESS;
3613 if (__pWebViewer != NULL)
3615 r = __pWebViewer->ClearCache();
3618 AppLogDebug("Cache cleared success");
3622 AppLogDebug("Cache cleared fail");
3628 MainForm::OnClearCookie()
3630 result r = E_SUCCESS;
3632 if (__pWebViewer != NULL)
3634 __pWebViewer->ClearCookie();
3638 AppLogDebug("Cookie cleared success");
3642 AppLogDebug("Cache cleared fail");
3647 MainForm::findDistance(int x1,int y1,int x2, int y2)
3649 int deltaX = Math::Abs(x2 - x1);
3650 int deltaY = Math::Abs(y2 - y1);
3651 double num = deltaX*deltaX + deltaY*deltaY;
3657 for (i = 0; i < 20; i++)
3659 x = (((x*x)+ num)/(2*x));
3670 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3672 if(__pFindWordPanel)
3674 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3675 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3677 __isLongPressedDone = false;
3680 IList* pList = null;
3681 pList = touch.GetTouchInfoListN(source);
3685 int count = pList->GetCount();
3688 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3689 __touchPoint1 = pTouchInfo->position;
3691 /*if (__pAddressbar != null)
3693 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3695 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3697 __pAddressbar->SaveAddressbarEditText();
3699 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3702 __pAddressbar->Invalidate(true);
3704 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3706 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3708 //__pAddressbar->SaveAddressbarEditText();
3710 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3713 else if (count == 2)
3715 AppLogDebug("MainForm::OnTouchPressed count is two");
3716 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3717 __touchPoint1 = pTouchInfo->position;
3719 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3720 __touchPoint2 = pTouchInfo->position;
3726 pList->RemoveAll(true);
3733 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3735 __currentWordIndex = 0;
3736 __isLongPressedDone = false;
3741 MainForm::MoveUiControls()
3746 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
3748 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
3750 if(__pFooterUrlField->GetTextLength() == 0)
3752 __pFooterUrlField->SetKeypadActionEnabled(false);
3756 __pFooterUrlField->SetKeypadActionEnabled(true);
3759 if (__pFindWordEditField != null)
3761 __currentSearchStr = __pFindWordEditField->GetText();
3762 __pFindWordNext->SetEnabled(false);
3763 __pFindWordPrev->SetEnabled(false);
3764 __pFindWordNext->Invalidate(true);
3765 __pFindWordPrev->Invalidate(true);
3766 __pFindWordCountLabel->SetText(L"0/0");
3767 __pFindWordCountLabel->Invalidate(true);
3769 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
3770 if (__currentSearchStr.GetLength() > 0)
3776 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
3778 AppLogDebug("Enter something");
3783 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
3790 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
3792 if(__pWebViewer != null)
3795 AppLog("MainForm::InitMostVisitedSitesView");
3796 result r = E_SUCCESS;
3799 if (__pWebViewer != null && __pMostVisitedListView != null)
3804 if (__pMostVisitedListView != null)
3806 RemoveControl(*__pMostVisitedListView);
3808 if(__pMostVisitedSites != null)
3810 __pMostVisitedSites->RemoveAll(true);
3813 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
3815 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
3816 __pMostVisitedListView = new(std::nothrow) ListView();
3818 int height = GetClientAreaBounds().height;
3820 if(__pFooterPanel->GetShowState() == true)
3822 height = height - __pFooterPanel->GetHeight();
3824 if(__pAddressbar->GetShowState() == true)
3826 height -= __pAddressbar->GetHeight();
3829 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
3833 delete __pMostVisitedListView;
3834 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
3837 __pMostVisitedListView->SetItemProvider(*this);
3838 __pMostVisitedListView->AddListViewItemEventListener(*this);
3839 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
3840 AddControl(*__pMostVisitedListView);
3841 __pMostVisitedListView->UpdateList();
3848 MainForm::GetImagePath(void)
3852 String formattedTime;
3853 DateTime currentTime;
3854 LocaleManager localManager;
3855 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
3857 localManager.Construct();
3858 Locale locale = localManager.GetSystemLocale();
3859 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
3861 // Get date formatter
3862 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
3866 pTimeFormatter->Format(currentTime, formattedTime);
3869 AppLog("current time stamp is %ls", formattedTime.GetPointer());
3870 String delim(L" :");
3871 StringTokenizer strTok(formattedTime, delim);
3874 String str1("GMT+00");
3875 while (strTok.HasMoreTokens())
3877 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
3878 if(token.Equals(str1))
3880 AppLog("token is %ls", token.GetPointer());
3881 imageName.Append(token);
3887 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
3889 result r = E_FAILURE;
3890 AppLog("Content manager 1");
3891 ContentId contentId;
3892 ContentManager contentManager;
3893 r = contentManager.Construct();
3896 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
3899 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
3900 contentPath.Append(imageName);
3901 contentPath.Append(".jpg");
3902 contentId = contentManager.CreateContent(*aBuffer, contentPath);
3903 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
3907 MainForm::SetForwardButtonEnabled(bool isEnabled)
3909 __pGoForwardBtn->SetEnabled(isEnabled);
3910 __pGoBackBtn->Invalidate(true);
3914 MainForm::SetBackButtonEnabled(bool isEnabled)
3916 __pGoBackBtn->SetEnabled(isEnabled);
3917 __pGoBackBtn->Invalidate(true);
3921 MainForm::UpdateProgress(int percentage)
3923 __progressPercentage = percentage;
3924 if (percentage == 0 || percentage == 100)
3926 __isLoadingData = false;
3927 if (percentage == 100)
3929 __isLoadingCompleted = true;
3930 __progressPercentage = 0;
3934 __isLoadingCompleted = false;
3939 __isLoadingData = true;
3941 UpdateProgressBitmap();
3945 MainForm::GetProgress(void)
3947 return __progressPercentage;
3951 MainForm::UpdateProgressBitmap(void)
3953 result r = E_SUCCESS;
3954 if (__pProgressbarLabel == null)
3956 int w = __pProgressbarLabel->GetWidth();
3957 int h = __pProgressbarLabel->GetHeight();
3959 int progressWidth = 0;
3960 Bitmap* pRetBitmap = null;
3962 if (__progressPercentage == 0 || __progressPercentage == 100)
3964 __pProgressbarLabel->SetShowState(false);
3965 __pProgressbarLabel->Invalidate(false);
3970 __pProgressbarLabel->SetShowState(true);
3971 __pProgressbarLabel->Invalidate(false);
3974 r = canvas.Construct(Rectangle(0, 0, w, h));
3978 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
3983 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
3987 pBgBmp->Scale(Dimension(w, h));
3988 canvas.DrawBitmap(Point(0,0), *pBgBmp);
3992 progressWidth = (double) (w) * __progressPercentage / 100;
3993 AppLogDebug("progressWidth: %d", progressWidth);
3994 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
3996 if (pProgressBmp != null)
3998 pProgressBmp->Scale(Dimension(progressWidth, h));
3999 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4000 delete pProgressBmp;
4003 pRetBitmap = new (std::nothrow) Bitmap();
4005 if (pRetBitmap == null)
4007 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4011 pRetBitmap->Construct(canvas, canvas.GetBounds());
4013 if (__pProgressbarLabel != null && pRetBitmap != null)
4015 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4016 __pProgressbarLabel->Invalidate(false);
4019 if (pRetBitmap != null)
4027 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4029 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4031 __currentAddMode = addMode;
4035 case ADDRESSBAR_MODE_INVALID:
4040 case ADDRESSBAR_MODE_READER:
4042 __pStopBtn->SetShowState(false);
4043 __pClearBtn->SetShowState(false);
4046 case ADDRESSBAR_MODE_LOADING:
4048 __pRefreshBtn->SetShowState(false);
4049 __pStopBtn->SetShowState(true);
4050 __pClearBtn->SetShowState(false);
4053 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4055 // SetUrl(__pAddressbar->GetUrl());
4057 __pRefreshBtn->SetShowState(true);
4058 __pStopBtn->SetShowState(false);
4059 __pClearBtn->SetShowState(false);
4062 case ADDRESSBAR_MODE_EDIT:
4064 __pRefreshBtn->SetShowState(false);
4065 __pStopBtn->SetShowState(false);
4066 __pClearBtn->SetShowState(true);
4073 OnAddressBarModeChanged();
4076 AddressBarMode MainForm::GetAddressbarMode(void)
4078 return __currentAddMode;
4081 void MainForm::SetUrl(const String& url)
4085 if (__pFooterUrlField != NULL)
4087 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4088 if (removedHttpUrl.IsEmpty() == false)
4090 __pFooterUrlField->SetText(removedHttpUrl);
4091 __pAddressbar->SetUrl(__displayUrl);
4095 __pFooterUrlField->SetText(__displayUrl);
4096 __pAddressbar->SetUrl(__displayUrl);
4099 __pFooterUrlField->Invalidate(false);
4100 __pAddressbar->Invalidate(true);
4101 __pFooterUrlField->SetCursorPosition(0);
4106 MainForm::RemoveHttpTextFromDisplayURL(void)
4108 bool isHttpText = __displayUrl.Contains(L"http://");
4109 String updatedDisplayUrl;
4110 updatedDisplayUrl.Clear();
4112 if (isHttpText == true)
4114 __displayUrl.SubString(7,updatedDisplayUrl);
4116 return updatedDisplayUrl;