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;
119 const int IDA_READER_BTN_CLICKED = 219;
122 const int IDA_HYPERLINK_OPEN_CLICKED = 220;
123 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221;
124 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
125 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
127 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
129 const int MainForm::IDA_FORMAT_BITMAP = 500;
130 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
131 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
132 const int MainForm::IDA_FORMAT_URL_STRING = 503;
133 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
135 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
136 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
137 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
139 MainForm::MainForm(void)
141 __isLongPressedDone = false;
143 __pAddressbar = null;
144 // __pMostVisitedSitesPanel = null;
145 __pMostVisitedListView = null;
146 __pFooterPanel = null;
147 __pHitElementResult = null;
148 __pWindowInfo = null;
152 __pFindWordControl = null;
154 __pFindWordBgLabel = null;
155 __pFindWordEditField = null;
156 __pFindWordClear = null;
157 __pFindWordCountLabel = null;
158 __pFindWordNext = null;
159 __pFindWordPrev = null;
160 __previousZoomLevel = 1.0;
162 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
165 __currentSearchStr = L"";
166 __currentSelectedStr = L"";
167 __maxOccurrances = 0;
168 __currentWordIndex = 0;
171 //__inputEventToBeSupressed = false;
172 __isLoadingData = false;
173 __isLoadingCompleted = false;
174 __progressPercentage = 0;
175 __touchPoint1 = Point(-1,-1);
176 __touchPoint2 = Point(-1,-1);
178 // __pReaderPopup = null;
179 __pReaderData = null;
181 __pReaderCloseBtn = null;
182 //__pNewWindowButton = null;
183 __pMoreButton = null;
184 __pMultiWindowButton = null;
185 __pArticleReaderPanel = null;
186 __pBlankPanel = null;
187 __pArticleReaderLabel = null;
188 __webControlHeight = 0;
189 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
190 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
191 __pMostVisitedSites = null;
192 __pFooterUrlField = null;
194 __pGoForwardBtn = null;
195 __pRefreshBtn = null;
196 __pProgressbarLabel = null;
197 __pFooterLabel = null;
201 __isWebKeypadOpened = false;
204 MainForm::~MainForm(void)
206 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
210 __pAddressbar->SetAddressbarEventListener(null);
213 if(__pHistory != null)
219 if (__pReaderData != null)
221 delete __pReaderData;
222 __pReaderData = null;
225 if (__pPopUp != null)
231 if (__pHitElementResult != null)
233 delete __pHitElementResult;
234 __pHitElementResult = null;
237 String* pSelectedScene = NULL;
238 Object* pValue = NULL;
239 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
240 pSelectedScene = (String*) pValue;
242 /*if (pSelectedScene != null)
244 delete pSelectedScene;
246 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
250 MainForm::Initialize(void)
252 Construct(L"IDL_FORM");
257 MainForm::OnInitializing(void)
259 AppLog("get client area width = %d",GetClientAreaBounds().width);
260 AppLog("get client area height = %d",GetClientAreaBounds().height);
261 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
262 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
264 Panel* pFooterPanel = null;
266 __pSaveImage = new Image();
267 __pSaveImage->Construct();
269 // Setup back event listener
270 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
271 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
272 AddOrientationEventListener(*this);
273 AppLogDebug(" MainForm::OnInitializing ended");
274 if (__pMostVisitedSites == null)
276 __pMostVisitedSites = new(std::nothrow) ArrayList();
277 __pMostVisitedSites->Construct();
279 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
281 __pItemContext= new(std::nothrow) ListContextItem();
282 __pItemContext->Construct();
283 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
284 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
286 if (pBitmapNormal != null && pBitmapPressed != null)
288 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
291 if (pBitmapNormal != null)
293 delete pBitmapNormal;
296 if (pBitmapPressed != null)
298 delete pBitmapPressed;
301 __pItemContextLandscape= new(std::nothrow) ListContextItem();
302 __pItemContextLandscape->Construct();
303 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
304 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
306 if (pBitmapNormal != null && pBitmapPressed != null)
308 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
311 if (pBitmapNormal != null)
313 delete pBitmapNormal;
316 if (pBitmapPressed != null)
318 delete pBitmapPressed;
325 MainForm::InitAddressbar(void)
327 AppLogDebug("MainForm::InitAddressbar entered");
329 result r = E_SUCCESS;
331 if (__pAddressbar != null)
335 __pAddressbar = new(std::nothrow) Addressbar();
336 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
337 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
340 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
343 __pAddressbar->SetAddressbarEventListener(this);
344 AddControl(__pAddressbar);
345 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
346 SetControlAlwaysOnTop(*__pAddressbar, true);
347 __adressPanelPosition = __pAddressbar->GetPosition();
349 AppLogDebug("MainForm::InitAddressbar exit");
355 MainForm::CreateReaderPanel(void)
357 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
358 result r = E_FAILURE;
360 Button *pSmallFontBtn = null;
361 Button *pLargeFontBtn = null;
363 __pBlankPanel = new (std::nothrow) Panel();
364 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
366 __pArticleReaderPanel = new (std::nothrow) Panel();
367 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
369 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
370 if (__pReaderCloseBtn)
372 AppLogDebug("CreateReaderPanel() 6");
373 __pReaderCloseBtn->AddActionEventListener(*this);
374 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
377 __pWebReader = new (std::nothrow) Web();
378 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
380 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
381 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
383 r = __pWebReader->SetSetting(settings);
385 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
388 __pArticleReaderLabel = new Label();
389 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
391 __pBlankPanel->AddControl(__pArticleReaderLabel);
392 __pBlankPanel->AddControl(__pArticleReaderPanel);
393 AddControl(__pBlankPanel);
395 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
396 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
397 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
399 __pArticleReaderPanel->AddControl(__pWebReader);
400 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
401 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
402 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
404 if (pBitmap != null && pSrcBitmap != null)
406 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
408 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
410 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
413 pSmallFontBtn->AddActionEventListener(*this);
414 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
417 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
420 pLargeFontBtn->AddActionEventListener(*this);
421 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
430 if (pSrcBitmap != null)
436 SetControlAlwaysOnTop(*__pBlankPanel, true);
437 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
444 MainForm::InitWebControl()
446 AppLogDebug("MainForm::InitWebControl enter");
447 result r = E_SUCCESS;
448 AppLogDebug("InitWebControl");
450 if (__pAddressbar == null || __pFooterPanel == null)
453 const int Y_WEBCONTROL_POSITION = 0;
454 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
455 if (__pMostVisitedListView)
457 __pMostVisitedListView->SetShowState(false);
459 if (__pWebViewer != null)
461 AppLogDebug("Already initialized");
464 __pWebViewer = new(std::nothrow) Web();
465 if(__pWebViewer == NULL)
467 AppLogDebug("Initialization failed");
470 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
474 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
481 r = AddControl(__pWebViewer);
487 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
490 __webControlPosition = __pWebViewer->GetPosition();
491 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
494 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
498 __pWebViewer->SetLoadingListener(this);
499 __pWebViewer->SetWebUiEventListener(this);
500 __pWebViewer->SetWebKeypadEventListener(this);
501 __pWebViewer->SetFocus();
502 __pWebViewer->AddTouchEventListener(*this);
504 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
505 __pWebViewer->SetTextSearchListener(this);
508 AppLogDebug("MainForm :before return");
510 AppLogDebug("MainForm::InitWebControl Exit");
516 MainForm::OnFocusGained(const Control& source)
518 AppLog("MainForm::OnFocusGained");
522 MainForm::OnFocusLost(const Control& source)
524 AppLog("MainForm::OnFocusLost");
528 MainForm::SetJavascriptEnabled()
530 WebSetting settings = __pWebViewer->GetSetting();
531 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
532 __pWebViewer->SetSetting(settings);
536 MainForm::SetImageLoadEnabled()
538 WebSetting settings = __pWebViewer->GetSetting();
539 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
540 __pWebViewer->SetSetting(settings);
544 MainForm::InitFooter(void)
546 AppLogDebug("MainForm::InitFooter entered");
547 Button* pBackButton = null;
548 Button* pBookmarkButton = null;
549 Button* pMultiWindowButton = null;
550 Bitmap *pIconBitmap = null;
551 Bitmap *pBGBitmap = null;
552 Label *pBGLabel = null;
554 if (__pFooterPanel == null)
556 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
559 if (__pFooterPanel == null)
564 SetControlAlwaysOnTop(*__pFooterPanel, true);
566 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
567 if ( __pFooterLabel == NULL )
571 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
572 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
575 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
579 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
581 if ( __pMultiWindowButton == NULL )
586 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
588 if ( __pMoreButton == NULL )
593 if (__pMultiWindowButton != null)
595 Bitmap* pBitmap = null;
596 Bitmap* pPressedBitmap = null;
597 String imagePath = "I01_toolbar_icon_windows_manager_0";
598 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
599 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
600 imagePath.Append(totalCount);
601 imagePath.Append(".png");
603 pressedImagePath.Append(totalCount);
604 pressedImagePath.Append("_press.png");
606 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
607 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
608 if ( pBitmap == null )
613 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
616 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
617 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
622 __pMultiWindowButton->AddActionEventListener(*this);
623 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
628 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
629 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
632 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
633 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
634 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
638 __pMoreButton->AddActionEventListener(*this);
639 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
642 //Add the editfield for url
643 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
644 if (__pFooterUrlField == NULL)
646 return E_INVALID_KEY;
649 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
650 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
651 __pFooterUrlField->AddKeypadEventListener(*this);
652 __pFooterUrlField->SetPropagatedTouchEventListener(this);
654 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
656 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
658 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
660 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
664 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
665 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
669 //Add the go Back Button
670 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
671 if (__pGoBackBtn == NULL)
673 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
674 return E_INVALID_KEY;
676 __pGoBackBtn->SetActionId(IDA_GO_BACK);
677 __pGoBackBtn->AddActionEventListener(*this);
679 //Add the go forward Button
680 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
681 if (__pGoForwardBtn == NULL)
683 AppLogDebug("Control not found returning E_INVALID_KEY");
684 return E_INVALID_KEY;
686 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
687 __pGoForwardBtn->AddActionEventListener(*this);
688 if (__pWebViewer && __pWebViewer->CanGoForward())
690 SetForwardButtonEnabled(true);
694 SetForwardButtonEnabled(false);
697 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
698 if (__pRefreshBtn == NULL)
700 AppLogDebug("Control not found returning E_INVALID_KEY");
701 return E_INVALID_KEY;
704 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
705 __pRefreshBtn->AddActionEventListener(*this);
706 __pRefreshBtn->SetShowState(true);
708 //Add the backround label for displaying progressbar
709 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
710 if (__pProgressbarLabel == NULL)
712 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
713 return E_INVALID_KEY;
715 __pProgressbarLabel->SetShowState(false);
717 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
718 if (__pStopBtn == NULL)
720 AppLogDebug("Control not found returning E_INVALID_KEY");
721 return E_INVALID_KEY;
723 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
724 __pStopBtn->AddActionEventListener(*this);
725 __pStopBtn->SetShowState(false);
727 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
728 if (__pClearBtn == NULL)
730 AppLogDebug("Control not found returning E_INVALID_KEY");
731 return E_INVALID_KEY;
733 __pClearBtn->SetActionId(IDA_CLEAR_URL);
734 __pClearBtn->AddActionEventListener(*this);
735 __pClearBtn->SetShowState(false);
737 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
738 if (__pReaderBtn == NULL)
740 AppLogDebug("Control not found returning E_INVALID_KEY");
741 return E_INVALID_KEY;
743 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
744 __pReaderBtn->AddActionEventListener(*this);
745 __pReaderBtn->SetShowState(false);
747 // __pFooterPanel->Invalidate(true);
748 AppLogDebug("MainForm::InitFooter exit");
754 MainForm::InitContextMenu(Point& p)
756 result r = E_SUCCESS;
757 bool isPrivateBrowsing = false;
758 Bitmap* pBitmap = null;
762 __pMenu->SetAnchorPosition(p);
763 __pMenu->Invalidate(true);
767 __pMenu = new(std::nothrow) ContextMenu();
768 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
769 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
771 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
774 if (isPrivateBrowsing == true)
776 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
780 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
783 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
785 if ( pBitmap != NULL)
787 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
790 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
791 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
792 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
795 __pMenu->SetMaxVisibleItemsCount(6);
796 __pMenu->SetShowState(false);
797 __pMenu->AddActionEventListener(*this);
798 SetControlAlwaysOnTop(*__pMenu, true);
804 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
806 result r = E_SUCCESS;
807 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
809 AppLog("MainForm::InitImageContextMenu clicked on image");
810 if (__pImageMenu != null)
816 __pImageMenu = new (std::nothrow) ContextMenu();
817 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
818 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
820 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
821 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
822 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
823 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
824 __pImageMenu->SetMaxVisibleItemsCount(4);
825 __pImageMenu->AddActionEventListener(*this);
826 SetControlAlwaysOnTop(*__pImageMenu, true);
832 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
834 result r = E_SUCCESS;
835 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
837 AppLog("MainForm::InitImageContextMenu clicked on image");
838 if (__pImageMenu != null)
844 if(__pAddressbar->GetShowState() == true)
845 p.y = p.y + __pAddressbar->GetHeight();
847 __pImageMenu = new (std::nothrow) ContextMenu();
848 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
849 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
851 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
852 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
853 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
854 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
856 __pImageMenu->SetMaxVisibleItemsCount(3);
857 __pImageMenu->AddActionEventListener(*this);
858 SetControlAlwaysOnTop(*__pImageMenu, true);
865 MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
867 result r = E_SUCCESS;
868 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
870 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
871 if (__pImageMenu != null)
880 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
884 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
886 __pImageMenu = new (std::nothrow) ContextMenu();
887 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
888 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
890 if(onlyPasteOption == false)
892 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
894 if (pasteOption || onlyPasteOption)
896 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
898 if(onlyPasteOption == false)
900 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
901 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
904 __pImageMenu->SetMaxVisibleItemsCount(3);
905 __pImageMenu->AddActionEventListener(*this);
906 SetControlAlwaysOnTop(*__pImageMenu, true);
913 MainForm::InitFindWordPanel(void)
915 result r = E_SUCCESS;
916 Bitmap *pIconBitmap = null;
918 if (__pFindWordControl != null)
920 AppLogDebug("Findword panel already initialized");
921 if (__pFindWordBgLabel != null)
923 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
926 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
933 __pFindWordControl = new (std::nothrow) Panel();
934 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
937 AppLogException("There is some problem in the xml file. Please check.");
940 AddControl(__pFindWordControl);
941 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
942 SetControlAlwaysOnTop(*__pFindWordControl,true);
943 __pFindWordControl->SetShowState(false);
944 __pFindWordControl->Invalidate(false);
946 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
947 if (__pFindWordBgLabel != null)
949 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
950 Rectangle pRect = pPanel1->GetBounds();
951 pRect.x = pRect.y = 0;
952 __pFindWordBgLabel->SetBounds(pRect);
953 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
956 AppLogDebug("InitFindWordPanel: Coming here");
957 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
962 AppLogDebug("InitFindWordPanel: shouldn't Come here");
966 Button* pfindWordCancel = null;
967 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
968 if (pfindWordCancel == null)
970 AppLogException("There is some problem in the xml file. Please check.");
973 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
974 pfindWordCancel->AddActionEventListener(*this);
976 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
977 if (__pFindWordClear == null)
979 AppLogException("There is some problem in the xml file. Please check.");
983 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
984 __pFindWordClear->AddActionEventListener(*this);
986 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
987 if (__pFindWordNext == null)
989 AppLogException("There is some problem in the xml file. Please check.");
993 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
994 __pFindWordNext->AddActionEventListener(*this);
996 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
997 if (__pFindWordPrev == null)
999 AppLogException("There is some problem in the xml file. Please check.");
1003 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1004 __pFindWordPrev->AddActionEventListener(*this);
1006 __pFindWordNext->SetEnabled(false);
1007 __pFindWordPrev->SetEnabled(false);
1009 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1010 if (__pFindWordCountLabel == null)
1012 AppLogException("There is some problem in the xml file. Please check.");
1016 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1017 if (__pFindWordEditField == null)
1019 AppLogException("There is some problem in the xml file. Please check.");
1022 __pFindWordEditField->AddTextEventListener(*this);
1023 __pFindWordEditField->AddKeypadEventListener(*this);
1024 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1030 MainForm::CreateItem (int index, int itemWidth)
1032 Rectangle listImageRect;
1033 Rectangle pagetTitleRect;
1034 Rectangle pageURLRect;
1035 Rectangle deleteImageRect;
1036 String pageTitle(L"");
1037 String pageURL(L"");
1038 result r = E_SUCCESS;
1039 Bitmap* pListIconImage = null;
1042 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1043 if(pHistory == null)
1047 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1048 if ( pAppResource == NULL )
1052 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1054 CustomItem* pItem = new(std::nothrow) CustomItem();
1055 pageTitle = pHistory->GetHistoryTitle();
1056 pageURL = pHistory->GetHistoryUrl();
1058 if (pageURL.GetLength() == 0)
1061 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1062 pageURL = L"<"+ nourl +">";
1066 Rectangle screenBounds = GetBounds();
1069 r = pItem->Construct(Dimension(itemWidth, 128), style);
1078 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1080 if ( pBitmap != NULL)
1082 pListIconImage = new Bitmap();
1083 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1087 if(pListIconImage == null)
1089 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1092 if ( pListIconImage != NULL)
1094 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1095 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1096 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1099 if (pItem != null && pListIconImage != NULL)
1101 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1105 if (pageTitle.CompareTo(L"") != 0)
1109 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1113 if (pageURL.CompareTo(L"") != 0)
1117 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1122 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1124 if ( __pItemContext!= NULL)
1128 pItem->SetContextItem(__pItemContext);
1134 if ( __pItemContextLandscape!= NULL)
1138 pItem->SetContextItem(__pItemContextLandscape);
1142 if( pListIconImage != NULL)
1144 delete pListIconImage;
1145 pListIconImage = null;
1152 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1159 MainForm::GetItemCount (void)
1161 if(__pMostVisitedSites != null)
1163 __pMostVisitedSites->RemoveAll(true);
1165 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1166 if(__pMostVisitedSites != null)
1168 return __pMostVisitedSites->GetCount();
1175 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1177 if(__pMostVisitedSites != null)
1179 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1180 if (pHistory != null)
1182 String url = pHistory->GetHistoryUrl();
1184 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1185 __pMostVisitedListView->UpdateList();
1191 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1193 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1194 String url = pHistory->GetHistoryUrl();
1202 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1208 MainForm::OnTerminating(void)
1210 result r = E_SUCCESS;
1213 delete __pItemContext;
1215 if(__pItemContextLandscape)
1217 delete __pItemContextLandscape;
1223 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1225 result r = E_SUCCESS;
1227 AppLogDebug("Clicked : %d", actionId);
1230 case IDA_BACKBTN_CLICKED:
1232 if (__pWebViewer && __pWebViewer->CanGoBack())
1234 __pWebViewer->GoBack();
1236 else if(__pWindowInfo->isJavascriptInitiated == false)
1239 pApp = UiApp::GetInstance();
1242 r = pApp->Terminate();
1245 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1253 WindowInfo* pWindowInfo = null;
1255 SceneManager* pSceneManager = SceneManager::GetInstance();
1256 if (pSceneManager == null)
1260 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1261 if (pAllWindowList == NULL)
1263 pApp = UiApp::GetInstance();
1266 r = pApp->Terminate();
1269 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1274 if (pAllWindowList != null)
1276 totalCount = pAllWindowList->GetCount();
1278 for (int count = 0; count < totalCount; count++)
1280 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1281 if (pWindowInfo == null)
1283 pApp = UiApp::GetInstance();
1286 r = pApp->Terminate();
1289 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1296 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1298 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1301 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1304 r = pAllWindowList->RemoveAt(count, true);
1305 __pWindowInfo = null;
1308 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1313 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1317 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1319 if (pWindowInfo == null)
1321 pApp = UiApp::GetInstance();
1324 r = pApp->Terminate();
1330 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1333 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1345 case IDA_FORWARD_CLICKED:
1346 if (__pWebViewer == null)
1349 if (__pWebViewer->CanGoForward())
1351 __pWebViewer->GoForward();
1353 __pMenu->SetShowState(false);
1354 __pMenu->Invalidate(false);
1357 case IDA_FINDONPAGE_CLICKED:
1359 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1360 __currentSearchStr.Clear();
1362 InitFindWordPanel();
1363 __pMenu->SetShowState(false);
1364 __pMenu->Invalidate(false);
1366 __pFindWordEditField->SetFocus();
1367 ShowFindWordPanel(true);
1370 case IDA_PRIVATEON_CLICKED:
1372 result r = E_SUCCESS;
1374 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1375 Bitmap* pBitmap = null;
1376 if (isPrivateBrowsing == true)
1378 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1381 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1385 if (__pWebViewer != NULL)
1387 __pWebViewer->SetPrivateBrowsingEnabled(false);
1390 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1392 if (__pAddressbar != null)
1394 __pAddressbar->UpdateFaviconBitmap(false);
1400 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1403 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1407 if (__pWebViewer != NULL)
1409 __pWebViewer->SetPrivateBrowsingEnabled(true);
1412 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1414 if (__pAddressbar != null)
1416 __pAddressbar->UpdateFaviconBitmap(true);
1421 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1422 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1423 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1424 __pMenu->Invalidate(true);
1426 if ( pBitmap != NULL )
1433 case IDA_SETTINGS_CLICKED:
1436 ArrayList* pArgList = new(std::nothrow) ArrayList();
1439 pArgList->Construct();
1440 pArgList->Add(*__pWindowInfo);
1441 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1443 __pMenu->SetShowState(false);
1444 __pMenu->Invalidate(false);
1445 if (pArgList != null)
1454 case IDA_ADDTOBOOKMARK_CLICKED:
1457 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1459 int bookmarkCount=0;
1462 url=__pWindowInfo->pageUrl;
1463 result r = E_SUCCESS;
1464 Bitmap* pBitmap = null;
1465 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1473 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1474 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1475 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1477 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1478 if (pNotification != null)
1480 pNotification->SetText(message);
1481 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1482 pNotification->ShowNotification();
1487 String title=__pWindowInfo->pageTitle;
1488 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1489 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1491 pBookmark->SetBookmarkTitle(title);
1492 pBookmark->SetUrl(url);
1493 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1495 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1497 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1498 pBookmark->SetFaviconId(id);
1499 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1500 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1503 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1504 if (pNotification != null)
1506 pNotification->SetText(message);
1507 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1508 pNotification->ShowNotification();
1509 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1512 if (pBitmap != null)
1514 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1518 __pMenu->Invalidate(true);
1522 case IDA_PRINT_CLICKED:
1524 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1525 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1527 AppLog("RequestPrint called!");
1528 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1529 result nResult = E_FAILURE;
1532 AppLog("TestPrint if (pAc) == true");
1537 String fileType = L"service_print_files_type";
1538 String typeVal = L"DOC";
1540 String fileCount = L"service_print_files_count";
1541 String countVal = L"1";
1542 String fileFolder= L"service_print_files_folder_name";
1543 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1545 map.Add(&fileCount, &countVal);
1546 map.Add(&fileFolder, &folderVal);
1547 map.Add(&fileType, &typeVal);
1549 String fileName = L"service_print_files_files_name";
1551 ArrayList fileNameList;
1552 fileNameList.Construct();
1553 String file1 = L"test.pdf";
1555 fileNameList.Add(&file1);
1556 map.Add(&fileName, &fileNameList);
1558 nResult = pAc->Start(NULL, NULL, &map, NULL);
1560 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1561 else if (nResult == E_MAX_EXCEEDED)
1562 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1563 else if (nResult == E_OBJ_NOT_FOUND)
1564 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1565 else if (nResult == E_IN_PROGRESS)
1566 AppLog("TestPrint ret == E_IN_PROGRESS");
1567 else if (nResult == E_PRIVILEGE_DENIED)
1568 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1569 else if(nResult == E_SYSTEM)
1570 AppLog("TestPrint ret == E_SYSTEM");
1576 int __modalMsgBoxResult;
1577 MessageBox* pMsgBox = new MessageBox();
1578 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1579 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1582 __modalMsgBoxResult = 0;
1586 case IDA_SHARE_CLICKED:
1588 if(__pPopUp != null)
1593 __pPopUp = new(std::nothrow) SharePopup();
1594 __pPopUp->Initialize();
1595 if (__pWindowInfo != null)
1597 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1598 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1599 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1600 pShareInfo->SetImageAttached(false);
1601 __pPopUp->RemoveAllShareInfo();
1602 __pPopUp->AddShareInfo(pShareInfo);
1604 __pPopUp->SetShowState(true);
1608 case IDA_BOOKMARKBTN_CLICKED:
1610 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1611 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1614 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1619 case IDA_MOREBTN_CLICKED:
1621 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1622 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1623 AppLog("Anchot pos: %d %d", p.x, p.y);
1625 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1627 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1628 int bookmarkCount=0;
1631 url=__pWindowInfo->pageUrl;
1632 result r = E_SUCCESS;
1633 Bitmap* pBitmap = null;
1635 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1638 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1643 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1647 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1649 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1651 if (__pMenu->GetItemCount() == 9)
1653 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1657 r = __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1662 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1666 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1667 if (__pMenu->GetItemCount() != 9)
1669 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1670 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_COM_SK_PRINT"), IDA_PRINT_CLICKED);
1671 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1672 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1673 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1674 __pMenu->SetMaxVisibleItemsCount(6);
1676 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1678 AppLog(" Orientation landscape");
1679 __pMenu->SetMaxVisibleItemsCount(5);
1683 AppLog(" Orientation potrait");
1684 __pMenu->SetMaxVisibleItemsCount(6);
1687 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1690 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1691 __pMenu->SetShowState(true);
1692 __pMenu->Invalidate(true);
1696 case IDA_HISTORY_CLICKED:
1698 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1699 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1702 case IDA_SAVED_PAGES_CLICKED:
1707 case IDA_DESKTOP_VIEW_CLICKED:
1712 case IDA_SAVE_CLICKED:
1717 case IDA_MULTIWINDOWBTN_CLICKED:
1719 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1720 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1724 case IDA_NEWWINDOWBTN_CLICKED:
1726 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1728 if (pNewWindowInfo == null)
1732 result r = E_SUCCESS;
1733 SceneManager* pSceneManager = SceneManager::GetInstance();
1735 if (pSceneManager == NULL)
1739 ArrayList* pArgList = new(std::nothrow) ArrayList();
1740 if (pArgList == NULL)
1744 r = pArgList->Construct();
1747 pArgList->Add(*pNewWindowInfo);
1748 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1754 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1759 case IDA_SMALLFONT_BTN_CLICKED:
1761 WebSetting setting = __pWebReader->GetSetting();
1762 setting.SetFontSize(15);
1763 __pWebReader->SetSetting(setting);
1766 case IDA_LARGEFONT_BTN_CLICKED:
1768 WebSetting setting = __pWebReader->GetSetting();
1769 setting.SetFontSize(25);
1770 __pWebReader->SetSetting(setting);
1773 case IDA_READER_CLOSE_CLICKED:
1775 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1777 RemoveControl(__pBlankPanel);
1778 __pArticleReaderPanel = null;
1779 __pBlankPanel = null;
1780 __pArticleReaderLabel = null;
1782 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1785 case IDA_FINDWORD_CANCEL_CLICKED:
1787 __currentSearchStr = L"";
1788 __currentWordIndex = 0;
1789 __maxOccurrances = 0;
1790 __pFindWordEditField->SetText(L"");
1791 __pFindWordNext->SetEnabled(false);
1792 __pFindWordPrev->SetEnabled(false);
1793 __pFindWordCountLabel->SetText(L"0/0");
1794 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1795 AppLog("akjshdasd 1");
1796 __pFooterPanel->SetShowState(true);
1797 ShowFindWordPanel(false);
1800 case IDA_FINDWORD_SEARCH_CLICKED:
1802 __currentSearchStr = __pFindWordEditField->GetText();
1803 if (__currentSearchStr.GetLength() > 0)
1809 AppLogDebug("Enter something");
1813 case IDA_FINDWORD_CLEAR_CLICKED:
1815 __pFindWordCountLabel->SetText(L"0/0");
1816 __pFindWordEditField->SetText(L"");
1817 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1819 __currentSearchStr = L"";
1820 __pFindWordNext->SetEnabled(false);
1821 __pFindWordPrev->SetEnabled(false);
1822 __pFindWordControl->Invalidate(true);
1825 case IDA_FINDWORD_NEXT_CLICKED:
1830 case IDA_FINDWORD_PREV_CLICKED:
1832 FindNextWord(false);
1835 case IDA_BRIGHTNESS_BTN_CLICKED:
1837 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1838 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1841 case IDA_COPY_IMAGE_CLICKED:
1843 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1844 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1846 const Bitmap* pBitmap = null;
1847 if (__pHitElementResult != null)
1849 pBitmap = __pHitElementResult->GetImage();
1852 String resourcePath = App::GetInstance()->GetAppResourcePath();
1853 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1855 // copying the item to clipboard
1856 Clipboard* pClipboard = Clipboard::GetInstance();
1857 if (pClipboard != null)
1859 pClipboard->CopyItem(item);
1863 case IDA_VIEW_IMAGE_CLICKED:
1865 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1866 WindowInfo* pNewWindowInfo = null;
1867 if (__pHitElementResult != null)
1869 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1870 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1876 case IDA_SAVE_IMAGE_CLICKED:
1878 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1879 const Bitmap* pSaveBitmap = null;
1880 String imageName = GetImagePath();
1881 AppLog("Content manager image name %ls",imageName.GetPointer());
1884 imagePath.Append(imageName);
1885 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1886 AppLog("Content manager image path %ls",imagePath.GetPointer());
1887 if (__pHitElementResult != null)
1889 pSaveBitmap = __pHitElementResult->GetImage();
1891 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1895 UpdateImageContent(pBuffer, imageName);
1897 NotificationPanel *pNotification = new NotificationPanel(*this);
1899 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1900 msg.Append(imagePath);
1901 if (pNotification != null)
1903 pNotification->SetText(msg);
1904 if (__pFooterPanel->GetShowState() == true)
1906 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1910 pNotification->SetPositionDiff(0);
1913 pNotification->ShowNotification();
1918 int __modalMsgBoxResult;
1919 MessageBox* pMsgBox = new MessageBox();
1920 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1921 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1924 __modalMsgBoxResult = 0;
1928 case IDA_SHARE_IMAGE_CLICKED:
1930 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1931 if (__pPopUp != null)
1936 __pPopUp = new(std::nothrow) SharePopup();
1937 __pPopUp->Initialize();
1938 if (__pHitElementResult != null)
1940 const Bitmap* pSaveBitmap = null;
1941 String imageName = GetImagePath();
1942 AppLog("Content manager image name %ls",imageName.GetPointer());
1945 imagePath.Append(imageName);
1946 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1947 AppLog("Content manager image path %ls",imagePath.GetPointer());
1948 if (__pHitElementResult != null)
1950 pSaveBitmap = __pHitElementResult->GetImage();
1952 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1954 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1955 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1957 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1958 pShareInfo->SetPageTitle(L"");
1959 pShareInfo->SetPageUrl(srcUrl);
1960 pShareInfo->SetImageAttached(true);
1961 pShareInfo->SetImagePath(imagePath);
1962 __pPopUp->RemoveAllShareInfo();
1963 __pPopUp->AddShareInfo(pShareInfo);
1964 __pPopUp->SetShowState(true);
1969 case IDA_HYPERLINK_OPEN_CLICKED:
1971 if (__pHitElementResult != null)
1973 String srcUrl = __pHitElementResult->GetUrl();
1975 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(srcUrl);
1977 if (pNewWindowInfo == null)
1981 result r = E_SUCCESS;
1982 SceneManager* pSceneManager = SceneManager::GetInstance();
1983 if (pSceneManager == NULL)
1987 ArrayList* pArgList = new(std::nothrow) ArrayList();
1988 if (pArgList == NULL)
1992 pArgList->Construct();
1994 pArgList->Add(*pNewWindowInfo);
1995 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1996 if (pArgList != null)
2003 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2009 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2011 if (__pHitElementResult == null)
2016 if(__pPopUp != null)
2021 __pPopUp = new(std::nothrow) SharePopup();
2022 __pPopUp->Initialize();
2024 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2025 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2026 pShareInfo->SetImageAttached(false);
2027 __pPopUp->RemoveAllShareInfo();
2028 __pPopUp->AddShareInfo(pShareInfo);
2030 __pPopUp->SetShowState(true);
2034 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2038 if (__pHitElementResult != null)
2040 url = __pHitElementResult->GetUrl();
2043 String resourcePath = App::GetInstance()->GetAppResourcePath();
2044 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2046 // copying the item to clipboard
2047 Clipboard* pClipboard = Clipboard::GetInstance();
2048 if (pClipboard != null)
2050 pClipboard->CopyItem(item);
2054 case IDA_FIND_TEXT__CLICKED:
2056 // AddressBarCancelledClicked(*__pAddressbar);
2057 RelayoutControls(false);
2058 // __pFooterPanel->SetShowState(false);
2059 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2060 __currentSearchStr.Clear();
2061 __currentSearchStr.Append(__currentSelectedStr);
2062 InitFindWordPanel();
2063 __pFindWordEditField->SetText(__currentSearchStr);
2066 __pMenu->SetShowState(false);
2067 __pMenu->Invalidate(false);
2070 __adressPanelPosition.y = 0;
2072 if (__pAddressbar != null && __pWebViewer != NULL)
2074 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2075 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2077 if (__pFooterPanel->GetShowState() == false)
2078 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2080 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2081 __pWebViewer->Invalidate(true);
2084 ShowFindWordPanel(true);
2085 __pFindWordEditField->SetFocus();
2086 if (__currentSearchStr.GetLength() > 0)
2092 AppLogDebug("Enter something");
2095 if (__pWebViewer != null)
2097 // releasing the set block
2098 __pWebViewer->ReleaseBlock();
2103 case IDA_SHARE_TEXT_CLICKED:
2105 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2106 if(__pPopUp != null)
2111 __pPopUp = new(std::nothrow) SharePopup();
2112 __pPopUp->Initialize();
2113 if (__pHitElementResult != null)
2115 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2116 pShareInfo->SetPageTitle(L"");
2117 pShareInfo->SetPageUrl(__currentSelectedStr);
2118 pShareInfo->SetImageAttached(false);
2119 __pPopUp->RemoveAllShareInfo();
2120 __pPopUp->AddShareInfo(pShareInfo);
2121 __pPopUp->SetShowState(true);
2126 case IDA_COPY_TEXT_CLICKED:
2128 __pWebViewer->ReleaseBlock();
2129 // need to implement
2130 //__currentSelectedStr
2131 // Sets data to a clip board item
2133 String resourcePath = App::GetInstance()->GetAppResourcePath();
2134 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2136 // copying the item to clipboard
2137 Clipboard* pClipboard = Clipboard::GetInstance();
2138 if (pClipboard != null)
2140 pClipboard->CopyItem(item);
2144 case IDA_PASTE_TEXT_CLICKED:
2146 Clipboard* pClipboard = Clipboard::GetInstance();
2148 if(pClipboard == null)
2152 // Retrieves a latest item
2153 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2159 //Gets data from the clipboard item
2160 String* pString = dynamic_cast<String*>(pItem->GetData());
2162 if (pString != null)
2164 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2165 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2166 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2169 if(idElement.GetLength() != 0)
2171 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; } } ";
2172 script.Append("insertAtCursor('");
2173 script.Append(idElement);
2174 script.Append("',");
2175 script.Append("\"");
2176 script.Append(*pString);
2177 script.Append("\");");
2179 else if (nameElement.GetLength() != 0)
2181 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementByName(myField)[0].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 { document.getElementByName(myField)[0].value += myValue; } } ";
2182 script.Append("insertAtCursor(document.getElementsByName('");
2183 script.Append(nameElement);
2184 script.Append("')[0],");
2185 script.Append("\"");
2186 script.Append(*pString);
2187 script.Append("\");");
2189 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2190 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2201 case IDA_GO_FORWARD:
2206 case IDA_REFRESH_BTN_CLICKED:
2208 __isLoadingCompleted = false;
2209 __isLoadingData = true;
2210 __progressPercentage = 0;
2211 __displayUrl = __pFooterUrlField->GetText();
2213 String url = __pFooterUrlField->GetText();
2214 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2218 UpdateProgressBitmap();
2221 case IDA_STOP_BTN_CLICKED:
2223 __isLoadingCompleted = false;
2224 __isLoadingData = false;
2225 __progressPercentage = 0;
2226 __pFooterUrlField->HideKeypad();
2227 __displayUrl = __pFooterUrlField->GetText();
2231 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2232 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2233 __pWebViewer->StopLoading();
2234 RequestRedraw(true);
2237 UpdateProgressBitmap();
2242 if (__pFooterUrlField->GetText().IsEmpty() == false)
2244 //__displayUrl = __pUrlField->GetText();
2245 __pFooterUrlField->Clear();
2250 case IDA_READER_BTN_CLICKED:
2261 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2264 UiApp* pApp = UiApp::GetInstance();
2273 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2274 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2276 AppLog("MainForm::OnSceneActivatedN called");
2277 String* pSelectedScene = NULL;
2278 Object* pValue = NULL;
2279 String* pUrl = null;
2280 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2281 pSelectedScene = (String*) pValue;
2283 if (pSelectedScene != null)
2285 delete pSelectedScene;
2287 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2288 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2289 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2290 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2292 // setting the current scene ID
2293 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2295 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2297 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2299 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2300 if(__pWindowInfo == null)
2302 // if(__pWindowInfo == null)
2304 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2307 else if ( pArgs != null && pArgs->GetCount() == 1)
2309 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2315 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2317 // hiding the address bar
2318 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2319 __pAddressbar->SetShowState(false);
2320 if(__pWebViewer != null)
2322 __pWebViewer->Resume();
2325 if(pUrl != null && pUrl->GetLength() > 0)
2329 else if(__pWindowInfo != null)
2331 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)
2333 LoadUrl(__pWindowInfo->pageUrl);
2335 else if (__pWindowInfo->isJavascriptInitiated == true)
2339 __pWindowInfo->pCurrentWeb = __pWebViewer;
2343 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2344 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2345 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2347 InitMostVisitedSitesView(GetOrientationStatus());
2349 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2351 if(__pMostVisitedListView != null)
2353 __pMostVisitedListView->SetShowState(false);
2357 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2359 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2361 if (pBookmarkUrl == null)
2363 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2364 //__pAddressbar->SetUrl(*pBookmarkUrl);
2365 SetUrl(*pBookmarkUrl);
2367 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2368 __pWebViewer->LoadUrl(*pBookmarkUrl);
2369 delete pBookmarkUrl;
2372 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2373 Bitmap* pBitmap = null;
2374 if (isPrivateBrowsing == true)
2376 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2378 if (__pWebViewer != null)
2380 __pWebViewer->SetPrivateBrowsingEnabled(true);
2383 if (__pAddressbar != null)
2385 // __pAddressbar->UpdateFaviconBitmap(true);
2391 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2393 if (__pWebViewer != null)
2395 __pWebViewer->SetPrivateBrowsingEnabled(false);
2398 if (__pAddressbar != null)
2400 // __pAddressbar->UpdateFaviconBitmap(false);
2404 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2406 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2408 else if (__pMenu != null )
2410 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2413 if (pBitmap != null)
2418 AppLog("ABC: OnSceneActivatedN started exit");
2423 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2424 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2426 Canvas* pWebCanvas = null;
2427 if (__pWebViewer != null)
2429 pWebCanvas = __pWebViewer->GetCanvasN();
2430 __pWebViewer->Pause();
2433 if (pWebCanvas == null)
2437 if (__pWindowInfo != null)
2439 if (__pWindowInfo->pWebCanvasBitmap != null)
2441 delete __pWindowInfo->pWebCanvasBitmap;
2443 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2444 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2445 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2447 Bitmap* pBitmap = GetCapturedBitmapN();
2448 AppLog("Coming here");
2449 Canvas* pCanvas = new(std::nothrow) Canvas();
2450 pCanvas->Construct(GetClientAreaBounds());
2453 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2456 if(__pWebViewer != null && __pWindowInfo != null)
2457 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2459 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2460 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2462 AppLog("Coming here");
2466 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2467 const Tizen::Base::String& realm,
2468 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2474 MainForm::OnHttpAuthenticationCanceled(void)
2479 MainForm::OnLoadingStarted(void)
2481 AppLogDebug("MainForm::OnLoadingStarted entered");
2483 if(__pAddressbar == NULL || __pWebViewer == null)
2487 // this is added in case if menu is opened and user load the page
2488 if(__pMenu != null && __pMenu->GetShowState() == true)
2490 __pMenu->SetShowState(false);
2491 __pMenu->Invalidate(true);
2493 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2495 __pImageMenu->SetShowState(false);
2496 __pImageMenu->Invalidate(true);
2498 String url = __pWebViewer->GetUrl();
2499 if(url.Contains(IDS_TIZEN_SERVICE))
2502 String delim(L":;");
2504 // Creates a StringTokenizer instance
2505 StringTokenizer strTok(url, delim);
2507 int count = strTok.GetTokenCount(); // count == 4
2509 HashMap *pMap = new HashMap();
2514 while (strTok.HasMoreTokens())
2516 AppLog("Token: %ls", token.GetPointer());
2517 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2518 if(token.Contains(IDS_APPID))
2520 token.SubString(6, appId);
2521 AppLog("AppID:%ls", appId.GetPointer());
2523 else if(token.Contains("="))
2525 String *pKey = new String();
2526 String *pValue = new String();
2528 token.IndexOf("=", 0, index);
2531 token.SubString(0, index, *pKey);
2532 token.SubString(index + 1, *pValue);
2533 pMap->Add(pKey, pValue);
2539 AppControl *pAppControl = null;
2540 String operationId = L"http://tizen.org/appcontrol/operation/main";
2541 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2544 AppLog("Starting AppControl");
2545 result r = pAppControl->Start(null, null, pMap, null);
2546 AppLog("Result of Start %s", GetErrorMessage(r));
2550 AppLogException("AppControl not found");
2555 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2557 __pAddressbar->SetShowState(false);
2558 AddressBarCancelledClicked(*__pAddressbar);
2559 __pAddressbar->Invalidate(true);
2561 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2564 __pAddressbar->SetFaviconBitmap(*pBitmap);
2567 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2569 // updating the address bar position with respect to web control
2570 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2571 __distanceMoved = 0;
2575 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2576 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2577 if (__pWebViewer != null)
2579 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2580 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2581 SetUrl(__pWebViewer->GetUrl());
2582 if (__pWindowInfo != NULL)
2584 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2585 __pWindowInfo->pageTitle = L"";
2586 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2588 __pAddressbar->Invalidate(true);
2594 MainForm::OnLoadingCanceled(void)
2601 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2603 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2608 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2610 AppLog("XYZ::MainForm::OnKeypadOpened");
2615 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2617 AppLog("XYZ::MainForm::OnKeypadClosed");
2618 RelayoutControls(true);
2622 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2624 AppLog("KeypadBoundsChanged");
2625 RelayoutControls(false);
2629 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2630 const Tizen::Base::String& reason)
2632 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2636 MainForm::OnLoadingCompleted(void)
2638 AppLog("MainForm::OnLoadingCompleted start");
2640 result r = E_SUCCESS;
2642 if (__pWebViewer == null)
2647 if (__pAddressbar == null)
2651 if (__pWebViewer->CanGoForward())
2653 //__pAddressbar->SetForwardButtonEnabled(true);
2654 SetForwardButtonEnabled(true);
2658 //__pAddressbar->SetForwardButtonEnabled(false);
2659 SetForwardButtonEnabled(false);
2662 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2664 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2666 //__pAddressbar->UpdateProgress(0);
2670 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2672 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2676 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2677 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2678 if (isPrivateBrowsing == false)
2680 if(__pHistory != null)
2686 __pHistory = new(std::nothrow) History;
2687 HistoryPresentationModel::GetCurrentDateTime(date);
2690 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2691 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2693 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2694 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2696 __pHistory->SetVisitedTime(date);
2698 if (__pWebViewer != null)
2700 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2702 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2703 if (pTempBitmap != null)
2705 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2706 __pHistory->SetFavIconBitmap(*pTempBitmap);
2709 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2712 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2713 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2714 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2716 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2717 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2718 __pHistory->SetThumbnail(pBitmap);
2720 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2723 __pHistory->SetFavIconBitmap(*pFavIcon);
2727 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
2734 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2736 // temperary fixed (webpage can be not loaded)
2740 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
2741 if (isReaderEnabled == true)
2745 delete __pReaderData;
2746 __pReaderData = null;
2748 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
2749 filePath.Append(L"data/reader.js");
2755 result r = E_SUCCESS;
2756 FileAttributes attr;
2758 File::GetAttributes(filePath,attr);
2760 r = file.Construct(filePath, L"r+");
2763 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
2766 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
2769 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
2772 // file.Read(pScript,attr.GetFileSize());
2774 // AppLogDebug("scipt length %d",strlen(pScript));
2775 String strScript = L"";
2776 // strScript.Append(pScript);
2777 // for(int i=0; i<25; i++)
2779 file.Read(pScript,attr.GetFileSize());
2780 // AppLog("xyzz tell %d",file.Tell());
2781 // r = strScript.Append(pScript);
2782 // AppLog("xyzz append result %s",GetErrorMessage(r));
2783 // AppLog("xyzz strScript length %d",strScript.GetLength());
2785 // AppLog("xyzz final strScript length %d",strScript.GetLength());
2787 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
2788 if (__pReaderData == null)
2790 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
2793 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
2794 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
2796 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
2797 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
2803 AppLog("MainForm::OnLoadingCompleted done");
2807 MainForm::OnEstimatedProgress(int progress)
2809 AppLogDebug("MainForm::OnEstimatedProgress entered");
2810 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2811 progress = DEFAULT_PROGRESS_PERCENTAGE;
2813 // __pAddressbar->UpdateProgress(progress);
2814 UpdateProgress(progress);
2817 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2819 AppLog("MainForm::OnFaviconReceived");
2820 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
2822 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *(__pWebViewer->GetFaviconN()));
2827 MainForm::OnUrlValueChanged(Addressbar&)
2833 MainForm::OnUrlSubmitted(Addressbar& addBar)
2835 AppLog("MainForm::OnUrlSubmitted");
2836 String url = addBar.GetUrl();
2837 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2839 if(__pFooterUrlField)
2840 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2841 AddressBarCancelledClicked(*__pAddressbar);
2846 MainForm::LoadUrl(String& url)
2850 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2851 AppLogDebug("MainForm::LoadUrl enter");
2853 if (__pWebViewer != null)
2855 __pWebViewer->SetShowState(true);
2856 __pWebViewer->Invalidate(true);
2859 if (url.CompareTo(L"") == 0)
2863 if(__pFooterPanel != null)
2865 __pFooterPanel->SetShowState(true);
2866 __pFooterPanel->Invalidate(true);
2873 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2874 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)
2876 RegularExpression firstRegex;
2877 RegularExpression secondRegex;
2879 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2880 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2883 ret = firstRegex.Match(url, false); // This returns true value
2884 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2886 if (ret == true && __pWebViewer != null)
2889 __pWebViewer->LoadUrl(url);
2891 else if(__pWebViewer != null)
2893 String tempUrl = L"http://";
2894 tempUrl.Append(url);
2898 __pWebViewer->LoadUrl(tempUrl);
2902 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2903 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2906 if (__pAddressbar != null)
2908 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2909 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2912 AppLogDebug("MainForm::LoadUrl exit");
2919 MainForm::OnStopClicked(Addressbar& addBar)
2921 AppLogDebug("MainForm::OnStopClicked called");
2924 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2925 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2926 __pWebViewer->StopLoading();
2927 RequestRedraw(true);
2932 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2934 // AppLog("MainForm::OnBackClicked");
2935 result r = E_FAILURE;
2937 if (__pWebViewer && __pWebViewer->CanGoBack())
2939 __pWebViewer->GoBack();
2941 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2944 pApp = UiApp::GetInstance();
2947 r = pApp->Terminate();
2950 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2958 WindowInfo* pWindowInfo = null;
2960 SceneManager* pSceneManager = SceneManager::GetInstance();
2961 if (pSceneManager == null)
2965 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2966 if (pAllWindowList == NULL)
2968 pApp = UiApp::GetInstance();
2971 r = pApp->Terminate();
2974 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2979 if (pAllWindowList != null)
2981 totalCount = pAllWindowList->GetCount();
2983 for (int count = 0; count < totalCount; count++)
2985 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2986 if (pWindowInfo == null)
2988 pApp = UiApp::GetInstance();
2991 r = pApp->Terminate();
2994 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2999 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3001 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3004 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3007 r = pAllWindowList->RemoveAt(count, true);
3008 __pWindowInfo = null;
3011 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3016 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3020 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3022 if (pWindowInfo == null)
3024 pApp = UiApp::GetInstance();
3027 r = pApp->Terminate();
3033 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3036 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3050 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3052 AppLog("MainForm::OnForwardClicked");
3053 if (__pWebViewer == null)
3056 if (__pWebViewer->CanGoForward())
3058 __pWebViewer->GoForward();
3063 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3065 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3066 if(__pFooterPanel != null)
3068 __pFooterPanel->SetShowState(false);
3071 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3073 __pAddressbar->SetShowState(true);
3074 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3077 RelayoutControls(false);
3081 MainForm::OnAddressBarFocusLost(const Addressbar& addBar)
3083 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3086 __pAddressbar->SetShowState(false);
3089 AppLog("akjshdasd 3");
3090 __pFooterPanel->SetShowState(true);
3093 RelayoutControls(false);
3097 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3099 AddressBarCancelledClicked(addBar);
3103 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3105 __prevAddressBarMode = __curAddressBarMode;
3107 if (__pAddressbar != null)
3109 __curAddressBarMode = GetAddressbarMode();
3112 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3114 __adressPanelPosition.y = 0;
3115 if (__pAddressbar != null)
3117 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3118 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3119 __pAddressbar->Invalidate(true);
3121 if (__pWebViewer != null)
3123 __pWebViewer->StopLoading();
3126 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3128 __adressPanelPosition.y = 0;
3129 if (__pAddressbar != null)
3131 __webControlPosition.y = 0;
3132 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3133 __pAddressbar->Invalidate(true);
3139 MainForm::OnClipboardClosed(const Addressbar& addBar)
3141 RelayoutControls(false);
3145 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3147 RelayoutControls(false,footerState);
3151 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3153 RelayoutControls(false);
3157 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3159 __pFooterPanel->SetShowState(false);
3163 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3165 AppLog("KeypadBoundsChanged");
3166 RelayoutControls(false);
3170 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3174 __pWindowInfo->pageTitle = title;
3175 if (__pWebViewer != null)
3177 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3180 if (__pAddressbar != null && __pWebViewer != null)
3182 SetUrl(__pWebViewer->GetUrl());
3183 __pAddressbar->Invalidate(true);
3188 MainForm::UpdateFavicon(void)
3190 bool urlImageType = false;
3191 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();");
3192 Bitmap* pBitmap = null;
3194 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3196 if (__pWindowInfo != null)
3199 url.SetUri(*tempPath);
3200 if (url.GetHost().GetLength() == 0)
3203 webUrl.SetUri(__pWebViewer->GetUrl());
3204 result r = url.SetHost(webUrl.GetHost());
3211 if (url.GetScheme().GetLength() == 0)
3214 webUrl.SetUri(__pWebViewer->GetUrl());
3215 url.SetScheme(webUrl.GetScheme());
3217 __pWindowInfo->faviconUrl = url.ToString();
3219 pBitmap = __pWebViewer->GetFaviconN();
3221 if (pBitmap != null)
3223 if (__pWindowInfo->pFavicon != NULL)
3225 __pWindowInfo->pFavicon = null;
3227 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3228 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3230 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3232 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3234 else if(__pWindowInfo->pFavicon != null)
3236 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3240 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3241 if(pDefaultBmp != null)
3243 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3252 if(tempPath != null)
3256 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3263 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3264 Tizen::Web::Controls::WebNavigationType type)
3266 // when load new page if find word panel is open its show state is false
3267 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3269 __currentSearchStr = L"";
3270 __currentWordIndex = 0;
3271 __maxOccurrances = 0;
3272 __pFindWordEditField->SetText(L"");
3273 __pFindWordNext->SetEnabled(false);
3274 __pFindWordPrev->SetEnabled(false);
3275 __pFindWordCountLabel->SetText(L"0/0");
3276 __pFindWordControl->SetShowState(false);
3277 __pFindWordEditField->HideKeypad();
3278 RelayoutControls(false);
3283 __pFooterPanel->Invalidate(true);
3286 uriInfo.SetUri(url);
3288 if(url.Contains(IDS_TIZEN_SERVICE))
3291 String delim(L":;,");
3293 // Creates a StringTokenizer instance
3294 StringTokenizer strTok(url, delim);
3296 int count = strTok.GetTokenCount(); // count == 4
3298 HashMap *pMap = new HashMap();
3304 while (strTok.HasMoreTokens())
3306 AppLog("Token: %ls", token.GetPointer());
3307 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3308 if(token.Contains(IDS_APPID))
3310 token.SubString(6, appId);
3311 AppLog("AppID:%ls", appId.GetPointer());
3313 else if(token.Contains("="))
3315 String *pKey = new String();
3316 String *pValue = new String();
3318 token.IndexOf("=", 0, index);
3321 token.SubString(0, index, *pKey);
3322 token.SubString(index + 1, *pValue);
3323 pMap->Add(pKey, pValue);
3329 AppControl *pAppControl = null;
3330 String operationId = L"http://tizen.org/appcontrol/operation/main";
3331 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3334 result r = pAppControl->Start(null, null, pMap, null);
3338 AppLogException("AppControl not found");
3348 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3349 const Tizen::Net::Http::HttpHeader& httpHeader)
3351 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3356 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3358 AppLog("MainForm::OnWebPageBlockSelected");
3359 if (__pHitElementResult != null)
3361 delete __pHitElementResult;
3362 __pHitElementResult = null;
3365 if (__pWebViewer != null)
3367 AppLog("MainForm::OnWebPageBlockSelected web not null");
3368 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3369 if(GetLastResult() == E_INVALID_ARG)
3371 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3375 if (__pHitElementResult == null)
3380 if (__pHitElementResult->HasImage() != true)
3382 String tagName = __pHitElementResult->GetTagName();
3383 String type = __pHitElementResult->GetAttributeValue("type");
3385 __currentSelectedStr.Clear();
3386 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3387 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3388 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3390 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
3392 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3394 InitSelectTextContextMenu(endPoint,true);
3395 __pImageMenu->SetShowState(true);
3396 __pImageMenu->Show();
3397 __pImageMenu->Invalidate(true);
3399 else if(__isLongPressedDone == true)
3401 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3403 if(__pHitElementResult->GetUrl().GetLength() > 0)
3405 __currentSelectedStr.Clear();
3406 __currentSelectedStr = __pHitElementResult->GetUrl();
3408 InitSelectTextContextMenu(endPoint,false);
3409 __pImageMenu->SetShowState(true);
3410 __pImageMenu->Show();
3411 __pImageMenu->Invalidate(true);
3414 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3415 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3416 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3422 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3428 MainForm::OnWebWindowCreateRequested(void)
3430 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3432 if (pNewWindowInfo == null)
3436 result r = E_SUCCESS;
3437 SceneManager* pSceneManager = SceneManager::GetInstance();
3438 if (pSceneManager == NULL)
3442 ArrayList* pArgList = new(std::nothrow) ArrayList();
3443 if (pArgList == NULL)
3447 r = pArgList->Construct();
3450 pNewWindowInfo->isJavascriptInitiated = true;
3451 pArgList->Add(*pNewWindowInfo);
3452 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3456 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3463 return pNewWindowInfo->pCurrentWeb;
3467 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3469 __webControlPosition.y = 0;
3470 __webControlHeight = GetClientAreaBounds().height;
3471 AppLog("Client area height: %d", __webControlHeight);
3473 AppLog("Client area height: %d", __webControlHeight);
3474 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3476 __webControlPosition.y += __pAddressbar->GetHeight();
3477 __webControlHeight -= __pAddressbar->GetHeight();
3478 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3480 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3482 __webControlPosition.y += __pFindWordControl->GetHeight();
3483 __webControlHeight -= __pFindWordControl->GetHeight();
3484 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3487 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3489 __webControlHeight -= __pFooterPanel->GetHeight();
3491 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3493 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3495 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3496 __pWebViewer->Invalidate(false);
3498 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3500 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3507 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3509 if (__pFindWordControl == null)
3515 InitFindWordPanel();
3516 // __pFindWordEditField->SetText(__currentSearchStr);
3517 //__pFindWordCountLabel->SetText(L"");
3518 // __pFindWordCountLabel->SetText(L"0/0");
3519 __pFindWordControl->SetShowState(true);
3523 if(__pFindWordControl != null)
3525 __pFindWordControl->SetShowState(false);
3529 AppLog("MainForm::ShowFindWordPanel %d",show);
3530 if (show && !isTouchPressed)
3532 if (__pFindWordEditField)
3534 __pFindWordEditField->SetFocus();
3535 __pFindWordEditField->ShowKeypad();
3540 if (__pFindWordEditField)
3541 __pFindWordEditField->HideKeypad();
3544 RelayoutControls(false);
3548 MainForm::StartWordSearch()
3550 //Get the count of occurances of the word in the current page
3551 __maxOccurrances = 0;
3552 __currentWordIndex = 0;
3554 __pFindWordPrev->SetEnabled(false);
3555 String *pCountStr = null;
3556 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3557 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3558 if (pCountStr != null)
3560 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3564 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3569 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3571 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3572 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3574 if(totalCount == -1 || totalCount == 0)
3576 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3577 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3580 else if(totalCount > 100)
3582 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3583 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3587 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3588 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3591 __maxOccurrances = totalCount;
3592 __currentWordIndex = currentOrdinal;
3594 //Reset the UI controls as per the maxOccurrance value
3595 if (totalCount <= 0)
3597 AppLog("Word not found");
3598 //Show error notification to user
3599 __pFindWordNext->SetEnabled(false);
3600 __pFindWordCountLabel->SetText(L"0/0");
3601 __pFindWordNext->Invalidate(false);
3602 __pFindWordPrev->Invalidate(false);
3603 __pFindWordCountLabel->Invalidate(false);
3607 if (totalCount == 1)
3609 __pFindWordNext->SetEnabled(false);
3613 __pFindWordNext->SetEnabled(true);
3616 String countStr = L"";
3617 countStr.Append(__currentWordIndex);
3618 countStr.Append(L"/");
3619 countStr.Append(__maxOccurrances);
3620 __pFindWordCountLabel->SetText(countStr);
3621 // __pFindWordCountLabel->SetShowState(true);
3622 __pFindWordCountLabel->Invalidate(false);
3624 //FindNextWord(true);
3625 //Update the controls
3626 __pFindWordNext->Invalidate(false);
3627 __pFindWordPrev->Invalidate(false);
3628 __pFindWordCountLabel->Invalidate(false);
3632 MainForm::FindNextWord(bool next)
3636 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3638 if(__currentWordIndex < __maxOccurrances)
3640 __currentWordIndex++;
3646 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3648 if(__currentWordIndex > 1)
3650 __currentWordIndex--;
3655 String countStr = L"";
3656 countStr.Append(__currentWordIndex);
3657 countStr.Append(L"/");
3658 countStr.Append(__maxOccurrances);
3659 __pFindWordCountLabel->SetText(countStr);
3660 // __pFindWordCountLabel->SetShowState(true);
3661 __pFindWordCountLabel->Invalidate(false);
3662 if (__currentWordIndex >= __maxOccurrances)
3664 __pFindWordNext->SetEnabled(false);
3668 __pFindWordNext->SetEnabled(true);
3670 if (__currentWordIndex <= 1)
3672 __pFindWordPrev->SetEnabled(false);
3676 __pFindWordPrev->SetEnabled(true);
3678 __pFindWordPrev->Invalidate(false);
3679 __pFindWordNext->Invalidate(false);
3680 __pFindWordCountLabel->Invalidate(false);
3681 __pFindWordControl->Invalidate(true);
3684 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3686 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
3687 __isWebKeypadOpened = true;
3688 __pFooterPanel->SetShowState(false);
3689 // OnAddressBarKeypadOpened(*__pAddressbar);
3693 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3695 AppLog("xyz::MainForm::OnWebKeypadOpened");
3697 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3699 __currentSearchStr = L"";
3700 __currentWordIndex = 0;
3701 __maxOccurrances = 0;
3702 __pFindWordEditField->SetText(L"");
3703 __pFindWordNext->SetEnabled(false);
3704 __pFindWordPrev->SetEnabled(false);
3705 __pFindWordCountLabel->SetText(L"0/0");
3706 __pWebViewer->SearchTextAllAsync(L"",false);
3707 __pFindWordControl->SetShowState(false);
3708 __pFindWordEditField->HideKeypad();
3712 if (__pWebViewer != null && __pFooterPanel != null)
3714 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3715 if(__pAddressbar != null)
3717 __pAddressbar->SetShowState(false);
3719 if(__pFindWordControl != null)
3721 __pFindWordControl->SetShowState(false);
3723 __pFooterPanel->SetShowState(false);
3724 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3726 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
3728 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
3729 // AppLog("omgomgomg");
3735 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3737 AppLog("xyz::MainForm::OnWebKeypadClosed");
3738 AppLog("akjshdasd 4");
3739 __pFooterPanel->SetShowState(true);
3740 // OnAddressBarKeypadClosed(*__pAddressbar);
3741 RelayoutControls(false);
3742 __isWebKeypadOpened = false;
3746 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3748 Control* temp = const_cast< Control* >(&source);
3749 Header* pHeader = dynamic_cast< Header* >(temp);
3750 if (pHeader != null)
3752 //Header double - clicked
3753 AppLog("Header double clicked");
3755 if(__pFindWordControl)
3757 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3758 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3762 AppLog("MainScene::OnTouchDoublePressed");
3766 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3768 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
3770 if (__pHitElementResult != null)
3772 delete __pHitElementResult;
3773 __pHitElementResult = null;
3776 if (__pWebViewer != null)
3778 AppLog("MainForm::OnTouchLongPressed web not null");
3779 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3782 if (__pHitElementResult == null)
3787 if (__pHitElementResult->HasImage() == true)
3789 InitImageContextMenu(currentPosition);
3790 __pImageMenu->SetShowState(true);
3791 __pImageMenu->Show();
3792 __pImageMenu->Invalidate(true);
3794 else if(__pHitElementResult->HasUrl() == true)
3796 String tempURl = __pHitElementResult->GetUrl();
3797 AppLog("tempURl is %ls", tempURl.GetPointer());
3798 const Bitmap* pBitmap = __pHitElementResult->GetImage();
3799 if (pBitmap != null)
3807 InitImageLinkContextMenu(currentPosition);
3808 __pImageMenu->SetShowState(true);
3809 __pImageMenu->Show();
3810 __pImageMenu->Invalidate(true);
3814 String tagName = __pHitElementResult->GetTagName();
3815 String type = __pHitElementResult->GetAttributeValue("type");
3816 String value = __pHitElementResult->GetAttributeValue(L"value");
3817 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3819 __currentSelectedStr.Clear();
3820 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3822 AppLog("tag name is %ls", tagName.GetPointer());
3823 AppLog("type is %ls", type.GetPointer());
3824 AppLog("innerHtml is %ls", innerHtml.GetPointer());
3826 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3828 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3830 InitSelectTextContextMenu(currentPosition,true, true);
3833 __pImageMenu->SetShowState(true);
3834 __pImageMenu->Show();
3835 __pImageMenu->Invalidate(true);
3838 __isLongPressedDone = true;
3839 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
3840 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
3843 // __inputEventToBeSupressed = true;
3847 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3849 AppLog("MainForm::OnTouchReleased");
3852 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3853 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3855 __pWebViewer->ConsumeInputEvent();
3857 if(pHitElement != null)
3861 __inputEventToBeSupressed = false;*/
3865 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3872 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3874 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3876 __currentSearchStr = L"";
3877 __currentWordIndex = 0;
3878 __maxOccurrances = 0;
3879 __pFindWordEditField->SetText(L"");
3880 __pFindWordNext->SetEnabled(false);
3881 __pFindWordPrev->SetEnabled(false);
3882 __pFindWordCountLabel->SetText(L"0/0");
3883 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3884 __pFindWordControl->SetShowState(false);
3885 __pFindWordEditField->HideKeypad();
3887 if(__pAddressbar->GetShowState() == false)
3889 __pAddressbar->SetAddressbarURLFocus();
3890 __pFooterPanel->SetShowState(false);
3897 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3903 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3909 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3915 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3921 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3927 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3929 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3930 int widthContextItem = 0;
3932 // As per the platform engineer comment removed this line
3933 /*if(__pWebViewer != null)
3935 // 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
3936 __pWebViewer->ReleaseBlock();
3939 if(__pFindWordControl != null)
3940 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
3941 if ( __pFooterLabel != null)
3943 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3946 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3951 if (__pFindWordBgLabel != null)
3953 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3954 if (pBitmap != null)
3956 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3962 __pMenu->SetShowState(false);
3963 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3965 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3969 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3974 AppLog("__pFooterPanel->GetShowState() is true");
3976 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3977 __pFooterPanel->Invalidate(true);
3981 if(__pMoreButton && __pMenu)
3983 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3984 __pMenu->SetAnchorPosition(p);
3985 __pMenu->Invalidate(true);
3988 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3989 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3991 InitMostVisitedSitesView(orientationStatus);
3994 RelayoutControls(false);
3995 if (__pArticleReaderPanel != null)
3997 if (__pArticleReaderPanel->GetShowState() == true)
3999 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4001 if (__pBlankPanel != null)
4002 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4004 if (__pWebReader != null)
4006 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4008 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4009 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4011 if ( pBitmap != null && pSrcBitmap != null)
4013 AppLog("CreateReaderPanel ninepatchbitmap found");
4014 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4017 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4018 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4019 if (pBitmap != null)
4024 if (pSrcBitmap != null)
4033 if (__pAddressbar != null)
4035 int width = GetClientAreaBounds().width;
4036 __pAddressbar->OrientationChanged(width);
4041 MainForm::OnSettingsChange(int settingvalue)
4043 AppLogDebug("MainForm::OnSettingsChange entered");
4045 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4047 __pAddressbar->ResetGuideText();
4049 if (__pWebViewer == null)
4051 AppLogDebug("Webviewer is not initialized yet.");
4055 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4057 WebSetting settings = __pWebViewer->GetSetting();
4058 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4060 settings.SetAutoFittingEnabled(true);
4062 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
4064 settings.SetAutoFittingEnabled(false);
4066 __pWebViewer->SetSetting(settings);
4068 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4070 WebSetting settings = __pWebViewer->GetSetting();
4071 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4072 __pWebViewer->SetSetting(settings);
4074 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4076 WebSetting settings = __pWebViewer->GetSetting();
4077 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4078 __pWebViewer->SetSetting(settings);
4080 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4082 WebSetting settings = __pWebViewer->GetSetting();
4083 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4084 __pWebViewer->SetSetting(settings);
4086 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4090 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4094 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4096 WebSetting settings = __pWebViewer->GetSetting();
4097 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4099 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4103 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4105 __pWebViewer->SetSetting(settings);
4107 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4111 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4112 WebSetting settings = __pWebReader->GetSetting();
4113 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4114 __pWebReader->SetSetting(settings);
4120 MainForm::OnSettingsReset()
4124 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4125 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4130 MainForm::OnClearCache()
4132 result r = E_SUCCESS;
4134 if (__pWebViewer != NULL)
4136 r = __pWebViewer->ClearCache();
4139 AppLogDebug("Cache cleared success");
4143 AppLogDebug("Cache cleared fail");
4149 MainForm::OnClearCookie()
4151 result r = E_SUCCESS;
4153 if (__pWebViewer != NULL)
4155 __pWebViewer->ClearCookie();
4159 AppLogDebug("Cookie cleared success");
4163 AppLogDebug("Cache cleared fail");
4168 MainForm::OnClearFormData()
4170 result r = E_SUCCESS;
4172 if (__pWebViewer != NULL)
4174 __pWebViewer->ClearFormData();
4178 AppLogDebug("Cookie cleared success");
4182 AppLogDebug("Cache cleared fail");
4187 MainForm::OnClearPasswords()
4189 result r = E_SUCCESS;
4191 if (__pWebViewer != NULL)
4193 __pWebViewer->ClearLoginFormData();
4197 AppLogDebug("Cookie cleared success");
4201 AppLogDebug("Cache cleared fail");
4207 MainForm::findDistance(int x1,int y1,int x2, int y2)
4209 int deltaX = Math::Abs(x2 - x1);
4210 int deltaY = Math::Abs(y2 - y1);
4211 double num = deltaX*deltaX + deltaY*deltaY;
4217 for (i = 0; i < 20; i++)
4219 x = (((x*x)+ num)/(2*x));
4230 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4232 if(__pFindWordControl)
4234 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4235 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4237 __isLongPressedDone = false;
4240 IList* pList = null;
4241 pList = touch.GetTouchInfoListN(source);
4245 int count = pList->GetCount();
4248 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4249 __touchPoint1 = pTouchInfo->position;
4251 /*if (__pAddressbar != null)
4253 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4255 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4257 __pAddressbar->SaveAddressbarEditText();
4259 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4262 __pAddressbar->Invalidate(true);
4264 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4266 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4268 //__pAddressbar->SaveAddressbarEditText();
4270 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4273 else if (count == 2)
4275 AppLogDebug("MainForm::OnTouchPressed count is two");
4276 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4277 __touchPoint1 = pTouchInfo->position;
4279 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4280 __touchPoint2 = pTouchInfo->position;
4286 pList->RemoveAll(true);
4293 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4295 // __currentWordIndex = 0;
4296 __isLongPressedDone = false;
4301 MainForm::MoveUiControls()
4306 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4308 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4310 if(__pFooterUrlField->GetTextLength() == 0)
4312 __pFooterUrlField->SetKeypadActionEnabled(false);
4316 __pFooterUrlField->SetKeypadActionEnabled(true);
4319 if (__pFindWordEditField != null)
4321 __currentSearchStr = __pFindWordEditField->GetText();
4322 __pFindWordNext->SetEnabled(false);
4323 __pFindWordPrev->SetEnabled(false);
4324 __pFindWordNext->Invalidate(true);
4325 __pFindWordPrev->Invalidate(true);
4326 __pFindWordCountLabel->SetText(L"0/0");
4327 __pFindWordCountLabel->Invalidate(true);
4329 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4330 if (__currentSearchStr.GetLength() > 0)
4336 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4338 __currentSearchStr = L"";
4339 AppLogDebug("Enter something");
4344 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4351 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4353 if(__pWebViewer != null)
4356 AppLog("MainForm::InitMostVisitedSitesView");
4357 result r = E_SUCCESS;
4360 if (__pWebViewer != null && __pMostVisitedListView != null)
4365 if (__pMostVisitedListView != null)
4367 RemoveControl(__pMostVisitedListView);
4369 if(__pMostVisitedSites != null)
4371 __pMostVisitedSites->RemoveAll(true);
4374 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4376 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4377 __pMostVisitedListView = new(std::nothrow) ListView();
4379 int height = GetClientAreaBounds().height;
4381 if(__pFooterPanel->GetShowState() == true)
4383 height = height - __pFooterPanel->GetHeight();
4385 if(__pAddressbar->GetShowState() == true)
4387 height -= __pAddressbar->GetHeight();
4390 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4394 delete __pMostVisitedListView;
4395 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4398 __pMostVisitedListView->SetItemProvider(*this);
4399 __pMostVisitedListView->AddListViewItemEventListener(*this);
4400 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4401 AddControl(__pMostVisitedListView);
4402 __pMostVisitedListView->UpdateList();
4409 MainForm::GetImagePath(void)
4413 String formattedTime;
4414 DateTime currentTime;
4415 LocaleManager localManager;
4416 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4418 localManager.Construct();
4419 Locale locale = localManager.GetSystemLocale();
4420 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4422 // Get date formatter
4423 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4427 pTimeFormatter->Format(currentTime, formattedTime);
4430 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4431 String delim(L" :");
4432 StringTokenizer strTok(formattedTime, delim);
4435 String str1("GMT+00");
4436 while (strTok.HasMoreTokens())
4438 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4439 if(token.Equals(str1))
4441 AppLog("token is %ls", token.GetPointer());
4442 imageName.Append(token);
4448 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4450 result r = E_FAILURE;
4451 AppLog("Content manager 1");
4452 ContentId contentId;
4453 ContentManager contentManager;
4454 r = contentManager.Construct();
4457 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4460 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4461 contentPath.Append(imageName);
4462 contentPath.Append(".jpg");
4463 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4464 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4468 MainForm::SetForwardButtonEnabled(bool isEnabled)
4470 __pGoForwardBtn->SetEnabled(isEnabled);
4471 __pGoForwardBtn->Invalidate(true);
4475 MainForm::SetBackButtonEnabled(bool isEnabled)
4477 __pGoBackBtn->SetEnabled(isEnabled);
4478 __pGoBackBtn->Invalidate(true);
4482 MainForm::UpdateProgress(int percentage)
4484 __progressPercentage = percentage;
4485 if (percentage == 0 || percentage == 100)
4487 __isLoadingData = false;
4488 if (percentage == 100)
4490 __isLoadingCompleted = true;
4491 __progressPercentage = 0;
4495 __isLoadingCompleted = false;
4500 __isLoadingData = true;
4502 UpdateProgressBitmap();
4506 MainForm::GetProgress(void)
4508 return __progressPercentage;
4512 MainForm::UpdateProgressBitmap(void)
4514 result r = E_SUCCESS;
4515 if (__pProgressbarLabel == null)
4517 int w = __pProgressbarLabel->GetWidth();
4518 int h = __pProgressbarLabel->GetHeight();
4520 int progressWidth = 0;
4521 Bitmap* pRetBitmap = null;
4523 if (__progressPercentage == 0 || __progressPercentage == 100)
4525 __pProgressbarLabel->SetShowState(false);
4526 __pProgressbarLabel->Invalidate(false);
4531 __pProgressbarLabel->SetShowState(true);
4532 __pProgressbarLabel->Invalidate(false);
4535 r = canvas.Construct(Rectangle(0, 0, w, h));
4539 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4544 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4548 pBgBmp->Scale(Dimension(w, h));
4549 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4553 progressWidth = (double) (w) * __progressPercentage / 100;
4554 AppLogDebug("progressWidth: %d", progressWidth);
4555 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4557 if (pProgressBmp != null)
4559 pProgressBmp->Scale(Dimension(progressWidth, h));
4560 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4561 delete pProgressBmp;
4564 pRetBitmap = new (std::nothrow) Bitmap();
4566 if (pRetBitmap == null)
4568 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4572 pRetBitmap->Construct(canvas, canvas.GetBounds());
4574 if (__pProgressbarLabel != null && pRetBitmap != null)
4576 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4577 __pProgressbarLabel->Invalidate(false);
4580 if (pRetBitmap != null)
4589 MainForm::ReaderClicked()
4591 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
4595 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
4597 CreateReaderPanel();
4598 AppLogDebug("MainScene::ReaderClicked entered");
4601 /*if (__pArticleReaderPanel)
4603 AppLogDebug("showstate true for reader panel");
4604 __pArticleReaderPanel->SetShowState(true);
4605 __pArticleReaderPanel->Show();
4607 int xPos = __pArticleReaderPanel->GetX();
4608 int yPos = __pArticleReaderPanel->GetY();
4609 AppLog("ReaderClicked() xPos = %d",xPos);
4610 AppLog("ReaderClicked() yPos = %d",yPos);
4612 if (__pReaderData == null)
4617 String loadData = L"<html>\
4619 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
4624 background-color: transparent;\
4643 <body style='width:'";
4644 loadData.Append(bodyWidth);
4645 loadData.Append(L"px'>");
4646 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
4647 loadData.Append(*__pReaderData);
4648 loadData.Append(L"</body></html>");
4651 buf.Construct(loadData.GetLength());
4652 AppLogDebug("data->GetLength %d",loadData.GetLength());
4653 for (int z=0;z<loadData.GetLength();z++)
4656 loadData.GetCharAt(z,b);
4657 buf.SetByte((byte)b);
4661 if (__pWebReader != null)
4663 __pWebReader->LoadData(L"",buf,L"text/html");
4664 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
4668 AppLogDebug("cannot LoadData __pWebReader is null");
4673 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4675 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4677 __currentAddMode = addMode;
4681 case ADDRESSBAR_MODE_INVALID:
4686 case ADDRESSBAR_MODE_READER:
4688 __pStopBtn->SetShowState(false);
4689 __pRefreshBtn->SetShowState(false);
4690 __pClearBtn->SetShowState(false);
4691 __pReaderBtn->SetShowState(false);
4694 case ADDRESSBAR_MODE_LOADING:
4696 __pRefreshBtn->SetShowState(false);
4697 __pStopBtn->SetShowState(true);
4698 __pClearBtn->SetShowState(false);
4699 __pReaderBtn->SetShowState(false);
4702 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4704 // SetUrl(__pAddressbar->GetUrl());
4706 __pRefreshBtn->SetShowState(true);
4707 __pStopBtn->SetShowState(false);
4708 __pClearBtn->SetShowState(false);
4709 __pReaderBtn->SetShowState(false);
4712 case ADDRESSBAR_MODE_EDIT:
4714 __pRefreshBtn->SetShowState(false);
4715 __pStopBtn->SetShowState(false);
4716 __pReaderBtn->SetShowState(false);
4717 __pClearBtn->SetShowState(true);
4724 OnAddressBarModeChanged();
4727 AddressBarMode MainForm::GetAddressbarMode(void)
4729 return __currentAddMode;
4732 void MainForm::SetUrl(const String& url)
4736 if (__pFooterUrlField != NULL)
4738 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4739 if (removedHttpUrl.IsEmpty() == false)
4741 __pFooterUrlField->SetText(removedHttpUrl);
4742 if(__pAddressbar != NULL)
4743 __pAddressbar->SetUrl(__displayUrl);
4747 __pFooterUrlField->SetText(__displayUrl);
4748 if(__pAddressbar != NULL)
4749 __pAddressbar->SetUrl(__displayUrl);
4751 if(__pFooterUrlField)
4752 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
4753 __pFooterUrlField->Invalidate(false);
4754 if(__pAddressbar != NULL)
4755 __pAddressbar->Invalidate(true);
4756 // __pFooterUrlField->SetCursorPosition(0);
4761 MainForm::RemoveHttpTextFromDisplayURL(void)
4763 bool isHttpText = __displayUrl.Contains(L"http://");
4764 String updatedDisplayUrl;
4765 updatedDisplayUrl.Clear();
4767 if (isHttpText == true)
4769 __displayUrl.SubString(7,updatedDisplayUrl);
4771 return updatedDisplayUrl;
4774 void MainForm::OnSharePopupControlStarted(void)
4776 __pWebViewer->AddTouchEventListener(*this);
4779 void MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
4781 if (requestId == BACK_GROUND_APP_EVENT)
4783 if(__pWebViewer != null)
4785 __pWebViewer->Pause();
4788 else if(requestId == FORE_GROUND_APP_EVENT)
4790 if(__pWebViewer != null)
4792 __pWebViewer->Resume();
4798 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
4800 result r = E_SUCCESS;
4801 AppLog("akjshdasd 5");
4802 __pFooterPanel->SetShowState(true);
4805 __pWebViewer->SetFocus();
4806 else if(__pMostVisitedListView)
4807 __pMostVisitedListView->SetFocus();
4808 else if(__pMultiWindowButton)
4809 __pMultiWindowButton->SetFocus();
4810 __pMoreButton->SetFocus();
4812 __pAddressbar->SetShowState(false);
4814 RelayoutControls(false);