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;
878 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
879 if (__pImageMenu != null)
884 // p.y = p.y + __pAddressbar->GetHeight() + 12;
889 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
894 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
896 __pImageMenu = new (std::nothrow) ContextMenu();
897 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
898 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
900 if(onlyPasteOption == false)
902 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
904 if (pasteOption || onlyPasteOption)
906 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
908 if(onlyPasteOption == false)
910 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
911 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
914 __pImageMenu->SetMaxVisibleItemsCount(3);
915 __pImageMenu->AddActionEventListener(*this);
916 SetControlAlwaysOnTop(*__pImageMenu, true);
923 MainForm::InitFindWordPanel(void)
925 result r = E_SUCCESS;
926 Bitmap *pIconBitmap = null;
928 if (__pFindWordControl != null)
930 AppLogDebug("Findword panel already initialized");
931 if (__pFindWordBgLabel != null)
933 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
936 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
943 __pFindWordControl = new (std::nothrow) Panel();
944 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
947 AppLogException("There is some problem in the xml file. Please check.");
950 AddControl(__pFindWordControl);
951 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
952 SetControlAlwaysOnTop(*__pFindWordControl,true);
953 __pFindWordControl->SetShowState(false);
954 __pFindWordControl->Invalidate(false);
956 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
957 if (__pFindWordBgLabel != null)
959 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
960 Rectangle pRect = pPanel1->GetBounds();
961 pRect.x = pRect.y = 0;
962 __pFindWordBgLabel->SetBounds(pRect);
963 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
966 AppLogDebug("InitFindWordPanel: Coming here");
967 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
972 AppLogDebug("InitFindWordPanel: shouldn't Come here");
976 Button* pfindWordCancel = null;
977 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
978 if (pfindWordCancel == null)
980 AppLogException("There is some problem in the xml file. Please check.");
983 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
984 pfindWordCancel->AddActionEventListener(*this);
986 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
987 if (__pFindWordClear == null)
989 AppLogException("There is some problem in the xml file. Please check.");
993 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
994 __pFindWordClear->AddActionEventListener(*this);
996 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
997 if (__pFindWordNext == null)
999 AppLogException("There is some problem in the xml file. Please check.");
1003 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1004 __pFindWordNext->AddActionEventListener(*this);
1006 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1007 if (__pFindWordPrev == null)
1009 AppLogException("There is some problem in the xml file. Please check.");
1013 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1014 __pFindWordPrev->AddActionEventListener(*this);
1016 __pFindWordNext->SetEnabled(false);
1017 __pFindWordPrev->SetEnabled(false);
1019 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1020 if (__pFindWordCountLabel == null)
1022 AppLogException("There is some problem in the xml file. Please check.");
1026 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1027 if (__pFindWordEditField == null)
1029 AppLogException("There is some problem in the xml file. Please check.");
1032 __pFindWordEditField->AddTextEventListener(*this);
1033 __pFindWordEditField->AddKeypadEventListener(*this);
1034 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1040 MainForm::CreateItem (int index, int itemWidth)
1042 Rectangle listImageRect;
1043 Rectangle pagetTitleRect;
1044 Rectangle pageURLRect;
1045 Rectangle deleteImageRect;
1046 String pageTitle(L"");
1047 String pageURL(L"");
1048 result r = E_SUCCESS;
1049 Bitmap* pListIconImage = null;
1052 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1053 if(pHistory == null)
1057 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1058 if ( pAppResource == NULL )
1062 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1064 CustomItem* pItem = new(std::nothrow) CustomItem();
1065 pageTitle = pHistory->GetHistoryTitle();
1066 pageURL = pHistory->GetHistoryUrl();
1068 if (pageURL.GetLength() == 0)
1071 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1072 pageURL = L"<"+ nourl +">";
1076 Rectangle screenBounds = GetBounds();
1079 r = pItem->Construct(Dimension(itemWidth, 128), style);
1088 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1090 if ( pBitmap != NULL)
1092 pListIconImage = new Bitmap();
1093 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1097 if(pListIconImage == null)
1099 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1102 if ( pListIconImage != NULL)
1104 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1105 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1106 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1109 if (pItem != null && pListIconImage != NULL)
1111 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1115 if (pageTitle.CompareTo(L"") != 0)
1119 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1123 if (pageURL.CompareTo(L"") != 0)
1127 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1132 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1134 if ( __pItemContext!= NULL)
1138 pItem->SetContextItem(__pItemContext);
1144 if ( __pItemContextLandscape!= NULL)
1148 pItem->SetContextItem(__pItemContextLandscape);
1152 if( pListIconImage != NULL)
1154 delete pListIconImage;
1155 pListIconImage = null;
1162 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1169 MainForm::GetItemCount (void)
1171 if(__pMostVisitedSites != null)
1173 __pMostVisitedSites->RemoveAll(true);
1175 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1176 if(__pMostVisitedSites != null)
1178 return __pMostVisitedSites->GetCount();
1185 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1187 if(__pMostVisitedSites != null)
1189 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1190 if (pHistory != null)
1192 String url = pHistory->GetHistoryUrl();
1194 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1195 __pMostVisitedListView->UpdateList();
1201 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1203 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1204 String url = pHistory->GetHistoryUrl();
1212 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1218 MainForm::OnTerminating(void)
1220 result r = E_SUCCESS;
1223 delete __pItemContext;
1225 if(__pItemContextLandscape)
1227 delete __pItemContextLandscape;
1233 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1235 result r = E_SUCCESS;
1237 AppLogDebug("Clicked : %d", actionId);
1240 // case IDA_BACKBTN_CLICKED:
1242 // if (__pWebViewer && __pWebViewer->CanGoBack())
1244 // __pWebViewer->GoBack();
1248 // UiApp* pApp = null;
1249 // pApp = UiApp::GetInstance();
1250 // if (pApp != null)
1252 // r = pApp->Terminate();
1255 // AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1263 case IDA_BACKBTN_CLICKED:
1265 if (__pWebViewer && __pWebViewer->CanGoBack())
1267 __pWebViewer->GoBack();
1269 else if(__pWindowInfo->isJavascriptInitiated == false)
1272 pApp = UiApp::GetInstance();
1275 r = pApp->Terminate();
1278 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1286 WindowInfo* pWindowInfo = null;
1288 SceneManager* pSceneManager = SceneManager::GetInstance();
1289 if (pSceneManager == null)
1293 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1294 if (pAllWindowList == NULL)
1296 pApp = UiApp::GetInstance();
1299 r = pApp->Terminate();
1302 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1307 if (pAllWindowList != null)
1309 totalCount = pAllWindowList->GetCount();
1311 for (int count = 0; count < totalCount; count++)
1313 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1314 if (pWindowInfo == null)
1316 pApp = UiApp::GetInstance();
1319 r = pApp->Terminate();
1322 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1329 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1331 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1334 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1337 r = pAllWindowList->RemoveAt(count, true);
1338 __pWindowInfo = null;
1341 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1346 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1350 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1352 if (pWindowInfo == null)
1354 pApp = UiApp::GetInstance();
1357 r = pApp->Terminate();
1363 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1366 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1378 case IDA_FORWARD_CLICKED:
1379 if (__pWebViewer == null)
1382 if (__pWebViewer->CanGoForward())
1384 __pWebViewer->GoForward();
1386 __pMenu->SetShowState(false);
1387 __pMenu->Invalidate(false);
1390 case IDA_FINDONPAGE_CLICKED:
1392 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1393 __currentSearchStr.Clear();
1395 InitFindWordPanel();
1396 __pMenu->SetShowState(false);
1397 __pMenu->Invalidate(false);
1399 __pFindWordEditField->SetFocus();
1401 if (__pWebViewer != null)
1403 // releasing the set block
1404 __pWebViewer->ReleaseBlock();
1407 ShowFindWordPanel(true);
1410 case IDA_PRIVATEON_CLICKED:
1412 result r = E_SUCCESS;
1414 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1415 Bitmap* pBitmap = null;
1416 if (isPrivateBrowsing == true)
1418 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1421 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1425 if (__pWebViewer != NULL)
1427 __pWebViewer->SetPrivateBrowsingEnabled(false);
1430 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1432 if (__pAddressbar != null)
1434 __pAddressbar->UpdateFaviconBitmap(false);
1440 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1443 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1447 if (__pWebViewer != NULL)
1449 __pWebViewer->SetPrivateBrowsingEnabled(true);
1452 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1454 if (__pAddressbar != null)
1456 __pAddressbar->UpdateFaviconBitmap(true);
1461 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1462 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1463 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1464 __pMenu->Invalidate(true);
1466 if ( pBitmap != NULL )
1473 case IDA_SETTINGS_CLICKED:
1476 ArrayList* pArgList = new(std::nothrow) ArrayList();
1479 pArgList->Construct();
1480 pArgList->Add(*__pWindowInfo);
1481 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1483 __pMenu->SetShowState(false);
1484 __pMenu->Invalidate(false);
1485 if (pArgList != null)
1494 case IDA_ADDTOBOOKMARK_CLICKED:
1497 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1499 int bookmarkCount=0;
1502 url=__pWindowInfo->pageUrl;
1503 result r = E_SUCCESS;
1504 Bitmap* pBitmap = null;
1505 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1513 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1514 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1515 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1517 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1518 if (pNotification != null)
1520 pNotification->SetText(message);
1521 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1522 pNotification->ShowNotification();
1527 String title=__pWindowInfo->pageTitle;
1528 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1529 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1531 pBookmark->SetBookmarkTitle(title);
1532 pBookmark->SetUrl(url);
1533 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1535 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1537 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1538 pBookmark->SetFaviconId(id);
1539 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1540 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1543 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1544 if (pNotification != null)
1546 pNotification->SetText(message);
1547 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1548 pNotification->ShowNotification();
1549 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1552 if (pBitmap != null)
1554 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1558 __pMenu->Invalidate(true);
1562 case IDA_PRINT_CLICKED:
1564 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1565 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1567 AppLog("RequestPrint called!");
1568 Tizen::App::AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1569 result nResult = E_FAILURE;
1572 AppLog("TestPrint if (pAc) == true");
1577 String fileType = L"service_print_files_type";
1578 String typeVal = L"DOC";
1580 String fileCount = L"service_print_files_count";
1581 String countVal = L"1";
1582 String fileFolder= L"service_print_files_folder_name";
1583 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1585 map.Add(&fileCount, &countVal);
1586 // map.Add(&fileIndex, &indexVal);
1587 map.Add(&fileFolder, &folderVal);
1588 map.Add(&fileType, &typeVal);
1590 String fileName = L"service_print_files_files_name";
1592 ArrayList fileNameList;
1593 fileNameList.Construct();
1594 String file1 = L"test.pdf";
1596 fileNameList.Add(&file1);
1597 map.Add(&fileName, &fileNameList);
1599 nResult = pAc->Start(NULL, NULL, &map, NULL);
1601 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1602 else if (nResult == E_MAX_EXCEEDED)
1603 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1604 else if (nResult == E_OBJ_NOT_FOUND)
1605 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1606 else if (nResult == E_IN_PROGRESS)
1607 AppLog("TestPrint ret == E_IN_PROGRESS");
1608 else if (nResult == E_PRIVILEGE_DENIED)
1609 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1610 else if(nResult == E_SYSTEM)
1611 AppLog("TestPrint ret == E_SYSTEM");
1617 int __modalMsgBoxResult;
1618 MessageBox* pMsgBox = new MessageBox();
1619 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1620 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1623 __modalMsgBoxResult = 0;
1627 case IDA_SHARE_CLICKED:
1629 if(__pPopUp != null)
1634 __pPopUp = new(std::nothrow) SharePopup();
1635 __pPopUp->Initialize();
1636 if (__pWindowInfo != null)
1638 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1639 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1640 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1641 pShareInfo->SetImageAttached(false);
1642 __pPopUp->RemoveAllShareInfo();
1643 __pPopUp->AddShareInfo(pShareInfo);
1645 __pPopUp->SetShowState(true);
1649 case IDA_BOOKMARKBTN_CLICKED:
1651 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1652 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1655 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1660 case IDA_MOREBTN_CLICKED:
1662 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1663 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1664 AppLog("Anchot pos: %d %d", p.x, p.y);
1666 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1668 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1669 int bookmarkCount=0;
1672 url=__pWindowInfo->pageUrl;
1673 result r = E_SUCCESS;
1674 Bitmap* pBitmap = null;
1676 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1679 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1684 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1688 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1690 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1692 if (__pMenu->GetItemCount() == 9)
1694 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1698 r = __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1703 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1707 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1708 if (__pMenu->GetItemCount() != 9)
1710 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1711 __pMenu->InsertItemAt(2,"Print", IDA_PRINT_CLICKED);
1712 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1713 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1714 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1715 __pMenu->SetMaxVisibleItemsCount(6);
1717 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1719 AppLog(" Orientation landscape");
1720 __pMenu->SetMaxVisibleItemsCount(5);
1724 AppLog(" Orientation potrait");
1725 __pMenu->SetMaxVisibleItemsCount(6);
1728 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1731 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1732 __pMenu->SetShowState(true);
1733 __pMenu->Invalidate(true);
1737 case IDA_HISTORY_CLICKED:
1739 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1740 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1743 case IDA_SAVED_PAGES_CLICKED:
1748 case IDA_DESKTOP_VIEW_CLICKED:
1753 case IDA_SAVE_CLICKED:
1758 case IDA_MULTIWINDOWBTN_CLICKED:
1760 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1761 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1765 case IDA_NEWWINDOWBTN_CLICKED:
1767 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1769 if (pNewWindowInfo == null)
1773 result r = E_SUCCESS;
1774 SceneManager* pSceneManager = SceneManager::GetInstance();
1776 if (pSceneManager == NULL)
1780 ArrayList* pArgList = new(std::nothrow) ArrayList();
1781 if (pArgList == NULL)
1785 r = pArgList->Construct();
1788 pArgList->Add(*pNewWindowInfo);
1789 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1795 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1800 case IDA_SMALLFONT_BTN_CLICKED:
1802 WebSetting setting = __pWebReader->GetSetting();
1803 setting.SetFontSize(15);
1804 __pWebReader->SetSetting(setting);
1807 case IDA_LARGEFONT_BTN_CLICKED:
1809 WebSetting setting = __pWebReader->GetSetting();
1810 setting.SetFontSize(25);
1811 __pWebReader->SetSetting(setting);
1814 case IDA_READER_CLOSE_CLICKED:
1816 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1818 //__pArticleReaderPanel->SetShowState(false);
1819 //__pArticleReaderPanel->Show();
1820 RemoveControl(__pBlankPanel);
1821 //RemoveControl(*__pArticleReaderPanel);
1822 __pArticleReaderPanel = null;
1823 __pBlankPanel = null;
1824 __pArticleReaderLabel = null;
1826 //if (__pAddressbar)
1827 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1828 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1831 case IDA_FINDWORD_CANCEL_CLICKED:
1833 __currentSearchStr = L"";
1834 __currentWordIndex = 0;
1835 __maxOccurrances = 0;
1836 __pFindWordEditField->SetText(L"");
1837 __pFindWordNext->SetEnabled(false);
1838 __pFindWordPrev->SetEnabled(false);
1839 __pFindWordCountLabel->SetText(L"0/0");
1840 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1841 ShowFindWordPanel(false);
1844 case IDA_FINDWORD_SEARCH_CLICKED:
1846 __currentSearchStr = __pFindWordEditField->GetText();
1847 if (__currentSearchStr.GetLength() > 0)
1853 AppLogDebug("Enter something");
1857 case IDA_FINDWORD_CLEAR_CLICKED:
1859 __pFindWordCountLabel->SetText(L"0/0");
1860 __pFindWordEditField->SetText(L"");
1861 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1863 __currentSearchStr = L"";
1864 __pFindWordNext->SetEnabled(false);
1865 __pFindWordPrev->SetEnabled(false);
1866 __pFindWordControl->Invalidate(true);
1869 case IDA_FINDWORD_NEXT_CLICKED:
1874 case IDA_FINDWORD_PREV_CLICKED:
1876 FindNextWord(false);
1879 case IDA_BRIGHTNESS_BTN_CLICKED:
1881 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1882 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1885 case IDA_COPY_IMAGE_CLICKED:
1887 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1888 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1890 const Bitmap* pBitmap = null;
1891 if (__pHitElementResult != null)
1893 pBitmap = __pHitElementResult->GetImage();
1896 String resourcePath = App::GetInstance()->GetAppResourcePath();
1897 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1899 // copying the item to clipboard
1900 Clipboard* pClipboard = Clipboard::GetInstance();
1901 if (pClipboard != null)
1903 pClipboard->CopyItem(item);
1907 case IDA_VIEW_IMAGE_CLICKED:
1909 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1910 WindowInfo* pNewWindowInfo = null;
1911 if (__pHitElementResult != null)
1913 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1914 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1920 case IDA_SAVE_IMAGE_CLICKED:
1922 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1923 const Bitmap* pSaveBitmap = null;
1924 String imageName = GetImagePath();
1925 AppLog("Content manager image name %ls",imageName.GetPointer());
1928 imagePath.Append(imageName);
1929 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1930 AppLog("Content manager image path %ls",imagePath.GetPointer());
1931 if (__pHitElementResult != null)
1933 pSaveBitmap = __pHitElementResult->GetImage();
1935 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1939 UpdateImageContent(pBuffer, imageName);
1941 NotificationPanel *pNotification = new NotificationPanel(*this);
1943 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1944 msg.Append(imagePath);
1945 if (pNotification != null)
1947 pNotification->SetText(msg);
1948 if (__pFooterPanel->GetShowState() == true)
1950 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1954 pNotification->SetPositionDiff(0);
1957 pNotification->ShowNotification();
1962 int __modalMsgBoxResult;
1963 MessageBox* pMsgBox = new MessageBox();
1964 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1965 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1968 __modalMsgBoxResult = 0;
1972 case IDA_SHARE_IMAGE_CLICKED:
1974 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1975 if (__pPopUp != null)
1980 __pPopUp = new(std::nothrow) SharePopup();
1981 __pPopUp->Initialize();
1982 if (__pHitElementResult != null)
1984 const Bitmap* pSaveBitmap = null;
1985 String imageName = GetImagePath();
1986 AppLog("Content manager image name %ls",imageName.GetPointer());
1989 imagePath.Append(imageName);
1990 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1991 AppLog("Content manager image path %ls",imagePath.GetPointer());
1992 if (__pHitElementResult != null)
1994 pSaveBitmap = __pHitElementResult->GetImage();
1996 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1998 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1999 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2001 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2002 pShareInfo->SetPageTitle(L"");
2003 pShareInfo->SetPageUrl(srcUrl);
2004 pShareInfo->SetImageAttached(true);
2005 pShareInfo->SetImagePath(imagePath);
2006 __pPopUp->RemoveAllShareInfo();
2007 __pPopUp->AddShareInfo(pShareInfo);
2008 __pPopUp->SetShowState(true);
2013 case IDA_HYPERLINK_OPEN_CLICKED:
2015 if (__pHitElementResult != null)
2017 String srcUrl = __pHitElementResult->GetUrl();
2019 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(srcUrl);
2021 if (pNewWindowInfo == null)
2025 result r = E_SUCCESS;
2026 SceneManager* pSceneManager = SceneManager::GetInstance();
2027 if (pSceneManager == NULL)
2031 ArrayList* pArgList = new(std::nothrow) ArrayList();
2032 if (pArgList == NULL)
2036 pArgList->Construct();
2038 pArgList->Add(*pNewWindowInfo);
2039 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2040 if (pArgList != null)
2047 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2053 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2055 if (__pHitElementResult == null)
2060 if(__pPopUp != null)
2065 __pPopUp = new(std::nothrow) SharePopup();
2066 __pPopUp->Initialize();
2068 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2069 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2070 pShareInfo->SetImageAttached(false);
2071 __pPopUp->RemoveAllShareInfo();
2072 __pPopUp->AddShareInfo(pShareInfo);
2074 __pPopUp->SetShowState(true);
2078 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2082 if (__pHitElementResult != null)
2084 url = __pHitElementResult->GetUrl();
2087 String resourcePath = App::GetInstance()->GetAppResourcePath();
2088 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2090 // copying the item to clipboard
2091 Clipboard* pClipboard = Clipboard::GetInstance();
2092 if (pClipboard != null)
2094 pClipboard->CopyItem(item);
2098 case IDA_FIND_TEXT__CLICKED:
2100 OnAddressCancelledClicked(*__pAddressbar);
2101 // __pFooterPanel->SetShowState(false);
2102 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2103 __currentSearchStr.Clear();
2104 __currentSearchStr.Append(__currentSelectedStr);
2105 InitFindWordPanel();
2106 __pFindWordEditField->SetText(__currentSearchStr);
2109 __pMenu->SetShowState(false);
2110 __pMenu->Invalidate(false);
2113 __adressPanelPosition.y = 0;
2115 if (__pAddressbar != null && __pWebViewer != NULL)
2117 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2118 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
2119 //__pAddressbar->Invalidate(true);
2120 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2122 if (__pFooterPanel->GetShowState() == false)
2123 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2125 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2126 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
2127 __pWebViewer->Invalidate(true);
2130 ShowFindWordPanel(true);
2131 __pFindWordEditField->SetFocus();
2132 if (__currentSearchStr.GetLength() > 0)
2138 AppLogDebug("Enter something");
2141 if (__pWebViewer != null)
2143 // releasing the set block
2144 __pWebViewer->ReleaseBlock();
2149 case IDA_SHARE_TEXT_CLICKED:
2151 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2152 if(__pPopUp != null)
2157 __pPopUp = new(std::nothrow) SharePopup();
2158 __pPopUp->Initialize();
2159 if (__pHitElementResult != null)
2161 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2162 pShareInfo->SetPageTitle(L"");
2163 pShareInfo->SetPageUrl(__currentSelectedStr);
2164 pShareInfo->SetImageAttached(false);
2165 __pPopUp->RemoveAllShareInfo();
2166 __pPopUp->AddShareInfo(pShareInfo);
2167 __pPopUp->SetShowState(true);
2172 case IDA_COPY_TEXT_CLICKED:
2174 __pWebViewer->ReleaseBlock();
2175 // need to implement
2176 //__currentSelectedStr
2177 // Sets data to a clip board item
2179 String resourcePath = App::GetInstance()->GetAppResourcePath();
2180 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2182 // copying the item to clipboard
2183 Clipboard* pClipboard = Clipboard::GetInstance();
2184 if (pClipboard != null)
2186 pClipboard->CopyItem(item);
2190 case IDA_PASTE_TEXT_CLICKED:
2192 Clipboard* pClipboard = Clipboard::GetInstance();
2194 if(pClipboard == null)
2198 // Retrieves a latest item
2199 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2205 //Gets data from the clipboard item
2206 String* pString = dynamic_cast<String*>(pItem->GetData());
2208 if (pString != null)
2210 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2211 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2212 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2213 // 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; } } ";
2214 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; } } ";//by hyunn.lee
2216 if(idElement.GetLength() != 0)
2218 script.Append("insertAtCursor('");
2219 script.Append(idElement);
2220 script.Append("',");
2221 script.Append("\"");
2222 script.Append(*pString);
2223 script.Append("\");");
2225 else if (nameElement.GetLength() != 0)
2227 script.Append("insertAtCursor(document.getElementsByName('");
2228 script.Append(nameElement);
2229 script.Append("')[0],");
2230 script.Append("\"");
2231 script.Append(*pString);
2232 script.Append("\");");
2234 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2235 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2246 case IDA_GO_FORWARD:
2251 case IDA_REFRESH_BTN_CLICKED:
2253 __isLoadingCompleted = false;
2254 __isLoadingData = true;
2255 __progressPercentage = 0;
2256 __displayUrl = __pFooterUrlField->GetText();
2258 String url = __pFooterUrlField->GetText();
2259 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2263 UpdateProgressBitmap();
2266 case IDA_STOP_BTN_CLICKED:
2268 __isLoadingCompleted = false;
2269 __isLoadingData = false;
2270 __progressPercentage = 0;
2271 __pFooterUrlField->HideKeypad();
2272 __displayUrl = __pFooterUrlField->GetText();
2276 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2277 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2278 __pWebViewer->StopLoading();
2279 RequestRedraw(true);
2282 UpdateProgressBitmap();
2287 if (__pFooterUrlField->GetText().IsEmpty() == false)
2289 //__displayUrl = __pUrlField->GetText();
2290 __pFooterUrlField->Clear();
2301 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2304 UiApp* pApp = UiApp::GetInstance();
2313 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2314 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2316 AppLog("MainForm::OnSceneActivatedN called");
2317 String* pSelectedScene = NULL;
2318 Object* pValue = NULL;
2319 String* pUrl = null;
2320 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2321 pSelectedScene = (String*) pValue;
2323 if (pSelectedScene != null)
2325 delete pSelectedScene;
2327 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2328 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2329 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2330 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2332 // setting the current scene ID
2333 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2335 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2337 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2339 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2340 if(__pWindowInfo == null)
2342 // if(__pWindowInfo == null)
2344 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2347 else if ( pArgs != null && pArgs->GetCount() == 1)
2349 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2355 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2357 // hiding the address bar
2358 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2359 __pAddressbar->SetShowState(false);
2360 if(__pWebViewer != null)
2362 __pWebViewer->Resume();
2365 if(pUrl != null && pUrl->GetLength() > 0)
2369 else if(__pWindowInfo != null)
2371 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)
2373 LoadUrl(__pWindowInfo->pageUrl);
2375 else if (__pWindowInfo->isJavascriptInitiated == true)
2379 __pWindowInfo->pCurrentWeb = __pWebViewer;
2383 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2384 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2385 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2387 InitMostVisitedSitesView(GetOrientationStatus());
2389 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2391 if(__pMostVisitedListView != null)
2393 __pMostVisitedListView->SetShowState(false);
2397 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2399 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2401 if (pBookmarkUrl == null)
2403 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2404 //__pAddressbar->SetUrl(*pBookmarkUrl);
2405 SetUrl(*pBookmarkUrl);
2407 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2408 __pWebViewer->LoadUrl(*pBookmarkUrl);
2409 delete pBookmarkUrl;
2412 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2413 Bitmap* pBitmap = null;
2414 if (isPrivateBrowsing == true)
2416 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2418 if (__pWebViewer != null)
2420 __pWebViewer->SetPrivateBrowsingEnabled(true);
2423 if (__pAddressbar != null)
2425 // __pAddressbar->UpdateFaviconBitmap(true);
2431 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2433 if (__pWebViewer != null)
2435 __pWebViewer->SetPrivateBrowsingEnabled(false);
2438 if (__pAddressbar != null)
2440 // __pAddressbar->UpdateFaviconBitmap(false);
2444 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2446 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2448 else if (__pMenu != null )
2450 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2453 if (pBitmap != null)
2458 AppLog("ABC: OnSceneActivatedN started exit");
2463 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2464 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2466 Canvas* pWebCanvas = null;
2467 if (__pWebViewer != null)
2469 pWebCanvas = __pWebViewer->GetCanvasN();
2470 __pWebViewer->Pause();
2473 if (pWebCanvas == null)
2477 if (__pWindowInfo != null)
2479 if (__pWindowInfo->pWebCanvasBitmap != null)
2481 delete __pWindowInfo->pWebCanvasBitmap;
2483 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2484 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2485 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2487 Bitmap* pBitmap = GetCapturedBitmapN();
2488 AppLog("Coming here");
2489 Canvas* pCanvas = new(std::nothrow) Canvas();
2490 pCanvas->Construct(GetClientAreaBounds());
2493 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2496 if(__pWebViewer != null && __pWindowInfo != null)
2497 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2499 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2500 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2502 AppLog("Coming here");
2506 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2507 const Tizen::Base::String& realm,
2508 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2514 MainForm::OnHttpAuthenticationCanceled(void)
2519 MainForm::OnLoadingStarted(void)
2521 AppLogDebug("MainForm::OnLoadingStarted entered");
2523 if(__pAddressbar == NULL || __pWebViewer == null)
2527 String url = __pWebViewer->GetUrl();
2528 if(url.Contains(IDS_TIZEN_SERVICE))
2531 String delim(L":;");
2533 // Creates a StringTokenizer instance
2534 StringTokenizer strTok(url, delim);
2536 int count = strTok.GetTokenCount(); // count == 4
2538 HashMap *pMap = new HashMap();
2543 while (strTok.HasMoreTokens())
2545 AppLog("Token: %ls", token.GetPointer());
2546 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2547 if(token.Contains(IDS_APPID))
2549 token.SubString(6, appId);
2550 AppLog("AppID:%ls", appId.GetPointer());
2552 else if(token.Contains("="))
2554 String *pKey = new String();
2555 String *pValue = new String();
2557 token.IndexOf("=", 0, index);
2560 token.SubString(0, index, *pKey);
2561 token.SubString(index + 1, *pValue);
2562 pMap->Add(pKey, pValue);
2568 AppControl *pAppControl = null;
2569 String operationId = L"http://tizen.org/appcontrol/operation/main";
2570 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2573 AppLog("Starting AppControl");
2574 result r = pAppControl->Start(null, null, pMap, null);
2575 AppLog("Result of Start %s", GetErrorMessage(r));
2579 AppLogException("AppControl not found");
2584 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2586 __pAddressbar->SetShowState(false);
2587 OnAddressCancelledClicked(*__pAddressbar);
2588 __pAddressbar->Invalidate(true);
2590 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2593 __pAddressbar->SetFaviconBitmap(*pBitmap);
2596 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2598 // updating the address bar position with respect to web control
2599 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2600 __distanceMoved = 0;
2604 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2605 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2606 if (__pWebViewer != null)
2608 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2609 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2610 SetUrl(__pWebViewer->GetUrl());
2611 if (__pWindowInfo != NULL)
2613 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2615 __pAddressbar->Invalidate(true);
2621 MainForm::OnLoadingCanceled(void)
2628 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2630 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2631 if (__pAddressbar != null)
2633 OnAddressBarKeypadWillOpen(*__pAddressbar);
2639 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2641 AppLog("XYZ::MainForm::OnKeypadOpened");
2642 if(__pAddressbar != null)
2644 OnAddressBarKeypadOpened(*__pAddressbar);
2650 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2652 AppLog("XYZ::MainForm::OnKeypadClosed");
2654 if (__pAddressbar != null)
2656 OnAddressBarKeypadClosed(*__pAddressbar);
2661 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2663 AppLog("KeypadBoundsChanged");
2664 RelayoutControls(false);
2668 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2669 const Tizen::Base::String& reason)
2671 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2675 MainForm::OnLoadingCompleted(void)
2677 AppLog("MainForm::OnLoadingCompleted start");
2679 result r = E_SUCCESS;
2681 if (__pWebViewer == null)
2686 if (__pAddressbar == null)
2690 if (__pWebViewer->CanGoForward())
2692 //__pAddressbar->SetForwardButtonEnabled(true);
2693 SetForwardButtonEnabled(true);
2697 //__pAddressbar->SetForwardButtonEnabled(false);
2698 SetForwardButtonEnabled(false);
2701 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2703 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2705 //__pAddressbar->UpdateProgress(0);
2709 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2711 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2715 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2716 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2717 if (isPrivateBrowsing == false)
2719 if(__pHistory != null)
2725 __pHistory = new(std::nothrow) History;
2726 HistoryPresentationModel::GetCurrentDateTime(date);
2729 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2730 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2732 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2733 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2735 __pHistory->SetVisitedTime(date);
2737 if (__pWebViewer != null)
2739 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2741 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2742 if (pTempBitmap != null)
2744 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2745 __pHistory->SetFavIconBitmap(*pTempBitmap);
2748 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2751 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2752 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2753 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2755 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2756 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2757 __pHistory->SetThumbnail(pBitmap);
2759 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2762 __pHistory->SetFavIconBitmap(*pFavIcon);
2766 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
2773 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2775 // temperary fixed (webpage can be not loaded)
2778 AppLog("MainForm::OnLoadingCompleted done");
2782 MainForm::OnEstimatedProgress(int progress)
2784 AppLogDebug("MainForm::OnEstimatedProgress entered");
2785 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2786 progress = DEFAULT_PROGRESS_PERCENTAGE;
2788 // __pAddressbar->UpdateProgress(progress);
2789 UpdateProgress(progress);
2792 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2794 AppLog("MainForm::OnFaviconReceived");
2795 if (__pWebViewer != null && __pHistory != null)
2797 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *(__pWebViewer->GetFaviconN()));
2802 MainForm::OnUrlValueChanged(Addressbar&)
2808 MainForm::OnUrlSubmitted(Addressbar& addBar)
2810 AppLog("MainForm::OnUrlSubmitted");
2811 String url = addBar.GetUrl();
2812 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2814 // __pFooterPanel->SetShowState(true);
2815 if(__pFooterUrlField)
2816 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2817 OnAddressCancelledClicked(*__pAddressbar);
2818 // __pAddressbar->SetShowState(false);
2819 // RelayoutControls(false);
2824 MainForm::LoadUrl(String& url)
2828 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2829 AppLogDebug("MainForm::LoadUrl enter");
2831 if (__pWebViewer != null)
2833 __pWebViewer->SetShowState(true);
2834 __pWebViewer->Invalidate(true);
2837 if (url.CompareTo(L"") == 0)
2841 if(__pFooterPanel != null)
2843 __pFooterPanel->SetShowState(true);
2844 __pFooterPanel->Invalidate(true);
2851 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2852 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)
2854 RegularExpression firstRegex;
2855 RegularExpression secondRegex;
2857 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2858 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2861 ret = firstRegex.Match(url, false); // This returns true value
2862 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2864 if (ret == true && __pWebViewer != null)
2867 __pWebViewer->LoadUrl(url);
2869 else if(__pWebViewer != null)
2871 String tempUrl = L"http://";
2872 tempUrl.Append(url);
2876 __pWebViewer->LoadUrl(tempUrl);
2880 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2881 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2884 if (__pAddressbar != null)
2886 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2887 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2890 AppLogDebug("MainForm::LoadUrl exit");
2897 MainForm::OnStopClicked(Addressbar& addBar)
2899 AppLogDebug("MainForm::OnStopClicked called");
2902 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2903 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2904 __pWebViewer->StopLoading();
2905 RequestRedraw(true);
2910 MainForm::OnReaderClicked(const Addressbar& addBar)
2912 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2914 CreateReaderPanel();
2915 AppLogDebug("MainScene::OnReaderClicked entered");
2918 /*if (__pArticleReaderPanel)
2920 AppLogDebug("showstate true for reader panel");
2921 __pArticleReaderPanel->SetShowState(true);
2922 __pArticleReaderPanel->Show();
2924 int xPos = __pArticleReaderPanel->GetX();
2925 int yPos = __pArticleReaderPanel->GetY();
2926 AppLog("OnReaderClicked() xPos = %d",xPos);
2927 AppLog("OnReaderClicked() yPos = %d",yPos);
2929 if (__pReaderData == null)
2934 String loadData = L"<html>\
2936 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2941 background-color: transparent;\
2960 <body style='width:'";
2961 loadData.Append(bodyWidth);
2962 loadData.Append(L"px'>");
2963 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2964 loadData.Append(*__pReaderData);
2965 loadData.Append(L"</body></html>");
2968 buf.Construct(loadData.GetLength());
2969 AppLogDebug("data->GetLength %d",loadData.GetLength());
2970 for (int z=0;z<loadData.GetLength();z++)
2973 loadData.GetCharAt(z,b);
2974 buf.SetByte((byte)b);
2978 if (__pWebReader != null)
2980 __pWebReader->LoadData(L"",buf,L"text/html");
2981 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2985 AppLogDebug("cannot LoadData __pWebReader is null");
2991 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2993 // AppLog("MainForm::OnBackClicked");
2994 result r = E_FAILURE;
2996 if (__pWebViewer && __pWebViewer->CanGoBack())
2998 __pWebViewer->GoBack();
3000 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3003 pApp = UiApp::GetInstance();
3006 r = pApp->Terminate();
3009 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3017 WindowInfo* pWindowInfo = null;
3019 SceneManager* pSceneManager = SceneManager::GetInstance();
3020 if (pSceneManager == null)
3024 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3025 if (pAllWindowList == NULL)
3027 pApp = UiApp::GetInstance();
3030 r = pApp->Terminate();
3033 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3038 if (pAllWindowList != null)
3040 totalCount = pAllWindowList->GetCount();
3042 for (int count = 0; count < totalCount; count++)
3044 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3045 if (pWindowInfo == null)
3047 pApp = UiApp::GetInstance();
3050 r = pApp->Terminate();
3053 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3058 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3060 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3063 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3066 r = pAllWindowList->RemoveAt(count, true);
3067 __pWindowInfo = null;
3070 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3075 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3079 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3081 if (pWindowInfo == null)
3083 pApp = UiApp::GetInstance();
3086 r = pApp->Terminate();
3092 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3095 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3109 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3111 AppLog("MainForm::OnForwardClicked");
3112 if (__pWebViewer == null)
3115 if (__pWebViewer->CanGoForward())
3117 __pWebViewer->GoForward();
3122 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3124 result r = E_SUCCESS;
3126 __pFooterPanel->SetShowState(true);
3127 __pFooterUrlField->SetFocusable(true);
3130 __pWebViewer->SetFocus();
3131 else if(__pMostVisitedListView)
3132 __pMostVisitedListView->SetFocus();
3133 else if(__pMultiWindowButton)
3134 __pMultiWindowButton->SetFocus();
3135 __pMoreButton->SetFocus();
3137 __pAddressbar->SetShowState(false);
3139 RelayoutControls(false,false);
3144 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3146 __prevAddressBarMode = __curAddressBarMode;
3148 if (__pAddressbar != null)
3150 __curAddressBarMode = GetAddressbarMode();
3153 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3155 __adressPanelPosition.y = 0;
3156 if (__pAddressbar != null)
3158 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3159 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3160 __pAddressbar->Invalidate(true);
3162 if (__pWebViewer != null)
3164 __pWebViewer->StopLoading();
3167 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3169 __adressPanelPosition.y = 0;
3170 if (__pAddressbar != null)
3172 __webControlPosition.y = 0;
3173 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3174 __pAddressbar->Invalidate(true);
3180 MainForm::OnClipboardClosed(const Addressbar& addBar)
3182 RelayoutControls(false);
3186 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3189 __pAddressbar->SetShowState(false);
3191 __pFooterPanel->SetShowState(true);
3193 // __pWebViewer->SetFocus();
3194 if(__pFooterUrlField)
3196 __pFooterUrlField->SetFocusable(true);
3198 RelayoutControls(false,footerState);
3202 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3204 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
3206 __pAddressbar->SetShowState(false);
3210 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3212 __pAddressbar->SetShowState(true);
3213 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3214 __pAddressbar->SetAddressbarURLFocus();
3218 RelayoutControls(false);
3222 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3224 __pFooterPanel->SetShowState(false);
3228 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3230 AppLog("KeypadBoundsChanged");
3231 RelayoutControls(false);
3235 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3239 __pWindowInfo->pageTitle = title;
3240 if (__pWebViewer != null)
3242 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3245 if (__pAddressbar != null && __pWebViewer != null)
3247 SetUrl(__pWebViewer->GetUrl());
3248 __pAddressbar->Invalidate(true);
3253 MainForm::UpdateFavicon(void)
3255 bool urlImageType = false;
3256 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();");
3257 Bitmap* pBitmap = null;
3259 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3261 if (__pWindowInfo != null)
3264 url.SetUri(*tempPath);
3265 if (url.GetHost().GetLength() == 0)
3268 webUrl.SetUri(__pWebViewer->GetUrl());
3269 result r = url.SetHost(webUrl.GetHost());
3276 if (url.GetScheme().GetLength() == 0)
3279 webUrl.SetUri(__pWebViewer->GetUrl());
3280 url.SetScheme(webUrl.GetScheme());
3282 __pWindowInfo->faviconUrl = url.ToString();
3284 pBitmap = __pWebViewer->GetFaviconN();
3286 if (pBitmap != null)
3288 if (__pWindowInfo->pFavicon != NULL)
3290 __pWindowInfo->pFavicon = null;
3292 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3293 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3295 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3297 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3299 else if(__pWindowInfo->pFavicon != null)
3301 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3305 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3306 if(pDefaultBmp != null)
3308 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3317 if(tempPath != null)
3321 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3328 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3329 Tizen::Web::Controls::WebNavigationType type)
3331 // when load new page if find word panel is open its show state is false
3332 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3334 __currentSearchStr = L"";
3335 __currentWordIndex = 0;
3336 __maxOccurrances = 0;
3337 __pFindWordEditField->SetText(L"");
3338 __pFindWordNext->SetEnabled(false);
3339 __pFindWordPrev->SetEnabled(false);
3340 __pFindWordCountLabel->SetText(L"0/0");
3341 // __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3342 __pFindWordControl->SetShowState(false);
3343 __pFindWordEditField->HideKeypad();
3346 // ShowFindWordPanel(false);
3348 __pFooterPanel->Invalidate(true);
3351 uriInfo.SetUri(url);
3353 if(url.Contains(IDS_TIZEN_SERVICE))
3356 String delim(L":;,");
3358 // Creates a StringTokenizer instance
3359 StringTokenizer strTok(url, delim);
3361 int count = strTok.GetTokenCount(); // count == 4
3363 HashMap *pMap = new HashMap();
3369 while (strTok.HasMoreTokens())
3371 AppLog("Token: %ls", token.GetPointer());
3372 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3373 if(token.Contains(IDS_APPID))
3375 token.SubString(6, appId);
3376 AppLog("AppID:%ls", appId.GetPointer());
3378 else if(token.Contains("="))
3380 String *pKey = new String();
3381 String *pValue = new String();
3383 token.IndexOf("=", 0, index);
3386 token.SubString(0, index, *pKey);
3387 token.SubString(index + 1, *pValue);
3388 pMap->Add(pKey, pValue);
3394 AppControl *pAppControl = null;
3395 String operationId = L"http://tizen.org/appcontrol/operation/main";
3396 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3399 result r = pAppControl->Start(null, null, pMap, null);
3403 AppLogException("AppControl not found");
3413 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3414 const Tizen::Net::Http::HttpHeader& httpHeader)
3416 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3421 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3423 AppLog("MainForm::OnWebPageBlockSelected");
3424 if (__pHitElementResult != null)
3426 delete __pHitElementResult;
3427 __pHitElementResult = null;
3430 if (__pWebViewer != null)
3432 AppLog("MainForm::OnWebPageBlockSelected web not null");
3433 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3436 if (__pHitElementResult == null)
3441 if (__pHitElementResult->HasImage() != true)
3443 String tagName = __pHitElementResult->GetTagName();
3444 String type = __pHitElementResult->GetAttributeValue("type");
3446 __currentSelectedStr.Clear();
3447 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3448 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3449 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3451 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
3453 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3455 InitSelectTextContextMenu(endPoint,true);
3456 __pImageMenu->SetShowState(true);
3457 __pImageMenu->Show();
3458 __pImageMenu->Invalidate(true);
3460 else if(__isLongPressedDone == true)
3462 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3464 if(__pHitElementResult->GetUrl().GetLength() > 0)
3466 __currentSelectedStr.Clear();
3467 __currentSelectedStr = __pHitElementResult->GetUrl();
3469 InitSelectTextContextMenu(endPoint,false);
3470 __pImageMenu->SetShowState(true);
3471 __pImageMenu->Show();
3472 __pImageMenu->Invalidate(true);
3475 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3476 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3477 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3483 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3489 MainForm::OnWebWindowCreateRequested(void)
3491 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3493 if (pNewWindowInfo == null)
3497 result r = E_SUCCESS;
3498 SceneManager* pSceneManager = SceneManager::GetInstance();
3499 if (pSceneManager == NULL)
3503 ArrayList* pArgList = new(std::nothrow) ArrayList();
3504 if (pArgList == NULL)
3508 r = pArgList->Construct();
3511 pNewWindowInfo->isJavascriptInitiated = true;
3512 pArgList->Add(*pNewWindowInfo);
3513 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3517 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3524 return pNewWindowInfo->pCurrentWeb;
3528 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3530 __webControlPosition.y = 0;
3531 __webControlHeight = GetClientAreaBounds().height;
3532 AppLog("Client area height: %d", __webControlHeight);
3534 AppLog("Client area height: %d", __webControlHeight);
3535 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3537 __webControlPosition.y += __pAddressbar->GetHeight();
3538 __webControlHeight -= __pAddressbar->GetHeight();
3539 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3541 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3543 __webControlPosition.y += __pFindWordControl->GetHeight();
3544 __webControlHeight -= __pFindWordControl->GetHeight();
3545 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3548 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3550 __webControlHeight -= __pFooterPanel->GetHeight();
3552 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3554 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3556 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3557 __pWebViewer->Invalidate(false);
3559 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3561 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3568 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3570 if (__pFindWordControl == null)
3576 InitFindWordPanel();
3577 // __pFindWordEditField->SetText(__currentSearchStr);
3578 //__pFindWordCountLabel->SetText(L"");
3579 // __pFindWordCountLabel->SetText(L"0/0");
3580 __pFindWordControl->SetShowState(true);
3584 if(__pFindWordControl != null)
3586 __pFindWordControl->SetShowState(false);
3590 AppLog("MainForm::ShowFindWordPanel %d",show);
3591 if (show && !isTouchPressed)
3593 if (__pFindWordEditField)
3595 __pFindWordEditField->SetFocus();
3596 __pFindWordEditField->ShowKeypad();
3601 if (__pFindWordEditField)
3602 __pFindWordEditField->HideKeypad();
3605 RelayoutControls(false);
3609 MainForm::StartWordSearch()
3611 //Get the count of occurances of the word in the current page
3612 __maxOccurrances = 0;
3613 __currentWordIndex = 0;
3615 __pFindWordPrev->SetEnabled(false);
3616 String *pCountStr = null;
3617 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3618 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3619 if (pCountStr != null)
3621 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3625 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3630 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3632 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3633 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3635 if(totalCount == -1 || totalCount == 0)
3637 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3638 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3641 else if(totalCount > 100)
3643 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3644 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3648 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3649 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3652 __maxOccurrances = totalCount;
3653 __currentWordIndex = currentOrdinal;
3655 //Reset the UI controls as per the maxOccurrance value
3656 if (totalCount <= 0)
3658 AppLog("Word not found");
3659 //Show error notification to user
3660 __pFindWordNext->SetEnabled(false);
3661 __pFindWordCountLabel->SetText(L"0/0");
3662 __pFindWordNext->Invalidate(false);
3663 __pFindWordPrev->Invalidate(false);
3664 __pFindWordCountLabel->Invalidate(false);
3668 if (totalCount == 1)
3670 __pFindWordNext->SetEnabled(false);
3674 __pFindWordNext->SetEnabled(true);
3677 String countStr = L"";
3678 countStr.Append(__currentWordIndex);
3679 countStr.Append(L"/");
3680 countStr.Append(__maxOccurrances);
3681 __pFindWordCountLabel->SetText(countStr);
3682 // __pFindWordCountLabel->SetShowState(true);
3683 __pFindWordCountLabel->Invalidate(false);
3685 //FindNextWord(true);
3686 //Update the controls
3687 __pFindWordNext->Invalidate(false);
3688 __pFindWordPrev->Invalidate(false);
3689 __pFindWordCountLabel->Invalidate(false);
3693 MainForm::FindNextWord(bool next)
3697 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3699 if(__currentWordIndex < __maxOccurrances)
3701 __currentWordIndex++;
3707 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3709 if(__currentWordIndex > 1)
3711 __currentWordIndex--;
3716 String countStr = L"";
3717 countStr.Append(__currentWordIndex);
3718 countStr.Append(L"/");
3719 countStr.Append(__maxOccurrances);
3720 __pFindWordCountLabel->SetText(countStr);
3721 // __pFindWordCountLabel->SetShowState(true);
3722 __pFindWordCountLabel->Invalidate(false);
3723 if (__currentWordIndex >= __maxOccurrances)
3725 __pFindWordNext->SetEnabled(false);
3729 __pFindWordNext->SetEnabled(true);
3731 if (__currentWordIndex <= 1)
3733 __pFindWordPrev->SetEnabled(false);
3737 __pFindWordPrev->SetEnabled(true);
3739 __pFindWordPrev->Invalidate(false);
3740 __pFindWordNext->Invalidate(false);
3741 __pFindWordCountLabel->Invalidate(false);
3742 __pFindWordControl->Invalidate(true);
3745 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3747 AppLog("MainForm::OnWebKeypadWillOpen");
3748 __isWebKeypadOpened = true;
3749 // OnAddressBarKeypadOpened(*__pAddressbar);
3753 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3756 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3758 __currentSearchStr = L"";
3759 __currentWordIndex = 0;
3760 __maxOccurrances = 0;
3761 __pFindWordEditField->SetText(L"");
3762 __pFindWordNext->SetEnabled(false);
3763 __pFindWordPrev->SetEnabled(false);
3764 __pFindWordCountLabel->SetText(L"0/0");
3765 __pWebViewer->SearchTextAllAsync(L"",false);
3766 __pFindWordControl->SetShowState(false);
3767 __pFindWordEditField->HideKeypad();
3771 if (__pWebViewer != null && __pFooterPanel != null)
3773 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3774 if(__pAddressbar != null)
3776 __pAddressbar->SetShowState(false);
3778 if(__pFindWordControl != null)
3780 __pFindWordControl->SetShowState(false);
3782 __pFooterPanel->SetShowState(false);
3783 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3785 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
3787 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
3788 // AppLog("omgomgomg");
3794 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3796 __pFooterPanel->SetShowState(true);
3797 OnAddressBarKeypadClosed(*__pAddressbar);
3798 __isWebKeypadOpened = false;
3802 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3804 Control* temp = const_cast< Control* >(&source);
3805 Header* pHeader = dynamic_cast< Header* >(temp);
3806 if (pHeader != null)
3808 //Header double - clicked
3809 AppLog("Header double clicked");
3811 if(__pFindWordControl)
3813 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3814 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3818 AppLog("MainScene::OnTouchDoublePressed");
3819 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3820 if (isReaderEnabled == true)
3824 delete __pReaderData;
3825 __pReaderData = null;
3827 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3828 filePath.Append(L"data/reader.js");
3834 result r = E_SUCCESS;
3835 FileAttributes attr;
3837 File::GetAttributes(filePath,attr);
3839 r = file.Construct(filePath, L"r+");
3842 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3845 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3848 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3851 file.Read(pScript,attr.GetFileSize());
3853 AppLogDebug("scipt length %d",strlen(pScript));
3854 String strScript = L"";
3855 strScript.Append(pScript);
3856 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3859 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3862 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3863 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3865 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3866 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3872 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3874 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
3876 if (__pHitElementResult != null)
3878 delete __pHitElementResult;
3879 __pHitElementResult = null;
3882 if (__pWebViewer != null)
3884 AppLog("MainForm::OnTouchLongPressed web not null");
3885 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3888 if (__pHitElementResult == null)
3893 if (__pHitElementResult->HasImage() == true)
3895 InitImageContextMenu(currentPosition);
3896 __pImageMenu->SetShowState(true);
3897 __pImageMenu->Show();
3898 __pImageMenu->Invalidate(true);
3900 else if(__pHitElementResult->HasUrl() == true)
3902 String tempURl = __pHitElementResult->GetUrl();
3903 AppLog("tempURl is %ls", tempURl.GetPointer());
3904 const Bitmap* pBitmap = __pHitElementResult->GetImage();
3905 if (pBitmap != null)
3913 InitImageLinkContextMenu(currentPosition);
3914 __pImageMenu->SetShowState(true);
3915 __pImageMenu->Show();
3916 __pImageMenu->Invalidate(true);
3920 String tagName = __pHitElementResult->GetTagName();
3921 String type = __pHitElementResult->GetAttributeValue("type");
3922 String value = __pHitElementResult->GetAttributeValue(L"value");
3923 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3925 __currentSelectedStr.Clear();
3926 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3928 AppLog("tag name is %ls", tagName.GetPointer());
3929 AppLog("type is %ls", type.GetPointer());
3930 AppLog("innerHtml is %ls", innerHtml.GetPointer());
3932 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3934 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3936 InitSelectTextContextMenu(currentPosition,true, true);
3939 __pImageMenu->SetShowState(true);
3940 __pImageMenu->Show();
3941 __pImageMenu->Invalidate(true);
3944 __isLongPressedDone = true;
3945 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
3946 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
3949 __inputEventToBeSupressed = true;
3953 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3955 AppLog("MainForm::OnTouchReleased");
3957 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3958 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3960 __pWebViewer->ConsumeInputEvent();
3962 if(pHitElement != null)
3966 __inputEventToBeSupressed = false;
3970 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3977 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3979 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3981 __currentSearchStr = L"";
3982 __currentWordIndex = 0;
3983 __maxOccurrances = 0;
3984 __pFindWordEditField->SetText(L"");
3985 __pFindWordNext->SetEnabled(false);
3986 __pFindWordPrev->SetEnabled(false);
3987 __pFindWordCountLabel->SetText(L"0/0");
3988 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3989 __pFindWordControl->SetShowState(false);
3990 __pFindWordEditField->HideKeypad();
3992 if(__pAddressbar->GetShowState() == false)
3994 __pAddressbar->SetShowState(true);
3995 __pAddressbar->SetAddressbarURLFocus();
3996 __pFooterUrlField->SetFocusable(false);
3997 __pFooterPanel->SetShowState(false);
4004 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4010 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4016 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4022 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4028 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4034 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4036 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4037 int widthContextItem = 0;
4039 // As per the platform engineer comment removed this line
4040 /*if(__pWebViewer != null)
4042 // 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
4043 __pWebViewer->ReleaseBlock();
4046 if(__pFindWordControl != null)
4047 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4048 if ( __pFooterLabel != null)
4050 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4053 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4058 if (__pFindWordBgLabel != null)
4060 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4061 if (pBitmap != null)
4063 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4069 __pMenu->SetShowState(false);
4070 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4072 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4076 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4081 AppLog("__pFooterPanel->GetShowState() is true");
4083 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4084 __pFooterPanel->Invalidate(true);
4088 if(__pMoreButton && __pMenu)
4090 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
4091 __pMenu->SetAnchorPosition(p);
4092 __pMenu->Invalidate(true);
4095 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4096 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4098 InitMostVisitedSitesView(orientationStatus);
4101 RelayoutControls(false);
4102 if (__pArticleReaderPanel != null)
4104 if (__pArticleReaderPanel->GetShowState() == true)
4106 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4108 if (__pBlankPanel != null)
4109 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4111 if (__pWebReader != null)
4113 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4115 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4116 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4118 if ( pBitmap != null && pSrcBitmap != null)
4120 AppLog("CreateReaderPanel ninepatchbitmap found");
4121 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4124 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4125 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4126 if (pBitmap != null)
4131 if (pSrcBitmap != null)
4140 if (__pAddressbar != null)
4142 int width = GetClientAreaBounds().width;
4143 __pAddressbar->OrientationChanged(width);
4148 MainForm::OnSettingsChange(int settingvalue)
4150 AppLogDebug("MainForm::OnSettingsChange entered");
4152 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4154 __pAddressbar->ResetGuideText();
4156 if (__pWebViewer == null)
4158 AppLogDebug("Webviewer is not initialized yet.");
4162 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4164 WebSetting settings = __pWebViewer->GetSetting();
4165 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4167 settings.SetAutoFittingEnabled(true);
4169 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
4171 settings.SetAutoFittingEnabled(false);
4173 __pWebViewer->SetSetting(settings);
4175 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4177 WebSetting settings = __pWebViewer->GetSetting();
4178 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4179 __pWebViewer->SetSetting(settings);
4181 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4183 WebSetting settings = __pWebViewer->GetSetting();
4184 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4185 __pWebViewer->SetSetting(settings);
4187 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4189 WebSetting settings = __pWebViewer->GetSetting();
4190 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4191 __pWebViewer->SetSetting(settings);
4193 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4197 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4201 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4203 WebSetting settings = __pWebViewer->GetSetting();
4204 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4206 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4210 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4212 __pWebViewer->SetSetting(settings);
4214 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4218 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4219 WebSetting settings = __pWebReader->GetSetting();
4220 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4221 __pWebReader->SetSetting(settings);
4227 MainForm::OnSettingsReset()
4231 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4232 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4237 MainForm::OnClearCache()
4239 result r = E_SUCCESS;
4241 if (__pWebViewer != NULL)
4243 r = __pWebViewer->ClearCache();
4246 AppLogDebug("Cache cleared success");
4250 AppLogDebug("Cache cleared fail");
4256 MainForm::OnClearCookie()
4258 result r = E_SUCCESS;
4260 if (__pWebViewer != NULL)
4262 __pWebViewer->ClearCookie();
4266 AppLogDebug("Cookie cleared success");
4270 AppLogDebug("Cache cleared fail");
4275 MainForm::OnClearFormData()
4277 result r = E_SUCCESS;
4279 if (__pWebViewer != NULL)
4281 __pWebViewer->ClearFormData();
4285 AppLogDebug("Cookie cleared success");
4289 AppLogDebug("Cache cleared fail");
4294 MainForm::OnClearPasswords()
4296 result r = E_SUCCESS;
4298 if (__pWebViewer != NULL)
4300 __pWebViewer->ClearLoginFormData();
4304 AppLogDebug("Cookie cleared success");
4308 AppLogDebug("Cache cleared fail");
4314 MainForm::findDistance(int x1,int y1,int x2, int y2)
4316 int deltaX = Math::Abs(x2 - x1);
4317 int deltaY = Math::Abs(y2 - y1);
4318 double num = deltaX*deltaX + deltaY*deltaY;
4324 for (i = 0; i < 20; i++)
4326 x = (((x*x)+ num)/(2*x));
4337 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4339 if(__pFindWordControl)
4341 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4342 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4344 __isLongPressedDone = false;
4347 IList* pList = null;
4348 pList = touch.GetTouchInfoListN(source);
4352 int count = pList->GetCount();
4355 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4356 __touchPoint1 = pTouchInfo->position;
4358 /*if (__pAddressbar != null)
4360 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4362 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4364 __pAddressbar->SaveAddressbarEditText();
4366 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4369 __pAddressbar->Invalidate(true);
4371 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4373 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4375 //__pAddressbar->SaveAddressbarEditText();
4377 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4380 else if (count == 2)
4382 AppLogDebug("MainForm::OnTouchPressed count is two");
4383 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4384 __touchPoint1 = pTouchInfo->position;
4386 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4387 __touchPoint2 = pTouchInfo->position;
4393 pList->RemoveAll(true);
4400 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4402 // __currentWordIndex = 0;
4403 __isLongPressedDone = false;
4408 MainForm::MoveUiControls()
4413 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4415 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4417 if(__pFooterUrlField->GetTextLength() == 0)
4419 __pFooterUrlField->SetKeypadActionEnabled(false);
4423 __pFooterUrlField->SetKeypadActionEnabled(true);
4426 if (__pFindWordEditField != null)
4428 __currentSearchStr = __pFindWordEditField->GetText();
4429 __pFindWordNext->SetEnabled(false);
4430 __pFindWordPrev->SetEnabled(false);
4431 __pFindWordNext->Invalidate(true);
4432 __pFindWordPrev->Invalidate(true);
4433 __pFindWordCountLabel->SetText(L"0/0");
4434 __pFindWordCountLabel->Invalidate(true);
4436 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4437 if (__currentSearchStr.GetLength() > 0)
4443 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4445 __currentSearchStr = L"";
4446 AppLogDebug("Enter something");
4451 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4458 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4460 if(__pWebViewer != null)
4463 AppLog("MainForm::InitMostVisitedSitesView");
4464 result r = E_SUCCESS;
4467 if (__pWebViewer != null && __pMostVisitedListView != null)
4472 if (__pMostVisitedListView != null)
4474 RemoveControl(__pMostVisitedListView);
4476 if(__pMostVisitedSites != null)
4478 __pMostVisitedSites->RemoveAll(true);
4481 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4483 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4484 __pMostVisitedListView = new(std::nothrow) ListView();
4486 int height = GetClientAreaBounds().height;
4488 if(__pFooterPanel->GetShowState() == true)
4490 height = height - __pFooterPanel->GetHeight();
4492 if(__pAddressbar->GetShowState() == true)
4494 height -= __pAddressbar->GetHeight();
4497 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4501 delete __pMostVisitedListView;
4502 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4505 __pMostVisitedListView->SetItemProvider(*this);
4506 __pMostVisitedListView->AddListViewItemEventListener(*this);
4507 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4508 AddControl(__pMostVisitedListView);
4509 __pMostVisitedListView->UpdateList();
4516 MainForm::GetImagePath(void)
4520 String formattedTime;
4521 DateTime currentTime;
4522 LocaleManager localManager;
4523 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4525 localManager.Construct();
4526 Locale locale = localManager.GetSystemLocale();
4527 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4529 // Get date formatter
4530 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4534 pTimeFormatter->Format(currentTime, formattedTime);
4537 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4538 String delim(L" :");
4539 StringTokenizer strTok(formattedTime, delim);
4542 String str1("GMT+00");
4543 while (strTok.HasMoreTokens())
4545 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4546 if(token.Equals(str1))
4548 AppLog("token is %ls", token.GetPointer());
4549 imageName.Append(token);
4555 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4557 result r = E_FAILURE;
4558 AppLog("Content manager 1");
4559 ContentId contentId;
4560 ContentManager contentManager;
4561 r = contentManager.Construct();
4564 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4567 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4568 contentPath.Append(imageName);
4569 contentPath.Append(".jpg");
4570 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4571 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4575 MainForm::SetForwardButtonEnabled(bool isEnabled)
4577 __pGoForwardBtn->SetEnabled(isEnabled);
4578 __pGoForwardBtn->Invalidate(true);
4582 MainForm::SetBackButtonEnabled(bool isEnabled)
4584 __pGoBackBtn->SetEnabled(isEnabled);
4585 __pGoBackBtn->Invalidate(true);
4589 MainForm::UpdateProgress(int percentage)
4591 __progressPercentage = percentage;
4592 if (percentage == 0 || percentage == 100)
4594 __isLoadingData = false;
4595 if (percentage == 100)
4597 __isLoadingCompleted = true;
4598 __progressPercentage = 0;
4602 __isLoadingCompleted = false;
4607 __isLoadingData = true;
4609 UpdateProgressBitmap();
4613 MainForm::GetProgress(void)
4615 return __progressPercentage;
4619 MainForm::UpdateProgressBitmap(void)
4621 result r = E_SUCCESS;
4622 if (__pProgressbarLabel == null)
4624 int w = __pProgressbarLabel->GetWidth();
4625 int h = __pProgressbarLabel->GetHeight();
4627 int progressWidth = 0;
4628 Bitmap* pRetBitmap = null;
4630 if (__progressPercentage == 0 || __progressPercentage == 100)
4632 __pProgressbarLabel->SetShowState(false);
4633 __pProgressbarLabel->Invalidate(false);
4638 __pProgressbarLabel->SetShowState(true);
4639 __pProgressbarLabel->Invalidate(false);
4642 r = canvas.Construct(Rectangle(0, 0, w, h));
4646 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4651 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4655 pBgBmp->Scale(Dimension(w, h));
4656 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4660 progressWidth = (double) (w) * __progressPercentage / 100;
4661 AppLogDebug("progressWidth: %d", progressWidth);
4662 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4664 if (pProgressBmp != null)
4666 pProgressBmp->Scale(Dimension(progressWidth, h));
4667 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4668 delete pProgressBmp;
4671 pRetBitmap = new (std::nothrow) Bitmap();
4673 if (pRetBitmap == null)
4675 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4679 pRetBitmap->Construct(canvas, canvas.GetBounds());
4681 if (__pProgressbarLabel != null && pRetBitmap != null)
4683 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4684 __pProgressbarLabel->Invalidate(false);
4687 if (pRetBitmap != null)
4695 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4697 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4699 __currentAddMode = addMode;
4703 case ADDRESSBAR_MODE_INVALID:
4708 case ADDRESSBAR_MODE_READER:
4710 __pStopBtn->SetShowState(false);
4711 __pClearBtn->SetShowState(false);
4714 case ADDRESSBAR_MODE_LOADING:
4716 __pRefreshBtn->SetShowState(false);
4717 __pStopBtn->SetShowState(true);
4718 __pClearBtn->SetShowState(false);
4721 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4723 // SetUrl(__pAddressbar->GetUrl());
4725 __pRefreshBtn->SetShowState(true);
4726 __pStopBtn->SetShowState(false);
4727 __pClearBtn->SetShowState(false);
4730 case ADDRESSBAR_MODE_EDIT:
4732 __pRefreshBtn->SetShowState(false);
4733 __pStopBtn->SetShowState(false);
4734 __pClearBtn->SetShowState(true);
4741 OnAddressBarModeChanged();
4744 AddressBarMode MainForm::GetAddressbarMode(void)
4746 return __currentAddMode;
4749 void MainForm::SetUrl(const String& url)
4753 if (__pFooterUrlField != NULL)
4755 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4756 if (removedHttpUrl.IsEmpty() == false)
4758 __pFooterUrlField->SetText(removedHttpUrl);
4759 if(__pAddressbar != NULL)
4760 __pAddressbar->SetUrl(__displayUrl);
4764 __pFooterUrlField->SetText(__displayUrl);
4765 if(__pAddressbar != NULL)
4766 __pAddressbar->SetUrl(__displayUrl);
4768 if(__pFooterUrlField)
4769 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
4770 __pFooterUrlField->Invalidate(false);
4771 if(__pAddressbar != NULL)
4772 __pAddressbar->Invalidate(true);
4773 // __pFooterUrlField->SetCursorPosition(0);
4778 MainForm::RemoveHttpTextFromDisplayURL(void)
4780 bool isHttpText = __displayUrl.Contains(L"http://");
4781 String updatedDisplayUrl;
4782 updatedDisplayUrl.Clear();
4784 if (isHttpText == true)
4786 __displayUrl.SubString(7,updatedDisplayUrl);
4788 return updatedDisplayUrl;
4791 void MainForm::OnSharePopupControlStarted(void)
4793 __pWebViewer->AddTouchEventListener(*this);
4796 void MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
4798 if (requestId == BACK_GROUND_APP_EVENT)
4800 if(__pWebViewer != null)
4802 __pWebViewer->Pause();
4805 else if(requestId == FORE_GROUND_APP_EVENT)
4807 if(__pWebViewer != null)
4809 __pWebViewer->Resume();