2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (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;
96 const int IDA_PRINT_CLICKED = 122;
98 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
99 const int IDA_FINDWORD_NEXT_CLICKED = 202;
100 const int IDA_FINDWORD_PREV_CLICKED = 203;
101 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
102 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
104 const int IDA_COPY_IMAGE_CLICKED = 206;
105 const int IDA_VIEW_IMAGE_CLICKED = 207;
106 const int IDA_SAVE_IMAGE_CLICKED = 208;
107 const int IDA_SHARE_IMAGE_CLICKED = 209;
109 const int IDA_COPY_TEXT_CLICKED = 210;
110 const int IDA_PASTE_TEXT_CLICKED = 211;
111 const int IDA_FIND_TEXT__CLICKED = 212;
112 const int IDA_SHARE_TEXT_CLICKED = 213;
114 const int IDA_GO_BACK = 214;
115 const int IDA_GO_FORWARD = 215;
116 const int IDA_REFRESH_BTN_CLICKED = 216;
117 const int IDA_STOP_BTN_CLICKED = 217;
118 const int IDA_CLEAR_URL = 218;
120 const int IDA_HYPERLINK_OPEN_CLICKED = 219;
121 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 220;
122 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
123 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
125 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
127 const int MainForm::IDA_FORMAT_BITMAP = 500;
128 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
129 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
130 const int MainForm::IDA_FORMAT_URL_STRING = 503;
131 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
133 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
134 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
135 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
137 MainForm::MainForm(void)
139 __isLongPressedDone = false;
141 __pAddressbar = null;
142 // __pMostVisitedSitesPanel = null;
143 __pMostVisitedListView = null;
144 __pFooterPanel = null;
145 __pHitElementResult = null;
146 __pWindowInfo = null;
150 __pFindWordControl = null;
152 __pFindWordBgLabel = null;
153 __pFindWordEditField = null;
154 __pFindWordClear = null;
155 __pFindWordCountLabel = null;
156 __pFindWordNext = null;
157 __pFindWordPrev = null;
158 __previousZoomLevel = 1.0;
160 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
163 __currentSearchStr = L"";
164 __currentSelectedStr = L"";
165 __maxOccurrances = 0;
166 __currentWordIndex = 0;
169 __inputEventToBeSupressed = false;
170 __isLoadingData = false;
171 __isLoadingCompleted = false;
172 __progressPercentage = 0;
173 __touchPoint1 = Point(-1,-1);
174 __touchPoint2 = Point(-1,-1);
176 // __pReaderPopup = null;
177 __pReaderData = null;
179 __pReaderCloseBtn = null;
180 //__pNewWindowButton = null;
181 __pMoreButton = null;
182 __pMultiWindowButton = null;
183 __pArticleReaderPanel = null;
184 __pBlankPanel = null;
185 __pArticleReaderLabel = null;
186 __webControlHeight = 0;
187 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
188 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
189 __pMostVisitedSites = null;
190 __pFooterUrlField = null;
192 __pGoForwardBtn = null;
193 __pRefreshBtn = null;
194 __pProgressbarLabel = null;
195 __pFooterLabel = null;
198 __isWebKeypadOpened = false;
201 MainForm::~MainForm(void)
203 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
207 __pAddressbar->SetAddressbarEventListener(null);
210 if(__pHistory != null)
216 if (__pReaderData != null)
218 delete __pReaderData;
219 __pReaderData = null;
222 if (__pPopUp != null)
228 if (__pHitElementResult != null)
230 delete __pHitElementResult;
231 __pHitElementResult = null;
234 String* pSelectedScene = NULL;
235 Object* pValue = NULL;
236 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
237 pSelectedScene = (String*) pValue;
239 /*if (pSelectedScene != null)
241 delete pSelectedScene;
243 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
247 MainForm::Initialize(void)
249 Construct(L"IDL_FORM");
254 MainForm::OnInitializing(void)
256 AppLog("get client area width = %d",GetClientAreaBounds().width);
257 AppLog("get client area height = %d",GetClientAreaBounds().height);
258 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
259 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
261 Panel* pFooterPanel = null;
263 __pSaveImage = new Image();
264 __pSaveImage->Construct();
266 // Setup back event listener
267 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
268 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
269 AddOrientationEventListener(*this);
270 AppLogDebug(" MainForm::OnInitializing ended");
271 if (__pMostVisitedSites == null)
273 __pMostVisitedSites = new(std::nothrow) ArrayList();
274 __pMostVisitedSites->Construct();
276 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
278 __pItemContext= new(std::nothrow) ListContextItem();
279 __pItemContext->Construct();
280 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
281 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
283 if (pBitmapNormal != null && pBitmapPressed != null)
285 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
288 if (pBitmapNormal != null)
290 delete pBitmapNormal;
293 if (pBitmapPressed != null)
295 delete pBitmapPressed;
298 __pItemContextLandscape= new(std::nothrow) ListContextItem();
299 __pItemContextLandscape->Construct();
300 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
301 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
303 if (pBitmapNormal != null && pBitmapPressed != null)
305 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
308 if (pBitmapNormal != null)
310 delete pBitmapNormal;
313 if (pBitmapPressed != null)
315 delete pBitmapPressed;
322 MainForm::InitAddressbar(void)
324 AppLogDebug("MainForm::InitAddressbar entered");
326 result r = E_SUCCESS;
328 if (__pAddressbar != null)
332 __pAddressbar = new(std::nothrow) Addressbar();
333 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
334 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
337 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
340 __pAddressbar->SetAddressbarEventListener(this);
341 AddControl(__pAddressbar);
342 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
343 SetControlAlwaysOnTop(*__pAddressbar, true);
344 __adressPanelPosition = __pAddressbar->GetPosition();
346 AppLogDebug("MainForm::InitAddressbar exit");
352 MainForm::CreateReaderPanel(void)
354 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
355 result r = E_FAILURE;
357 Button *pSmallFontBtn = null;
358 Button *pLargeFontBtn = null;
360 __pBlankPanel = new (std::nothrow) Panel();
361 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
363 __pArticleReaderPanel = new (std::nothrow) Panel();
364 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
366 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
367 if (__pReaderCloseBtn)
369 AppLogDebug("CreateReaderPanel() 6");
370 __pReaderCloseBtn->AddActionEventListener(*this);
371 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
374 __pWebReader = new (std::nothrow) Web();
375 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
377 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
378 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
380 r = __pWebReader->SetSetting(settings);
382 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
385 __pArticleReaderLabel = new Label();
386 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
388 __pBlankPanel->AddControl(__pArticleReaderLabel);
389 __pBlankPanel->AddControl(__pArticleReaderPanel);
390 AddControl(__pBlankPanel);
392 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
393 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
394 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
396 __pArticleReaderPanel->AddControl(__pWebReader);
397 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
398 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
399 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
401 if (pBitmap != null && pSrcBitmap != null)
403 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
405 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
407 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
410 pSmallFontBtn->AddActionEventListener(*this);
411 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
414 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
417 pLargeFontBtn->AddActionEventListener(*this);
418 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
427 if (pSrcBitmap != null)
433 SetControlAlwaysOnTop(*__pBlankPanel, true);
434 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
441 MainForm::InitWebControl()
443 AppLogDebug("MainForm::InitWebControl enter");
444 result r = E_SUCCESS;
445 AppLogDebug("InitWebControl");
447 if (__pAddressbar == null || __pFooterPanel == null)
450 const int Y_WEBCONTROL_POSITION = 0;
451 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
452 if (__pMostVisitedListView)
454 __pMostVisitedListView->SetShowState(false);
456 if (__pWebViewer != null)
458 AppLogDebug("Already initialized");
461 __pWebViewer = new(std::nothrow) Web();
462 if(__pWebViewer == NULL)
464 AppLogDebug("Initialization failed");
467 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
471 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
478 r = AddControl(__pWebViewer);
484 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
487 __webControlPosition = __pWebViewer->GetPosition();
488 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
491 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
495 __pWebViewer->SetLoadingListener(this);
496 __pWebViewer->SetWebUiEventListener(this);
497 __pWebViewer->SetWebKeypadEventListener(this);
498 __pWebViewer->SetFocus();
499 __pWebViewer->AddTouchEventListener(*this);
501 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
502 __pWebViewer->SetTextSearchListener(this);
505 AppLogDebug("MainForm :before return");
507 AppLogDebug("MainForm::InitWebControl Exit");
513 MainForm::OnFocusGained(const Control& source)
515 AppLog("MainForm::OnFocusGained");
519 MainForm::OnFocusLost(const Control& source)
521 AppLog("MainForm::OnFocusLost");
525 MainForm::SetJavascriptEnabled()
527 WebSetting settings = __pWebViewer->GetSetting();
528 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
529 __pWebViewer->SetSetting(settings);
533 MainForm::SetImageLoadEnabled()
535 WebSetting settings = __pWebViewer->GetSetting();
536 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
537 __pWebViewer->SetSetting(settings);
541 MainForm::InitFooter(void)
543 AppLogDebug("MainForm::InitFooter entered");
544 Button* pBackButton = null;
545 Button* pBookmarkButton = null;
546 Button* pMultiWindowButton = null;
547 Bitmap *pIconBitmap = null;
548 Bitmap *pBGBitmap = null;
549 Label *pBGLabel = null;
551 if (__pFooterPanel == null)
553 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
556 if (__pFooterPanel == null)
561 SetControlAlwaysOnTop(*__pFooterPanel, true);
563 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
564 if ( __pFooterLabel == NULL )
568 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
569 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
572 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
576 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
578 if ( __pMultiWindowButton == NULL )
583 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
585 if ( __pMoreButton == NULL )
590 if (__pMultiWindowButton != null)
592 Bitmap* pBitmap = null;
593 Bitmap* pPressedBitmap = null;
594 String imagePath = "I01_toolbar_icon_windows_manager_0";
595 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
596 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
597 imagePath.Append(totalCount);
598 imagePath.Append(".png");
600 pressedImagePath.Append(totalCount);
601 pressedImagePath.Append("_press.png");
603 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
604 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
605 if ( pBitmap == null )
610 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
613 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
614 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
619 __pMultiWindowButton->AddActionEventListener(*this);
620 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
625 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
626 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
629 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
630 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
631 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
635 __pMoreButton->AddActionEventListener(*this);
636 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
639 //Add the editfield for url
640 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
641 if (__pFooterUrlField == NULL)
643 return E_INVALID_KEY;
646 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
647 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
648 //__pFooterUrlField->AddFocusEventListener(*this);
649 __pFooterUrlField->AddKeypadEventListener(*this);
650 //__pFooterUrlField->AddFocusEventListener(*this);
651 __pFooterUrlField->SetPropagatedTouchEventListener(this);
653 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
655 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
657 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
659 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
663 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
664 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
668 //Add the go Back Button
669 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
670 if (__pGoBackBtn == NULL)
672 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
673 return E_INVALID_KEY;
675 __pGoBackBtn->SetActionId(IDA_GO_BACK);
676 __pGoBackBtn->AddActionEventListener(*this);
678 //Add the go forward Button
679 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
680 if (__pGoForwardBtn == NULL)
682 AppLogDebug("Control not found returning E_INVALID_KEY");
683 return E_INVALID_KEY;
685 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
686 __pGoForwardBtn->AddActionEventListener(*this);
687 // __pGoForwardBtn->SetEnabled(false);
688 if (__pWebViewer && __pWebViewer->CanGoForward())
690 //__pAddressbar->SetForwardButtonEnabled(true);
691 SetForwardButtonEnabled(true);
695 //__pAddressbar->SetForwardButtonEnabled(false);
696 SetForwardButtonEnabled(false);
699 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
700 if (__pRefreshBtn == NULL)
702 AppLogDebug("Control not found returning E_INVALID_KEY");
703 return E_INVALID_KEY;
706 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
707 __pRefreshBtn->AddActionEventListener(*this);
708 __pRefreshBtn->SetShowState(true);
710 //Add the backround label for displaying progressbar
711 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
712 if (__pProgressbarLabel == NULL)
714 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
715 return E_INVALID_KEY;
717 __pProgressbarLabel->SetShowState(false);
719 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
720 if (__pStopBtn == NULL)
722 AppLogDebug("Control not found returning E_INVALID_KEY");
723 return E_INVALID_KEY;
725 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
726 __pStopBtn->AddActionEventListener(*this);
727 __pStopBtn->SetShowState(false);
729 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
730 if (__pClearBtn == NULL)
732 AppLogDebug("Control not found returning E_INVALID_KEY");
733 return E_INVALID_KEY;
735 __pClearBtn->SetActionId(IDA_CLEAR_URL);
736 __pClearBtn->AddActionEventListener(*this);
737 __pClearBtn->SetShowState(false);
739 // __pFooterPanel->Invalidate(true);
740 AppLogDebug("MainForm::InitFooter exit");
746 MainForm::InitContextMenu(Point& p)
748 result r = E_SUCCESS;
749 bool isPrivateBrowsing = false;
750 Bitmap* pBitmap = null;
754 __pMenu->SetAnchorPosition(p);
755 __pMenu->Invalidate(true);
759 __pMenu = new(std::nothrow) ContextMenu();
760 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
761 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
763 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
766 if (isPrivateBrowsing == true)
768 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
772 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
775 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
777 if ( pBitmap != NULL)
779 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
782 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
783 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
784 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
787 __pMenu->SetMaxVisibleItemsCount(6);
788 __pMenu->SetShowState(false);
789 __pMenu->AddActionEventListener(*this);
790 SetControlAlwaysOnTop(*__pMenu, true);
796 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
798 result r = E_SUCCESS;
799 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
801 AppLog("MainForm::InitImageContextMenu clicked on image");
802 if (__pImageMenu != null)
808 // p.y = p.y + __pAddressbar->GetHeight() + 12;
809 // AppLog("vinaypy %d",p.y);
812 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
816 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
818 __pImageMenu = new (std::nothrow) ContextMenu();
819 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
820 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
822 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
823 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
824 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
825 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
826 __pImageMenu->SetMaxVisibleItemsCount(4);
827 __pImageMenu->AddActionEventListener(*this);
828 SetControlAlwaysOnTop(*__pImageMenu, true);
834 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
836 result r = E_SUCCESS;
837 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
839 AppLog("MainForm::InitImageContextMenu clicked on image");
840 if (__pImageMenu != null)
846 p.y = p.y + __pAddressbar->GetHeight();
849 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
853 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
855 __pImageMenu = new (std::nothrow) ContextMenu();
856 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
857 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
859 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
860 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
861 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
862 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
864 __pImageMenu->SetMaxVisibleItemsCount(3);
865 __pImageMenu->AddActionEventListener(*this);
866 SetControlAlwaysOnTop(*__pImageMenu, true);
873 MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
875 result r = E_SUCCESS;
876 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
877 if(onlyPasteOption == true)
880 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
881 if (__pImageMenu != null)
886 // p.y = p.y + __pAddressbar->GetHeight() + 12;
891 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
896 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
898 __pImageMenu = new (std::nothrow) ContextMenu();
899 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
900 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
902 if(onlyPasteOption == false)
904 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
906 if (pasteOption || onlyPasteOption)
908 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
910 if(onlyPasteOption == false)
912 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
913 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
916 __pImageMenu->SetMaxVisibleItemsCount(3);
917 __pImageMenu->AddActionEventListener(*this);
918 SetControlAlwaysOnTop(*__pImageMenu, true);
925 MainForm::InitFindWordPanel(void)
927 result r = E_SUCCESS;
928 Bitmap *pIconBitmap = null;
930 if (__pFindWordControl != null)
932 AppLogDebug("Findword panel already initialized");
933 if (__pFindWordBgLabel != null)
935 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
938 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
945 __pFindWordControl = new (std::nothrow) Panel();
946 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
949 AppLogException("There is some problem in the xml file. Please check.");
952 AddControl(__pFindWordControl);
953 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
954 SetControlAlwaysOnTop(*__pFindWordControl,true);
955 __pFindWordControl->SetShowState(false);
956 __pFindWordControl->Invalidate(false);
958 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
959 if (__pFindWordBgLabel != null)
961 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
962 Rectangle pRect = pPanel1->GetBounds();
963 pRect.x = pRect.y = 0;
964 __pFindWordBgLabel->SetBounds(pRect);
965 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
968 AppLogDebug("InitFindWordPanel: Coming here");
969 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
974 AppLogDebug("InitFindWordPanel: shouldn't Come here");
978 Button* pfindWordCancel = null;
979 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
980 if (pfindWordCancel == null)
982 AppLogException("There is some problem in the xml file. Please check.");
985 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
986 pfindWordCancel->AddActionEventListener(*this);
988 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
989 if (__pFindWordClear == null)
991 AppLogException("There is some problem in the xml file. Please check.");
995 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
996 __pFindWordClear->AddActionEventListener(*this);
998 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
999 if (__pFindWordNext == null)
1001 AppLogException("There is some problem in the xml file. Please check.");
1005 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1006 __pFindWordNext->AddActionEventListener(*this);
1008 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1009 if (__pFindWordPrev == null)
1011 AppLogException("There is some problem in the xml file. Please check.");
1015 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1016 __pFindWordPrev->AddActionEventListener(*this);
1018 __pFindWordNext->SetEnabled(false);
1019 __pFindWordPrev->SetEnabled(false);
1021 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1022 if (__pFindWordCountLabel == null)
1024 AppLogException("There is some problem in the xml file. Please check.");
1028 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1029 if (__pFindWordEditField == null)
1031 AppLogException("There is some problem in the xml file. Please check.");
1034 __pFindWordEditField->AddTextEventListener(*this);
1035 __pFindWordEditField->AddKeypadEventListener(*this);
1036 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1042 MainForm::CreateItem (int index, int itemWidth)
1044 Rectangle listImageRect;
1045 Rectangle pagetTitleRect;
1046 Rectangle pageURLRect;
1047 Rectangle deleteImageRect;
1048 String pageTitle(L"");
1049 String pageURL(L"");
1050 result r = E_SUCCESS;
1051 Bitmap* pListIconImage = null;
1054 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1055 if(pHistory == null)
1059 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1060 if ( pAppResource == NULL )
1064 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1066 CustomItem* pItem = new(std::nothrow) CustomItem();
1067 pageTitle = pHistory->GetHistoryTitle();
1068 pageURL = pHistory->GetHistoryUrl();
1070 if (pageURL.GetLength() == 0)
1073 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1074 pageURL = L"<"+ nourl +">";
1078 Rectangle screenBounds = GetBounds();
1081 r = pItem->Construct(Dimension(itemWidth, 128), style);
1090 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1092 if ( pBitmap != NULL)
1094 pListIconImage = new Bitmap();
1095 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1099 if(pListIconImage == null)
1101 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1104 if ( pListIconImage != NULL)
1106 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1107 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1108 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1111 if (pItem != null && pListIconImage != NULL)
1113 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1117 if (pageTitle.CompareTo(L"") != 0)
1121 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1125 if (pageURL.CompareTo(L"") != 0)
1129 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1134 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1136 if ( __pItemContext!= NULL)
1140 pItem->SetContextItem(__pItemContext);
1146 if ( __pItemContextLandscape!= NULL)
1150 pItem->SetContextItem(__pItemContextLandscape);
1154 if( pListIconImage != NULL)
1156 delete pListIconImage;
1157 pListIconImage = null;
1164 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1171 MainForm::GetItemCount (void)
1173 if(__pMostVisitedSites != null)
1175 __pMostVisitedSites->RemoveAll(true);
1177 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1178 if(__pMostVisitedSites != null)
1180 return __pMostVisitedSites->GetCount();
1187 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1189 if(__pMostVisitedSites != null)
1191 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1192 if (pHistory != null)
1194 String url = pHistory->GetHistoryUrl();
1196 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1197 __pMostVisitedListView->UpdateList();
1203 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1205 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1206 String url = pHistory->GetHistoryUrl();
1214 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1220 MainForm::OnTerminating(void)
1222 result r = E_SUCCESS;
1225 delete __pItemContext;
1227 if(__pItemContextLandscape)
1229 delete __pItemContextLandscape;
1235 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1237 result r = E_SUCCESS;
1239 AppLogDebug("Clicked : %d", actionId);
1242 // case IDA_BACKBTN_CLICKED:
1244 // if (__pWebViewer && __pWebViewer->CanGoBack())
1246 // __pWebViewer->GoBack();
1250 // UiApp* pApp = null;
1251 // pApp = UiApp::GetInstance();
1252 // if (pApp != null)
1254 // r = pApp->Terminate();
1257 // AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1265 case IDA_BACKBTN_CLICKED:
1267 if (__pWebViewer && __pWebViewer->CanGoBack())
1269 __pWebViewer->GoBack();
1271 else if(__pWindowInfo->isJavascriptInitiated == false)
1274 pApp = UiApp::GetInstance();
1277 r = pApp->Terminate();
1280 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1288 WindowInfo* pWindowInfo = null;
1290 SceneManager* pSceneManager = SceneManager::GetInstance();
1291 if (pSceneManager == null)
1295 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1296 if (pAllWindowList == NULL)
1298 pApp = UiApp::GetInstance();
1301 r = pApp->Terminate();
1304 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1309 if (pAllWindowList != null)
1311 totalCount = pAllWindowList->GetCount();
1313 for (int count = 0; count < totalCount; count++)
1315 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1316 if (pWindowInfo == null)
1318 pApp = UiApp::GetInstance();
1321 r = pApp->Terminate();
1324 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1331 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1333 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1336 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1339 r = pAllWindowList->RemoveAt(count, true);
1340 __pWindowInfo = null;
1343 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1348 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1352 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1354 if (pWindowInfo == null)
1356 pApp = UiApp::GetInstance();
1359 r = pApp->Terminate();
1365 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1368 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1380 case IDA_FORWARD_CLICKED:
1381 if (__pWebViewer == null)
1384 if (__pWebViewer->CanGoForward())
1386 __pWebViewer->GoForward();
1388 __pMenu->SetShowState(false);
1389 __pMenu->Invalidate(false);
1392 case IDA_FINDONPAGE_CLICKED:
1394 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1395 __currentSearchStr.Clear();
1397 InitFindWordPanel();
1398 __pMenu->SetShowState(false);
1399 __pMenu->Invalidate(false);
1401 __pFindWordEditField->SetFocus();
1403 if (__pWebViewer != null)
1405 // releasing the set block
1406 __pWebViewer->ReleaseBlock();
1409 ShowFindWordPanel(true);
1412 case IDA_PRIVATEON_CLICKED:
1414 result r = E_SUCCESS;
1416 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1417 Bitmap* pBitmap = null;
1418 if (isPrivateBrowsing == true)
1420 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1423 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1427 if (__pWebViewer != NULL)
1429 __pWebViewer->SetPrivateBrowsingEnabled(false);
1432 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1434 if (__pAddressbar != null)
1436 __pAddressbar->UpdateFaviconBitmap(false);
1442 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1445 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1449 if (__pWebViewer != NULL)
1451 __pWebViewer->SetPrivateBrowsingEnabled(true);
1454 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1456 if (__pAddressbar != null)
1458 __pAddressbar->UpdateFaviconBitmap(true);
1463 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1464 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1465 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1466 __pMenu->Invalidate(true);
1468 if ( pBitmap != NULL )
1475 case IDA_SETTINGS_CLICKED:
1478 ArrayList* pArgList = new(std::nothrow) ArrayList();
1481 pArgList->Construct();
1482 pArgList->Add(*__pWindowInfo);
1483 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1485 __pMenu->SetShowState(false);
1486 __pMenu->Invalidate(false);
1487 if (pArgList != null)
1496 case IDA_ADDTOBOOKMARK_CLICKED:
1499 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1501 int bookmarkCount=0;
1504 url=__pWindowInfo->pageUrl;
1505 result r = E_SUCCESS;
1506 Bitmap* pBitmap = null;
1507 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1515 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1516 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1517 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1519 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1520 if (pNotification != null)
1522 pNotification->SetText(message);
1523 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1524 pNotification->ShowNotification();
1529 String title=__pWindowInfo->pageTitle;
1530 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1531 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1533 pBookmark->SetBookmarkTitle(title);
1534 pBookmark->SetUrl(url);
1535 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1537 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1539 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1540 pBookmark->SetFaviconId(id);
1541 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1542 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1545 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1546 if (pNotification != null)
1548 pNotification->SetText(message);
1549 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1550 pNotification->ShowNotification();
1551 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1554 if (pBitmap != null)
1556 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1560 __pMenu->Invalidate(true);
1564 case IDA_PRINT_CLICKED:
1566 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1567 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1569 AppLog("RequestPrint called!");
1570 Tizen::App::AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1571 result nResult = E_FAILURE;
1574 AppLog("TestPrint if (pAc) == true");
1579 String fileType = L"service_print_files_type";
1580 String typeVal = L"DOC";
1582 String fileCount = L"service_print_files_count";
1583 String countVal = L"1";
1584 String fileFolder= L"service_print_files_folder_name";
1585 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1587 map.Add(&fileCount, &countVal);
1588 // map.Add(&fileIndex, &indexVal);
1589 map.Add(&fileFolder, &folderVal);
1590 map.Add(&fileType, &typeVal);
1592 String fileName = L"service_print_files_files_name";
1594 ArrayList fileNameList;
1595 fileNameList.Construct();
1596 String file1 = L"test.pdf";
1598 fileNameList.Add(&file1);
1599 map.Add(&fileName, &fileNameList);
1601 nResult = pAc->Start(NULL, NULL, &map, NULL);
1603 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1604 else if (nResult == E_MAX_EXCEEDED)
1605 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1606 else if (nResult == E_OBJ_NOT_FOUND)
1607 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1608 else if (nResult == E_IN_PROGRESS)
1609 AppLog("TestPrint ret == E_IN_PROGRESS");
1610 else if (nResult == E_PRIVILEGE_DENIED)
1611 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1612 else if(nResult == E_SYSTEM)
1613 AppLog("TestPrint ret == E_SYSTEM");
1619 int __modalMsgBoxResult;
1620 MessageBox* pMsgBox = new MessageBox();
1621 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1622 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1625 __modalMsgBoxResult = 0;
1629 case IDA_SHARE_CLICKED:
1631 if(__pPopUp != null)
1636 __pPopUp = new(std::nothrow) SharePopup();
1637 __pPopUp->Initialize();
1638 if (__pWindowInfo != null)
1640 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1641 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1642 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1643 pShareInfo->SetImageAttached(false);
1644 __pPopUp->RemoveAllShareInfo();
1645 __pPopUp->AddShareInfo(pShareInfo);
1647 __pPopUp->SetShowState(true);
1651 case IDA_BOOKMARKBTN_CLICKED:
1653 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1654 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1657 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1662 case IDA_MOREBTN_CLICKED:
1664 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1665 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1666 AppLog("Anchot pos: %d %d", p.x, p.y);
1668 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1670 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1671 int bookmarkCount=0;
1674 url=__pWindowInfo->pageUrl;
1675 result r = E_SUCCESS;
1676 Bitmap* pBitmap = null;
1678 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1681 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1686 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1690 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1692 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1694 if (__pMenu->GetItemCount() == 9)
1696 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1700 r = __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1705 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1709 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1710 if (__pMenu->GetItemCount() != 9)
1712 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1713 __pMenu->InsertItemAt(2,"Print", IDA_PRINT_CLICKED);
1714 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1715 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1716 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1717 __pMenu->SetMaxVisibleItemsCount(6);
1719 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1721 AppLog(" Orientation landscape");
1722 __pMenu->SetMaxVisibleItemsCount(5);
1726 AppLog(" Orientation potrait");
1727 __pMenu->SetMaxVisibleItemsCount(6);
1730 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1733 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1734 __pMenu->SetShowState(true);
1735 __pMenu->Invalidate(true);
1739 case IDA_HISTORY_CLICKED:
1741 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1742 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1745 case IDA_SAVED_PAGES_CLICKED:
1750 case IDA_DESKTOP_VIEW_CLICKED:
1755 case IDA_SAVE_CLICKED:
1760 case IDA_MULTIWINDOWBTN_CLICKED:
1762 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1763 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1767 case IDA_NEWWINDOWBTN_CLICKED:
1769 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1771 if (pNewWindowInfo == null)
1775 result r = E_SUCCESS;
1776 SceneManager* pSceneManager = SceneManager::GetInstance();
1778 if (pSceneManager == NULL)
1782 ArrayList* pArgList = new(std::nothrow) ArrayList();
1783 if (pArgList == NULL)
1787 r = pArgList->Construct();
1790 pArgList->Add(*pNewWindowInfo);
1791 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1797 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1802 case IDA_SMALLFONT_BTN_CLICKED:
1804 WebSetting setting = __pWebReader->GetSetting();
1805 setting.SetFontSize(15);
1806 __pWebReader->SetSetting(setting);
1809 case IDA_LARGEFONT_BTN_CLICKED:
1811 WebSetting setting = __pWebReader->GetSetting();
1812 setting.SetFontSize(25);
1813 __pWebReader->SetSetting(setting);
1816 case IDA_READER_CLOSE_CLICKED:
1818 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1820 //__pArticleReaderPanel->SetShowState(false);
1821 //__pArticleReaderPanel->Show();
1822 RemoveControl(__pBlankPanel);
1823 //RemoveControl(*__pArticleReaderPanel);
1824 __pArticleReaderPanel = null;
1825 __pBlankPanel = null;
1826 __pArticleReaderLabel = null;
1828 //if (__pAddressbar)
1829 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1830 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1833 case IDA_FINDWORD_CANCEL_CLICKED:
1835 __currentSearchStr = L"";
1836 __currentWordIndex = 0;
1837 __maxOccurrances = 0;
1838 __pFindWordEditField->SetText(L"");
1839 __pFindWordNext->SetEnabled(false);
1840 __pFindWordPrev->SetEnabled(false);
1841 __pFindWordCountLabel->SetText(L"0/0");
1842 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1843 ShowFindWordPanel(false);
1846 case IDA_FINDWORD_SEARCH_CLICKED:
1848 __currentSearchStr = __pFindWordEditField->GetText();
1849 if (__currentSearchStr.GetLength() > 0)
1855 AppLogDebug("Enter something");
1859 case IDA_FINDWORD_CLEAR_CLICKED:
1861 __pFindWordCountLabel->SetText(L"0/0");
1862 __pFindWordEditField->SetText(L"");
1863 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1865 __currentSearchStr = L"";
1866 __pFindWordNext->SetEnabled(false);
1867 __pFindWordPrev->SetEnabled(false);
1868 __pFindWordControl->Invalidate(true);
1871 case IDA_FINDWORD_NEXT_CLICKED:
1876 case IDA_FINDWORD_PREV_CLICKED:
1878 FindNextWord(false);
1881 case IDA_BRIGHTNESS_BTN_CLICKED:
1883 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1884 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1887 case IDA_COPY_IMAGE_CLICKED:
1889 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1890 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1892 const Bitmap* pBitmap = null;
1893 if (__pHitElementResult != null)
1895 pBitmap = __pHitElementResult->GetImage();
1898 String resourcePath = App::GetInstance()->GetAppResourcePath();
1899 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1901 // copying the item to clipboard
1902 Clipboard* pClipboard = Clipboard::GetInstance();
1903 if (pClipboard != null)
1905 pClipboard->CopyItem(item);
1909 case IDA_VIEW_IMAGE_CLICKED:
1911 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1912 WindowInfo* pNewWindowInfo = null;
1913 if (__pHitElementResult != null)
1915 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1916 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1922 case IDA_SAVE_IMAGE_CLICKED:
1924 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1925 const Bitmap* pSaveBitmap = null;
1926 String imageName = GetImagePath();
1927 AppLog("Content manager image name %ls",imageName.GetPointer());
1930 imagePath.Append(imageName);
1931 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1932 AppLog("Content manager image path %ls",imagePath.GetPointer());
1933 if (__pHitElementResult != null)
1935 pSaveBitmap = __pHitElementResult->GetImage();
1937 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1941 UpdateImageContent(pBuffer, imageName);
1943 NotificationPanel *pNotification = new NotificationPanel(*this);
1945 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1946 msg.Append(imagePath);
1947 if (pNotification != null)
1949 pNotification->SetText(msg);
1950 if (__pFooterPanel->GetShowState() == true)
1952 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1956 pNotification->SetPositionDiff(0);
1959 pNotification->ShowNotification();
1964 int __modalMsgBoxResult;
1965 MessageBox* pMsgBox = new MessageBox();
1966 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1967 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1970 __modalMsgBoxResult = 0;
1974 case IDA_SHARE_IMAGE_CLICKED:
1976 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1977 if (__pPopUp != null)
1982 __pPopUp = new(std::nothrow) SharePopup();
1983 __pPopUp->Initialize();
1984 if (__pHitElementResult != null)
1986 const Bitmap* pSaveBitmap = null;
1987 String imageName = GetImagePath();
1988 AppLog("Content manager image name %ls",imageName.GetPointer());
1991 imagePath.Append(imageName);
1992 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1993 AppLog("Content manager image path %ls",imagePath.GetPointer());
1994 if (__pHitElementResult != null)
1996 pSaveBitmap = __pHitElementResult->GetImage();
1998 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2000 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2001 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2003 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2004 pShareInfo->SetPageTitle(L"");
2005 pShareInfo->SetPageUrl(srcUrl);
2006 pShareInfo->SetImageAttached(true);
2007 pShareInfo->SetImagePath(imagePath);
2008 __pPopUp->RemoveAllShareInfo();
2009 __pPopUp->AddShareInfo(pShareInfo);
2010 __pPopUp->SetShowState(true);
2015 case IDA_HYPERLINK_OPEN_CLICKED:
2017 if (__pHitElementResult != null)
2019 String srcUrl = __pHitElementResult->GetUrl();
2021 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(srcUrl);
2023 if (pNewWindowInfo == null)
2027 result r = E_SUCCESS;
2028 SceneManager* pSceneManager = SceneManager::GetInstance();
2029 if (pSceneManager == NULL)
2033 ArrayList* pArgList = new(std::nothrow) ArrayList();
2034 if (pArgList == NULL)
2038 pArgList->Construct();
2040 pArgList->Add(*pNewWindowInfo);
2041 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2042 if (pArgList != null)
2049 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2055 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2057 if (__pHitElementResult == null)
2062 if(__pPopUp != null)
2067 __pPopUp = new(std::nothrow) SharePopup();
2068 __pPopUp->Initialize();
2070 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2071 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2072 pShareInfo->SetImageAttached(false);
2073 __pPopUp->RemoveAllShareInfo();
2074 __pPopUp->AddShareInfo(pShareInfo);
2076 __pPopUp->SetShowState(true);
2080 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2084 if (__pHitElementResult != null)
2086 url = __pHitElementResult->GetUrl();
2089 String resourcePath = App::GetInstance()->GetAppResourcePath();
2090 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2092 // copying the item to clipboard
2093 Clipboard* pClipboard = Clipboard::GetInstance();
2094 if (pClipboard != null)
2096 pClipboard->CopyItem(item);
2100 case IDA_FIND_TEXT__CLICKED:
2102 OnAddressCancelledClicked(*__pAddressbar);
2103 __pFooterPanel->SetShowState(false);
2104 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2105 __currentSearchStr.Clear();
2106 __currentSearchStr.Append(__currentSelectedStr);
2107 InitFindWordPanel();
2108 __pFindWordEditField->SetText(__currentSearchStr);
2111 __pMenu->SetShowState(false);
2112 __pMenu->Invalidate(false);
2115 __adressPanelPosition.y = 0;
2117 if (__pAddressbar != null && __pWebViewer != NULL)
2119 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2120 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
2121 //__pAddressbar->Invalidate(true);
2122 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2124 if (__pFooterPanel->GetShowState() == false)
2125 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2127 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2128 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
2129 __pWebViewer->Invalidate(true);
2132 ShowFindWordPanel(true);
2133 __pFindWordEditField->SetFocus();
2134 if (__currentSearchStr.GetLength() > 0)
2140 AppLogDebug("Enter something");
2143 if (__pWebViewer != null)
2145 // releasing the set block
2146 __pWebViewer->ReleaseBlock();
2151 case IDA_SHARE_TEXT_CLICKED:
2153 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2154 if(__pPopUp != null)
2159 __pPopUp = new(std::nothrow) SharePopup();
2160 __pPopUp->Initialize();
2161 if (__pHitElementResult != null)
2163 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2164 pShareInfo->SetPageTitle(L"");
2165 pShareInfo->SetPageUrl(__currentSelectedStr);
2166 pShareInfo->SetImageAttached(false);
2167 __pPopUp->RemoveAllShareInfo();
2168 __pPopUp->AddShareInfo(pShareInfo);
2169 __pPopUp->SetShowState(true);
2174 case IDA_COPY_TEXT_CLICKED:
2176 __pWebViewer->ReleaseBlock();
2177 // need to implement
2178 //__currentSelectedStr
2179 // Sets data to a clip board item
2181 String resourcePath = App::GetInstance()->GetAppResourcePath();
2182 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2184 // copying the item to clipboard
2185 Clipboard* pClipboard = Clipboard::GetInstance();
2186 if (pClipboard != null)
2188 pClipboard->CopyItem(item);
2192 case IDA_PASTE_TEXT_CLICKED:
2194 Clipboard* pClipboard = Clipboard::GetInstance();
2196 if(pClipboard == null)
2200 // Retrieves a latest item
2201 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2207 //Gets data from the clipboard item
2208 String* pString = dynamic_cast<String*>(pItem->GetData());
2210 if (pString != null)
2212 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2213 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2214 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2215 // 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; } } ";
2216 String script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementById(myField).focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0'){ var startPos = document.getElementById(myField).selectionStart; var endPos = document.getElementById(myField).selectionEnd; document.getElementById(myField).value = document.getElementById(myField).value.substring(0, startPos)+ myValue + document.getElementById(myField).value.substring(endPos, document.getElementById(myField).value.length); } else { document.getElementById(myField).value += myValue; } } ";
2217 if(idElement.GetLength() != 0)
2219 script.Append("insertAtCursor('");
2220 script.Append(idElement);
2221 script.Append("',");
2222 script.Append("\"");
2223 script.Append(*pString);
2224 script.Append("\");");
2226 else if (nameElement.GetLength() != 0)
2228 script.Append("insertAtCursor(document.getElementsByName('");
2229 script.Append(nameElement);
2230 script.Append("')[0],");
2231 script.Append("\"");
2232 script.Append(*pString);
2233 script.Append("\");");
2235 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2236 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2247 case IDA_GO_FORWARD:
2252 case IDA_REFRESH_BTN_CLICKED:
2254 __isLoadingCompleted = false;
2255 __isLoadingData = true;
2256 __progressPercentage = 0;
2257 __displayUrl = __pFooterUrlField->GetText();
2259 String url = __pFooterUrlField->GetText();
2260 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2264 UpdateProgressBitmap();
2267 case IDA_STOP_BTN_CLICKED:
2269 __isLoadingCompleted = false;
2270 __isLoadingData = false;
2271 __progressPercentage = 0;
2272 __pFooterUrlField->HideKeypad();
2273 __displayUrl = __pFooterUrlField->GetText();
2277 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2278 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2279 __pWebViewer->StopLoading();
2280 RequestRedraw(true);
2283 UpdateProgressBitmap();
2288 if (__pFooterUrlField->GetText().IsEmpty() == false)
2290 //__displayUrl = __pUrlField->GetText();
2291 __pFooterUrlField->Clear();
2302 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2305 UiApp* pApp = UiApp::GetInstance();
2314 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2315 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2317 AppLog("MainForm::OnSceneActivatedN called");
2318 String* pSelectedScene = NULL;
2319 Object* pValue = NULL;
2320 String* pUrl = null;
2321 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2322 pSelectedScene = (String*) pValue;
2324 if (pSelectedScene != null)
2326 delete pSelectedScene;
2328 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2329 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2330 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2331 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2333 // setting the current scene ID
2334 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2336 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2338 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2340 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2341 if(__pWindowInfo == null)
2343 // if(__pWindowInfo == null)
2345 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2348 else if ( pArgs != null && pArgs->GetCount() == 1)
2350 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2356 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2358 // hiding the address bar
2359 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2360 __pAddressbar->SetShowState(false);
2361 if(__pWebViewer != null)
2363 __pWebViewer->Resume();
2366 if(pUrl != null && pUrl->GetLength() > 0)
2370 else if(__pWindowInfo != null)
2372 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)
2374 LoadUrl(__pWindowInfo->pageUrl);
2376 else if (__pWindowInfo->isJavascriptInitiated == true)
2380 __pWindowInfo->pCurrentWeb = __pWebViewer;
2384 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2385 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2386 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2388 InitMostVisitedSitesView(GetOrientationStatus());
2390 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2392 if(__pMostVisitedListView != null)
2394 __pMostVisitedListView->SetShowState(false);
2398 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2400 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2402 if (pBookmarkUrl == null)
2404 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2405 //__pAddressbar->SetUrl(*pBookmarkUrl);
2406 SetUrl(*pBookmarkUrl);
2408 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2409 __pWebViewer->LoadUrl(*pBookmarkUrl);
2410 delete pBookmarkUrl;
2413 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2414 Bitmap* pBitmap = null;
2415 if (isPrivateBrowsing == true)
2417 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2419 if (__pWebViewer != null)
2421 __pWebViewer->SetPrivateBrowsingEnabled(true);
2424 if (__pAddressbar != null)
2426 // __pAddressbar->UpdateFaviconBitmap(true);
2432 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2434 if (__pWebViewer != null)
2436 __pWebViewer->SetPrivateBrowsingEnabled(false);
2439 if (__pAddressbar != null)
2441 // __pAddressbar->UpdateFaviconBitmap(false);
2445 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2447 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2449 else if (__pMenu != null )
2451 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2454 if (pBitmap != null)
2459 AppLog("ABC: OnSceneActivatedN started exit");
2464 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2465 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2467 Canvas* pWebCanvas = null;
2468 if (__pWebViewer != null)
2470 pWebCanvas = __pWebViewer->GetCanvasN();
2471 __pWebViewer->Pause();
2474 if (pWebCanvas == null)
2478 if (__pWindowInfo != null)
2480 if (__pWindowInfo->pWebCanvasBitmap != null)
2482 delete __pWindowInfo->pWebCanvasBitmap;
2484 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2485 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2486 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2488 Bitmap* pBitmap = GetCapturedBitmapN();
2489 AppLog("Coming here");
2490 Canvas* pCanvas = new(std::nothrow) Canvas();
2491 pCanvas->Construct(GetClientAreaBounds());
2494 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2497 if(__pWebViewer != null && __pWindowInfo != null)
2498 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2500 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2501 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2503 AppLog("Coming here");
2507 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2508 const Tizen::Base::String& realm,
2509 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2515 MainForm::OnHttpAuthenticationCanceled(void)
2520 MainForm::OnLoadingStarted(void)
2522 AppLogDebug("MainForm::OnLoadingStarted entered");
2524 if(__pAddressbar == NULL || __pWebViewer == null)
2528 String url = __pWebViewer->GetUrl();
2529 if(url.Contains(IDS_TIZEN_SERVICE))
2532 String delim(L":;");
2534 // Creates a StringTokenizer instance
2535 StringTokenizer strTok(url, delim);
2537 int count = strTok.GetTokenCount(); // count == 4
2539 HashMap *pMap = new HashMap();
2544 while (strTok.HasMoreTokens())
2546 AppLog("Token: %ls", token.GetPointer());
2547 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2548 if(token.Contains(IDS_APPID))
2550 token.SubString(6, appId);
2551 AppLog("AppID:%ls", appId.GetPointer());
2553 else if(token.Contains("="))
2555 String *pKey = new String();
2556 String *pValue = new String();
2558 token.IndexOf("=", 0, index);
2561 token.SubString(0, index, *pKey);
2562 token.SubString(index + 1, *pValue);
2563 pMap->Add(pKey, pValue);
2569 AppControl *pAppControl = null;
2570 String operationId = L"http://tizen.org/appcontrol/operation/main";
2571 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2574 AppLog("Starting AppControl");
2575 result r = pAppControl->Start(null, null, pMap, null);
2576 AppLog("Result of Start %s", GetErrorMessage(r));
2580 AppLogException("AppControl not found");
2585 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2588 __pAddressbar->SetFaviconBitmap(*pBitmap);
2591 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2593 // updating the address bar position with respect to web control
2594 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2595 __distanceMoved = 0;
2599 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2600 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2601 if (__pWebViewer != null)
2603 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2604 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2605 SetUrl(__pWebViewer->GetUrl());
2606 if (__pWindowInfo != NULL)
2608 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2610 __pAddressbar->Invalidate(true);
2616 MainForm::OnLoadingCanceled(void)
2623 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2625 AppLog("MainForm::OnKeypadWillOpen");
2626 if (__pAddressbar != null)
2628 OnAddressBarKeypadWillOpen(*__pAddressbar);
2634 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2636 if(__pAddressbar != null)
2638 OnAddressBarKeypadOpened(*__pAddressbar);
2644 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2648 if (__pAddressbar != null)
2650 OnAddressBarKeypadClosed(*__pAddressbar);
2655 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2657 AppLog("KeypadBoundsChanged");
2658 RelayoutControls(false);
2662 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2663 const Tizen::Base::String& reason)
2665 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2669 MainForm::OnLoadingCompleted(void)
2671 AppLog("MainForm::OnLoadingCompleted start");
2673 result r = E_SUCCESS;
2675 if (__pWebViewer == null)
2680 if (__pAddressbar == null)
2684 if (__pWebViewer->CanGoForward())
2686 //__pAddressbar->SetForwardButtonEnabled(true);
2687 SetForwardButtonEnabled(true);
2691 //__pAddressbar->SetForwardButtonEnabled(false);
2692 SetForwardButtonEnabled(false);
2695 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2697 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2699 //__pAddressbar->UpdateProgress(0);
2703 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2705 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2709 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2710 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2711 if (isPrivateBrowsing == false)
2713 if(__pHistory != null)
2719 __pHistory = new(std::nothrow) History;
2720 HistoryPresentationModel::GetCurrentDateTime(date);
2723 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2724 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2726 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2727 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2729 __pHistory->SetVisitedTime(date);
2731 if (__pWebViewer != null)
2733 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2735 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2736 if (pTempBitmap != null)
2738 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2739 __pHistory->SetFavIconBitmap(*pTempBitmap);
2742 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2745 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2746 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2747 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2749 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2750 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2751 __pHistory->SetThumbnail(pBitmap);
2753 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2756 __pHistory->SetFavIconBitmap(*pFavIcon);
2760 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
2767 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2769 // temperary fixed (webpage can be not loaded)
2772 AppLog("MainForm::OnLoadingCompleted done");
2776 MainForm::OnEstimatedProgress(int progress)
2778 AppLogDebug("MainForm::OnEstimatedProgress entered");
2779 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2780 progress = DEFAULT_PROGRESS_PERCENTAGE;
2782 // __pAddressbar->UpdateProgress(progress);
2783 UpdateProgress(progress);
2786 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2788 AppLog("MainForm::OnFaviconReceived");
2789 if (__pWebViewer != null && __pHistory != null)
2791 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2793 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *(__pWebViewer->GetFaviconN()));
2798 MainForm::OnUrlValueChanged(Addressbar&)
2804 MainForm::OnUrlSubmitted(Addressbar& addBar)
2806 AppLog("MainForm::OnUrlSubmitted");
2807 String url = addBar.GetUrl();
2808 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2810 // __pFooterPanel->SetShowState(true);
2811 if(__pFooterUrlField)
2812 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2813 OnAddressCancelledClicked(*__pAddressbar);
2814 // __pAddressbar->SetShowState(false);
2815 // RelayoutControls(false);
2820 MainForm::LoadUrl(String& url)
2824 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2825 AppLogDebug("MainForm::LoadUrl enter");
2827 if (__pWebViewer != null)
2829 __pWebViewer->SetShowState(true);
2830 __pWebViewer->Invalidate(true);
2833 if (url.CompareTo(L"") == 0)
2837 if(__pFooterPanel != null)
2839 __pFooterPanel->SetShowState(true);
2840 __pFooterPanel->Invalidate(true);
2847 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2848 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)
2850 RegularExpression firstRegex;
2851 RegularExpression secondRegex;
2853 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2854 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2857 ret = firstRegex.Match(url, false); // This returns true value
2858 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2860 if (ret == true && __pWebViewer != null)
2863 __pWebViewer->LoadUrl(url);
2865 else if(__pWebViewer != null)
2867 String tempUrl = L"http://";
2868 tempUrl.Append(url);
2872 __pWebViewer->LoadUrl(tempUrl);
2876 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2877 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2880 if (__pAddressbar != null)
2882 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2883 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2886 AppLogDebug("MainForm::LoadUrl exit");
2893 MainForm::OnStopClicked(Addressbar& addBar)
2895 AppLogDebug("MainForm::OnStopClicked called");
2898 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2899 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2900 __pWebViewer->StopLoading();
2901 RequestRedraw(true);
2906 MainForm::OnReaderClicked(const Addressbar& addBar)
2908 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2910 CreateReaderPanel();
2911 AppLogDebug("MainScene::OnReaderClicked entered");
2914 /*if (__pArticleReaderPanel)
2916 AppLogDebug("showstate true for reader panel");
2917 __pArticleReaderPanel->SetShowState(true);
2918 __pArticleReaderPanel->Show();
2920 int xPos = __pArticleReaderPanel->GetX();
2921 int yPos = __pArticleReaderPanel->GetY();
2922 AppLog("OnReaderClicked() xPos = %d",xPos);
2923 AppLog("OnReaderClicked() yPos = %d",yPos);
2925 if (__pReaderData == null)
2930 String loadData = L"<html>\
2932 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2937 background-color: transparent;\
2956 <body style='width:'";
2957 loadData.Append(bodyWidth);
2958 loadData.Append(L"px'>");
2959 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2960 loadData.Append(*__pReaderData);
2961 loadData.Append(L"</body></html>");
2964 buf.Construct(loadData.GetLength());
2965 AppLogDebug("data->GetLength %d",loadData.GetLength());
2966 for (int z=0;z<loadData.GetLength();z++)
2969 loadData.GetCharAt(z,b);
2970 buf.SetByte((byte)b);
2974 if (__pWebReader != null)
2976 __pWebReader->LoadData(L"",buf,L"text/html");
2977 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2981 AppLogDebug("cannot LoadData __pWebReader is null");
2987 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2989 // AppLog("MainForm::OnBackClicked");
2990 result r = E_FAILURE;
2992 if (__pWebViewer && __pWebViewer->CanGoBack())
2994 __pWebViewer->GoBack();
2996 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2999 pApp = UiApp::GetInstance();
3002 r = pApp->Terminate();
3005 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3013 WindowInfo* pWindowInfo = null;
3015 SceneManager* pSceneManager = SceneManager::GetInstance();
3016 if (pSceneManager == null)
3020 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3021 if (pAllWindowList == NULL)
3023 pApp = UiApp::GetInstance();
3026 r = pApp->Terminate();
3029 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3034 if (pAllWindowList != null)
3036 totalCount = pAllWindowList->GetCount();
3038 for (int count = 0; count < totalCount; count++)
3040 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3041 if (pWindowInfo == null)
3043 pApp = UiApp::GetInstance();
3046 r = pApp->Terminate();
3049 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3054 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3056 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3059 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3062 r = pAllWindowList->RemoveAt(count, true);
3063 __pWindowInfo = null;
3066 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3071 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3075 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3077 if (pWindowInfo == null)
3079 pApp = UiApp::GetInstance();
3082 r = pApp->Terminate();
3088 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3091 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3105 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3107 AppLog("MainForm::OnForwardClicked");
3108 if (__pWebViewer == null)
3111 if (__pWebViewer->CanGoForward())
3113 __pWebViewer->GoForward();
3118 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3120 result r = E_SUCCESS;
3122 __pFooterPanel->SetShowState(true);
3123 __pFooterUrlField->SetFocusable(true);
3126 __pWebViewer->SetFocus();
3127 else if(__pMostVisitedListView)
3128 __pMostVisitedListView->SetFocus();
3129 else if(__pMultiWindowButton)
3130 __pMultiWindowButton->SetFocus();
3131 __pMoreButton->SetFocus();
3133 __pAddressbar->SetShowState(false);
3135 RelayoutControls(false,false);
3140 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3142 __prevAddressBarMode = __curAddressBarMode;
3144 if (__pAddressbar != null)
3146 __curAddressBarMode = GetAddressbarMode();
3149 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3151 __adressPanelPosition.y = 0;
3152 if (__pAddressbar != null)
3154 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3155 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3156 __pAddressbar->Invalidate(true);
3158 if (__pWebViewer != null)
3160 __pWebViewer->StopLoading();
3163 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3165 __adressPanelPosition.y = 0;
3166 if (__pAddressbar != null)
3168 __webControlPosition.y = 0;
3169 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3170 __pAddressbar->Invalidate(true);
3176 MainForm::OnClipboardClosed(const Addressbar& addBar)
3178 RelayoutControls(false);
3182 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3185 __pAddressbar->SetShowState(false);
3187 __pFooterPanel->SetShowState(true);
3189 // __pWebViewer->SetFocus();
3190 if(__pFooterUrlField)
3192 __pFooterUrlField->SetFocusable(true);
3194 RelayoutControls(false,footerState);
3198 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3200 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
3202 __pAddressbar->SetShowState(false);
3206 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3208 __pAddressbar->SetShowState(true);
3209 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3210 __pAddressbar->SetAddressbarURLFocus();
3214 RelayoutControls(false);
3218 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3220 __pFooterPanel->SetShowState(false);
3224 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3226 AppLog("KeypadBoundsChanged");
3227 RelayoutControls(false);
3231 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3235 __pWindowInfo->pageTitle = title;
3236 if (__pWebViewer != null)
3238 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3241 if (__pAddressbar != null && __pWebViewer != null)
3243 SetUrl(__pWebViewer->GetUrl());
3244 __pAddressbar->Invalidate(true);
3249 MainForm::UpdateFavicon(void)
3251 bool urlImageType = false;
3252 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();");
3253 Bitmap* pBitmap = null;
3255 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3257 if (__pWindowInfo != null)
3260 url.SetUri(*tempPath);
3261 if (url.GetHost().GetLength() == 0)
3264 webUrl.SetUri(__pWebViewer->GetUrl());
3265 result r = url.SetHost(webUrl.GetHost());
3272 if (url.GetScheme().GetLength() == 0)
3275 webUrl.SetUri(__pWebViewer->GetUrl());
3276 url.SetScheme(webUrl.GetScheme());
3278 __pWindowInfo->faviconUrl = url.ToString();
3280 pBitmap = __pWebViewer->GetFaviconN();
3282 if (pBitmap != null)
3284 if (__pWindowInfo->pFavicon != NULL)
3286 __pWindowInfo->pFavicon = null;
3288 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3289 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3291 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3293 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3295 else if(__pWindowInfo->pFavicon != null)
3297 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3301 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3302 if(pDefaultBmp != null)
3304 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3313 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3320 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3321 Tizen::Web::Controls::WebNavigationType type)
3323 // when load new page if find word panel is open its show state is false
3324 ShowFindWordPanel(false);
3326 __pFooterPanel->Invalidate(true);
3329 uriInfo.SetUri(url);
3331 if(url.Contains(IDS_TIZEN_SERVICE))
3334 String delim(L":;,");
3336 // Creates a StringTokenizer instance
3337 StringTokenizer strTok(url, delim);
3339 int count = strTok.GetTokenCount(); // count == 4
3341 HashMap *pMap = new HashMap();
3347 while (strTok.HasMoreTokens())
3349 AppLog("Token: %ls", token.GetPointer());
3350 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3351 if(token.Contains(IDS_APPID))
3353 token.SubString(6, appId);
3354 AppLog("AppID:%ls", appId.GetPointer());
3356 else if(token.Contains("="))
3358 String *pKey = new String();
3359 String *pValue = new String();
3361 token.IndexOf("=", 0, index);
3364 token.SubString(0, index, *pKey);
3365 token.SubString(index + 1, *pValue);
3366 pMap->Add(pKey, pValue);
3372 AppControl *pAppControl = null;
3373 String operationId = L"http://tizen.org/appcontrol/operation/main";
3374 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3377 result r = pAppControl->Start(null, null, pMap, null);
3381 AppLogException("AppControl not found");
3387 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3389 __pAddressbar->SetShowState(false);
3390 OnAddressCancelledClicked(*__pAddressbar);
3391 __pAddressbar->Invalidate(true);
3397 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3398 const Tizen::Net::Http::HttpHeader& httpHeader)
3400 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3405 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3407 AppLog("MainForm::OnWebPageBlockSelected");
3408 if (__pHitElementResult != null)
3410 delete __pHitElementResult;
3411 __pHitElementResult = null;
3414 if (__pWebViewer != null)
3416 AppLog("MainForm::OnWebPageBlockSelected web not null");
3417 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3420 if (__pHitElementResult == null)
3425 if (__pHitElementResult->HasImage() != true)
3427 String tagName = __pHitElementResult->GetTagName();
3428 String type = __pHitElementResult->GetAttributeValue("type");
3430 __currentSelectedStr.Clear();
3431 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3432 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3433 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3435 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
3437 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3439 InitSelectTextContextMenu(endPoint,true);
3440 __pImageMenu->SetShowState(true);
3441 __pImageMenu->Show();
3442 __pImageMenu->Invalidate(true);
3444 else if(__isLongPressedDone == true)
3446 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3448 if(__pHitElementResult->GetUrl().GetLength() > 0)
3450 __currentSelectedStr.Clear();
3451 __currentSelectedStr = __pHitElementResult->GetUrl();
3453 InitSelectTextContextMenu(endPoint,false);
3454 __pImageMenu->SetShowState(true);
3455 __pImageMenu->Show();
3456 __pImageMenu->Invalidate(true);
3459 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3460 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3461 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3467 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3473 MainForm::OnWebWindowCreateRequested(void)
3475 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3477 if (pNewWindowInfo == null)
3481 result r = E_SUCCESS;
3482 SceneManager* pSceneManager = SceneManager::GetInstance();
3483 if (pSceneManager == NULL)
3487 ArrayList* pArgList = new(std::nothrow) ArrayList();
3488 if (pArgList == NULL)
3492 r = pArgList->Construct();
3495 pNewWindowInfo->isJavascriptInitiated = true;
3496 pArgList->Add(*pNewWindowInfo);
3497 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3501 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3508 return pNewWindowInfo->pCurrentWeb;
3512 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3514 __webControlPosition.y = 0;
3515 __webControlHeight = GetClientAreaBounds().height;
3516 AppLog("Client area height: %d", __webControlHeight);
3518 AppLog("Client area height: %d", __webControlHeight);
3519 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3521 __webControlPosition.y += __pAddressbar->GetHeight();
3522 __webControlHeight -= __pAddressbar->GetHeight();
3523 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3525 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3527 __webControlPosition.y += __pFindWordControl->GetHeight();
3528 __webControlHeight -= __pFindWordControl->GetHeight();
3529 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3532 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3534 __webControlHeight -= __pFooterPanel->GetHeight();
3536 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3538 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3540 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3541 __pWebViewer->Invalidate(false);
3543 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3545 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3552 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3554 if (__pFindWordControl == null)
3560 InitFindWordPanel();
3561 // __pFindWordEditField->SetText(__currentSearchStr);
3562 //__pFindWordCountLabel->SetText(L"");
3563 // __pFindWordCountLabel->SetText(L"0/0");
3564 __pFindWordControl->SetShowState(true);
3568 if(__pFindWordControl != null)
3570 __pFindWordControl->SetShowState(false);
3574 AppLog("MainForm::ShowFindWordPanel %d",show);
3575 if (show && !isTouchPressed)
3577 if (__pFindWordEditField)
3579 __pFindWordEditField->SetFocus();
3580 __pFindWordEditField->ShowKeypad();
3585 if (__pFindWordEditField)
3586 __pFindWordEditField->HideKeypad();
3589 RelayoutControls(false);
3593 MainForm::StartWordSearch()
3595 //Get the count of occurances of the word in the current page
3596 __maxOccurrances = 0;
3597 __currentWordIndex = 0;
3599 __pFindWordPrev->SetEnabled(false);
3600 String *pCountStr = null;
3601 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3602 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3603 if (pCountStr != null)
3605 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3609 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3614 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3616 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3617 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3619 if(totalCount == -1 || totalCount == 0)
3621 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3622 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3625 else if(totalCount > 100)
3627 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3628 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3632 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3633 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3636 __maxOccurrances = totalCount;
3637 __currentWordIndex = currentOrdinal;
3639 //Reset the UI controls as per the maxOccurrance value
3640 if (totalCount <= 0)
3642 AppLog("Word not found");
3643 //Show error notification to user
3644 __pFindWordNext->SetEnabled(false);
3645 __pFindWordCountLabel->SetText(L"0/0");
3646 __pFindWordNext->Invalidate(false);
3647 __pFindWordPrev->Invalidate(false);
3648 __pFindWordCountLabel->Invalidate(false);
3652 if (totalCount == 1)
3654 __pFindWordNext->SetEnabled(false);
3658 __pFindWordNext->SetEnabled(true);
3661 String countStr = L"";
3662 countStr.Append(__currentWordIndex);
3663 countStr.Append(L"/");
3664 countStr.Append(__maxOccurrances);
3665 __pFindWordCountLabel->SetText(countStr);
3666 // __pFindWordCountLabel->SetShowState(true);
3667 __pFindWordCountLabel->Invalidate(false);
3669 //FindNextWord(true);
3670 //Update the controls
3671 __pFindWordNext->Invalidate(false);
3672 __pFindWordPrev->Invalidate(false);
3673 __pFindWordCountLabel->Invalidate(false);
3677 MainForm::FindNextWord(bool next)
3681 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3683 if(__currentWordIndex < __maxOccurrances)
3685 __currentWordIndex++;
3691 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3693 if(__currentWordIndex > 1)
3695 __currentWordIndex--;
3700 String countStr = L"";
3701 countStr.Append(__currentWordIndex);
3702 countStr.Append(L"/");
3703 countStr.Append(__maxOccurrances);
3704 __pFindWordCountLabel->SetText(countStr);
3705 // __pFindWordCountLabel->SetShowState(true);
3706 __pFindWordCountLabel->Invalidate(false);
3707 if (__currentWordIndex >= __maxOccurrances)
3709 __pFindWordNext->SetEnabled(false);
3713 __pFindWordNext->SetEnabled(true);
3715 if (__currentWordIndex <= 1)
3717 __pFindWordPrev->SetEnabled(false);
3721 __pFindWordPrev->SetEnabled(true);
3723 __pFindWordPrev->Invalidate(false);
3724 __pFindWordNext->Invalidate(false);
3725 __pFindWordCountLabel->Invalidate(false);
3726 __pFindWordControl->Invalidate(true);
3729 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3731 AppLog("MainForm::OnWebKeypadWillOpen");
3732 __isWebKeypadOpened = true;
3733 // OnAddressBarKeypadOpened(*__pAddressbar);
3737 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3740 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3742 __currentSearchStr = L"";
3743 __currentWordIndex = 0;
3744 __maxOccurrances = 0;
3745 __pFindWordEditField->SetText(L"");
3746 __pFindWordNext->SetEnabled(false);
3747 __pFindWordPrev->SetEnabled(false);
3748 __pFindWordCountLabel->SetText(L"0/0");
3749 __pWebViewer->SearchTextAllAsync(L"",false);
3750 __pFindWordControl->SetShowState(false);
3751 __pFindWordEditField->HideKeypad();
3755 if (__pWebViewer != null && __pFooterPanel != null)
3757 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3758 if(__pAddressbar != null)
3760 __pAddressbar->SetShowState(false);
3762 if(__pFindWordControl != null)
3764 __pFindWordControl->SetShowState(false);
3766 __pFooterPanel->SetShowState(false);
3767 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3769 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
3771 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
3772 // AppLog("omgomgomg");
3778 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3780 __pFooterPanel->SetShowState(true);
3781 OnAddressBarKeypadClosed(*__pAddressbar);
3782 __isWebKeypadOpened = false;
3786 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3788 Control* temp = const_cast< Control* >(&source);
3789 Header* pHeader = dynamic_cast< Header* >(temp);
3790 if (pHeader != null)
3792 //Header double - clicked
3793 AppLog("Header double clicked");
3795 if(__pFindWordControl)
3797 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3798 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3802 AppLog("MainScene::OnTouchDoublePressed");
3803 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3804 if (isReaderEnabled == true)
3808 delete __pReaderData;
3809 __pReaderData = null;
3811 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3812 filePath.Append(L"data/reader.js");
3818 result r = E_SUCCESS;
3819 FileAttributes attr;
3821 File::GetAttributes(filePath,attr);
3823 r = file.Construct(filePath, L"r+");
3826 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3829 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3832 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3835 file.Read(pScript,attr.GetFileSize());
3837 AppLogDebug("scipt length %d",strlen(pScript));
3838 String strScript = L"";
3839 strScript.Append(pScript);
3840 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3843 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3846 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3847 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3849 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3850 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3856 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3858 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
3860 if (__pHitElementResult != null)
3862 delete __pHitElementResult;
3863 __pHitElementResult = null;
3866 if (__pWebViewer != null)
3868 AppLog("MainForm::OnTouchLongPressed web not null");
3869 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3872 if (__pHitElementResult == null)
3877 if (__pHitElementResult->HasImage() == true)
3879 InitImageContextMenu(currentPosition);
3880 __pImageMenu->SetShowState(true);
3881 __pImageMenu->Show();
3882 __pImageMenu->Invalidate(true);
3884 else if(__pHitElementResult->HasUrl() == true)
3886 String tempURl = __pHitElementResult->GetUrl();
3887 AppLog("tempURl is %ls", tempURl.GetPointer());
3888 const Bitmap* pBitmap = __pHitElementResult->GetImage();
3889 if (pBitmap != null)
3897 InitImageLinkContextMenu(currentPosition);
3898 __pImageMenu->SetShowState(true);
3899 __pImageMenu->Show();
3900 __pImageMenu->Invalidate(true);
3904 String tagName = __pHitElementResult->GetTagName();
3905 String type = __pHitElementResult->GetAttributeValue("type");
3906 String value = __pHitElementResult->GetAttributeValue(L"value");
3907 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3909 __currentSelectedStr.Clear();
3910 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3912 AppLog("tag name is %ls", tagName.GetPointer());
3913 AppLog("type is %ls", type.GetPointer());
3914 AppLog("innerHtml is %ls", innerHtml.GetPointer());
3916 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3918 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3920 InitSelectTextContextMenu(currentPosition,true, true);
3923 // __pImageMenu->SetShowState(true);
3924 // __pImageMenu->Show();
3925 // __pImageMenu->Invalidate(true);
3928 __isLongPressedDone = true;
3929 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
3930 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
3933 __inputEventToBeSupressed = true;
3937 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3939 AppLog("MainForm::OnTouchReleased");
3941 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3942 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3944 __pWebViewer->ConsumeInputEvent();
3946 if(pHitElement != null)
3950 __inputEventToBeSupressed = false;
3954 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3961 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3963 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3965 __currentSearchStr = L"";
3966 __currentWordIndex = 0;
3967 __maxOccurrances = 0;
3968 __pFindWordEditField->SetText(L"");
3969 __pFindWordNext->SetEnabled(false);
3970 __pFindWordPrev->SetEnabled(false);
3971 __pFindWordCountLabel->SetText(L"0/0");
3972 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3973 __pFindWordControl->SetShowState(false);
3974 __pFindWordEditField->HideKeypad();
3976 if(__pAddressbar->GetShowState() == false)
3978 __pAddressbar->SetShowState(true);
3979 __pAddressbar->SetAddressbarURLFocus();
3980 __pFooterUrlField->SetFocusable(false);
3981 __pFooterPanel->SetShowState(false);
3988 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3994 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4000 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4006 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4012 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4018 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4020 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4021 int widthContextItem = 0;
4023 // As per the platform engineer comment removed this line
4024 /*if(__pWebViewer != null)
4026 // this is added because if any text is selected on long press followed by on rotation we are hiding the context menu therefore we should release the text block also
4027 __pWebViewer->ReleaseBlock();
4030 if(__pFindWordControl != null)
4031 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4032 if ( __pFooterLabel != null)
4034 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4037 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4042 if (__pFindWordBgLabel != null)
4044 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4045 if (pBitmap != null)
4047 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4053 __pMenu->SetShowState(false);
4054 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4056 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4060 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4065 AppLog("__pFooterPanel->GetShowState() is true");
4067 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4068 __pFooterPanel->Invalidate(true);
4072 if(__pMoreButton && __pMenu)
4074 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
4075 __pMenu->SetAnchorPosition(p);
4076 __pMenu->Invalidate(true);
4079 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4080 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4082 InitMostVisitedSitesView(orientationStatus);
4085 RelayoutControls(false);
4086 if (__pArticleReaderPanel != null)
4088 if (__pArticleReaderPanel->GetShowState() == true)
4090 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4092 if (__pBlankPanel != null)
4093 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4095 if (__pWebReader != null)
4097 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4099 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4100 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4102 if ( pBitmap != null && pSrcBitmap != null)
4104 AppLog("CreateReaderPanel ninepatchbitmap found");
4105 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4108 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4109 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4110 if (pBitmap != null)
4115 if (pSrcBitmap != null)
4124 if (__pAddressbar != null)
4126 int width = GetClientAreaBounds().width;
4127 __pAddressbar->OrientationChanged(width);
4132 MainForm::OnSettingsChange(int settingvalue)
4134 AppLogDebug("MainForm::OnSettingsChange entered");
4136 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4138 __pAddressbar->ResetGuideText();
4140 if (__pWebViewer == null)
4142 AppLogDebug("Webviewer is not initialized yet.");
4146 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4148 WebSetting settings = __pWebViewer->GetSetting();
4149 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4151 settings.SetAutoFittingEnabled(true);
4153 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
4155 settings.SetAutoFittingEnabled(false);
4157 __pWebViewer->SetSetting(settings);
4159 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4161 WebSetting settings = __pWebViewer->GetSetting();
4162 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4163 __pWebViewer->SetSetting(settings);
4165 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4167 WebSetting settings = __pWebViewer->GetSetting();
4168 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4169 __pWebViewer->SetSetting(settings);
4171 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4173 WebSetting settings = __pWebViewer->GetSetting();
4174 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4175 __pWebViewer->SetSetting(settings);
4177 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4181 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4185 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4187 WebSetting settings = __pWebViewer->GetSetting();
4188 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4190 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4194 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4196 __pWebViewer->SetSetting(settings);
4198 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4202 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4203 WebSetting settings = __pWebReader->GetSetting();
4204 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4205 __pWebReader->SetSetting(settings);
4211 MainForm::OnSettingsReset()
4215 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4216 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4221 MainForm::OnClearCache()
4223 result r = E_SUCCESS;
4225 if (__pWebViewer != NULL)
4227 r = __pWebViewer->ClearCache();
4230 AppLogDebug("Cache cleared success");
4234 AppLogDebug("Cache cleared fail");
4240 MainForm::OnClearCookie()
4242 result r = E_SUCCESS;
4244 if (__pWebViewer != NULL)
4246 __pWebViewer->ClearCookie();
4250 AppLogDebug("Cookie cleared success");
4254 AppLogDebug("Cache cleared fail");
4259 MainForm::OnClearFormData()
4261 result r = E_SUCCESS;
4263 if (__pWebViewer != NULL)
4265 __pWebViewer->ClearFormData();
4269 AppLogDebug("Cookie cleared success");
4273 AppLogDebug("Cache cleared fail");
4278 MainForm::OnClearPasswords()
4280 result r = E_SUCCESS;
4282 if (__pWebViewer != NULL)
4284 __pWebViewer->ClearLoginFormData();
4288 AppLogDebug("Cookie cleared success");
4292 AppLogDebug("Cache cleared fail");
4298 MainForm::findDistance(int x1,int y1,int x2, int y2)
4300 int deltaX = Math::Abs(x2 - x1);
4301 int deltaY = Math::Abs(y2 - y1);
4302 double num = deltaX*deltaX + deltaY*deltaY;
4308 for (i = 0; i < 20; i++)
4310 x = (((x*x)+ num)/(2*x));
4321 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4323 if(__pFindWordControl)
4325 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4326 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4328 __isLongPressedDone = false;
4331 IList* pList = null;
4332 pList = touch.GetTouchInfoListN(source);
4336 int count = pList->GetCount();
4339 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4340 __touchPoint1 = pTouchInfo->position;
4342 /*if (__pAddressbar != null)
4344 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4346 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4348 __pAddressbar->SaveAddressbarEditText();
4350 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4353 __pAddressbar->Invalidate(true);
4355 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4357 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4359 //__pAddressbar->SaveAddressbarEditText();
4361 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4364 else if (count == 2)
4366 AppLogDebug("MainForm::OnTouchPressed count is two");
4367 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4368 __touchPoint1 = pTouchInfo->position;
4370 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4371 __touchPoint2 = pTouchInfo->position;
4377 pList->RemoveAll(true);
4384 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4386 // __currentWordIndex = 0;
4387 __isLongPressedDone = false;
4392 MainForm::MoveUiControls()
4397 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4399 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4401 if(__pFooterUrlField->GetTextLength() == 0)
4403 __pFooterUrlField->SetKeypadActionEnabled(false);
4407 __pFooterUrlField->SetKeypadActionEnabled(true);
4410 if (__pFindWordEditField != null)
4412 __currentSearchStr = __pFindWordEditField->GetText();
4413 __pFindWordNext->SetEnabled(false);
4414 __pFindWordPrev->SetEnabled(false);
4415 __pFindWordNext->Invalidate(true);
4416 __pFindWordPrev->Invalidate(true);
4417 __pFindWordCountLabel->SetText(L"0/0");
4418 __pFindWordCountLabel->Invalidate(true);
4420 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4421 if (__currentSearchStr.GetLength() > 0)
4427 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4429 __currentSearchStr = L"";
4430 AppLogDebug("Enter something");
4435 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4442 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4444 if(__pWebViewer != null)
4447 AppLog("MainForm::InitMostVisitedSitesView");
4448 result r = E_SUCCESS;
4451 if (__pWebViewer != null && __pMostVisitedListView != null)
4456 if (__pMostVisitedListView != null)
4458 RemoveControl(__pMostVisitedListView);
4460 if(__pMostVisitedSites != null)
4462 __pMostVisitedSites->RemoveAll(true);
4465 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4467 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4468 __pMostVisitedListView = new(std::nothrow) ListView();
4470 int height = GetClientAreaBounds().height;
4472 if(__pFooterPanel->GetShowState() == true)
4474 height = height - __pFooterPanel->GetHeight();
4476 if(__pAddressbar->GetShowState() == true)
4478 height -= __pAddressbar->GetHeight();
4481 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4485 delete __pMostVisitedListView;
4486 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4489 __pMostVisitedListView->SetItemProvider(*this);
4490 __pMostVisitedListView->AddListViewItemEventListener(*this);
4491 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4492 AddControl(__pMostVisitedListView);
4493 __pMostVisitedListView->UpdateList();
4500 MainForm::GetImagePath(void)
4504 String formattedTime;
4505 DateTime currentTime;
4506 LocaleManager localManager;
4507 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4509 localManager.Construct();
4510 Locale locale = localManager.GetSystemLocale();
4511 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4513 // Get date formatter
4514 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4518 pTimeFormatter->Format(currentTime, formattedTime);
4521 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4522 String delim(L" :");
4523 StringTokenizer strTok(formattedTime, delim);
4526 String str1("GMT+00");
4527 while (strTok.HasMoreTokens())
4529 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4530 if(token.Equals(str1))
4532 AppLog("token is %ls", token.GetPointer());
4533 imageName.Append(token);
4539 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4541 result r = E_FAILURE;
4542 AppLog("Content manager 1");
4543 ContentId contentId;
4544 ContentManager contentManager;
4545 r = contentManager.Construct();
4548 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4551 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4552 contentPath.Append(imageName);
4553 contentPath.Append(".jpg");
4554 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4555 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4559 MainForm::SetForwardButtonEnabled(bool isEnabled)
4561 __pGoForwardBtn->SetEnabled(isEnabled);
4562 __pGoForwardBtn->Invalidate(true);
4566 MainForm::SetBackButtonEnabled(bool isEnabled)
4568 __pGoBackBtn->SetEnabled(isEnabled);
4569 __pGoBackBtn->Invalidate(true);
4573 MainForm::UpdateProgress(int percentage)
4575 __progressPercentage = percentage;
4576 if (percentage == 0 || percentage == 100)
4578 __isLoadingData = false;
4579 if (percentage == 100)
4581 __isLoadingCompleted = true;
4582 __progressPercentage = 0;
4586 __isLoadingCompleted = false;
4591 __isLoadingData = true;
4593 UpdateProgressBitmap();
4597 MainForm::GetProgress(void)
4599 return __progressPercentage;
4603 MainForm::UpdateProgressBitmap(void)
4605 result r = E_SUCCESS;
4606 if (__pProgressbarLabel == null)
4608 int w = __pProgressbarLabel->GetWidth();
4609 int h = __pProgressbarLabel->GetHeight();
4611 int progressWidth = 0;
4612 Bitmap* pRetBitmap = null;
4614 if (__progressPercentage == 0 || __progressPercentage == 100)
4616 __pProgressbarLabel->SetShowState(false);
4617 __pProgressbarLabel->Invalidate(false);
4622 __pProgressbarLabel->SetShowState(true);
4623 __pProgressbarLabel->Invalidate(false);
4626 r = canvas.Construct(Rectangle(0, 0, w, h));
4630 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4635 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4639 pBgBmp->Scale(Dimension(w, h));
4640 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4644 progressWidth = (double) (w) * __progressPercentage / 100;
4645 AppLogDebug("progressWidth: %d", progressWidth);
4646 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4648 if (pProgressBmp != null)
4650 pProgressBmp->Scale(Dimension(progressWidth, h));
4651 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4652 delete pProgressBmp;
4655 pRetBitmap = new (std::nothrow) Bitmap();
4657 if (pRetBitmap == null)
4659 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4663 pRetBitmap->Construct(canvas, canvas.GetBounds());
4665 if (__pProgressbarLabel != null && pRetBitmap != null)
4667 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4668 __pProgressbarLabel->Invalidate(false);
4671 if (pRetBitmap != null)
4679 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4681 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4683 __currentAddMode = addMode;
4687 case ADDRESSBAR_MODE_INVALID:
4692 case ADDRESSBAR_MODE_READER:
4694 __pStopBtn->SetShowState(false);
4695 __pClearBtn->SetShowState(false);
4698 case ADDRESSBAR_MODE_LOADING:
4700 __pRefreshBtn->SetShowState(false);
4701 __pStopBtn->SetShowState(true);
4702 __pClearBtn->SetShowState(false);
4705 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4707 // SetUrl(__pAddressbar->GetUrl());
4709 __pRefreshBtn->SetShowState(true);
4710 __pStopBtn->SetShowState(false);
4711 __pClearBtn->SetShowState(false);
4714 case ADDRESSBAR_MODE_EDIT:
4716 __pRefreshBtn->SetShowState(false);
4717 __pStopBtn->SetShowState(false);
4718 __pClearBtn->SetShowState(true);
4725 OnAddressBarModeChanged();
4728 AddressBarMode MainForm::GetAddressbarMode(void)
4730 return __currentAddMode;
4733 void MainForm::SetUrl(const String& url)
4737 if (__pFooterUrlField != NULL)
4739 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4740 if (removedHttpUrl.IsEmpty() == false)
4742 __pFooterUrlField->SetText(removedHttpUrl);
4743 if(__pAddressbar != NULL)
4744 __pAddressbar->SetUrl(__displayUrl);
4748 __pFooterUrlField->SetText(__displayUrl);
4749 if(__pAddressbar != NULL)
4750 __pAddressbar->SetUrl(__displayUrl);
4752 if(__pFooterUrlField)
4753 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
4754 __pFooterUrlField->Invalidate(false);
4755 if(__pAddressbar != NULL)
4756 __pAddressbar->Invalidate(true);
4757 // __pFooterUrlField->SetCursorPosition(0);
4762 MainForm::RemoveHttpTextFromDisplayURL(void)
4764 bool isHttpText = __displayUrl.Contains(L"http://");
4765 String updatedDisplayUrl;
4766 updatedDisplayUrl.Clear();
4768 if (isHttpText == true)
4770 __displayUrl.SubString(7,updatedDisplayUrl);
4772 return updatedDisplayUrl;
4775 void MainForm::OnSharePopupControlStarted(void)
4777 __pWebViewer->AddTouchEventListener(*this);
4780 void MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
4782 if (requestId == BACK_GROUND_APP_EVENT)
4784 if(__pWebViewer != null)
4786 __pWebViewer->Pause();
4789 else if(requestId == FORE_GROUND_APP_EVENT)
4791 if(__pWebViewer != null)
4793 __pWebViewer->Resume();