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 <FShellNotificationManager.h>
31 #include "IntBookmarkData.h"
32 #include "IntBookmarkPresentationModel.h"
33 #include "IntCommonLib.h"
34 #include "IntFaviconManager.h"
35 #include "IntInternetApp.h"
36 #include "IntMainForm.h"
37 #include "IntSceneRegister.h"
38 #include "IntSettingPresentationModel.h"
40 using namespace Tizen::App;
41 using namespace Tizen::Base;
42 using namespace Tizen::Base::Collection;
43 using namespace Tizen::Base::Runtime;
44 using namespace Tizen::Base::Utility;
45 using namespace Tizen::Graphics;
46 using namespace Tizen::Io;
47 using namespace Tizen::Locales;
48 using namespace Tizen::Media;
49 using namespace Tizen::Shell;
50 using namespace Tizen::Ui;
51 using namespace Tizen::Ui::Controls;
52 using namespace Tizen::Content;
53 using namespace Tizen::Ui::Scenes;
54 using namespace Tizen::System;
55 using namespace Tizen::Web;
56 using namespace Tizen::Web::Controls;
58 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
59 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
60 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
61 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
65 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
66 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
67 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
68 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
69 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
70 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
71 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
72 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
73 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
74 static const wchar_t* IDS_APPID = L"AppID";
75 static const wchar_t* IDS_KEY = L"key";
76 static const wchar_t* IDS_VALUE = L"value";
77 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
78 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
79 //static const wchar_t* IDB_ADDRESS_BAR_BACKGROUND = L"I01_toolbar_bg_02.9.png";
81 const int IDA_BACKBTN_CLICKED = 101;
82 const int IDA_BOOKMARKBTN_CLICKED = 102;
83 const int IDA_MOREBTN_CLICKED = 103;
84 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
85 const int IDA_NEWWINDOWBTN_CLICKED = 105;
86 const int IDA_FORWARD_CLICKED = 106;
87 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
88 const int IDA_SHARE_CLICKED = 108;
89 const int IDA_FINDONPAGE_CLICKED = 109;
90 const int IDA_PRIVATEON_CLICKED = 110;
91 const int IDA_SETTINGS_CLICKED = 111;
92 const int IDA_READER_CLOSE_CLICKED = 112;
93 const int IDA_SMALLFONT_BTN_CLICKED = 113;
94 const int IDA_LARGEFONT_BTN_CLICKED = 114;
95 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
96 const int IDA_HISTORY_CLICKED = 116;
97 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
98 const int IDA_ADD_TO_HOME_CLICKED = 118;
99 const int IDA_SAVED_PAGES_CLICKED = 119;
100 const int IDA_DESKTOP_VIEW_CLICKED = 120;
101 const int IDA_SAVE_CLICKED = 121;
102 const int IDA_PRINT_CLICKED = 122;
104 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
105 const int IDA_FINDWORD_NEXT_CLICKED = 202;
106 const int IDA_FINDWORD_PREV_CLICKED = 203;
107 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
108 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
110 const int IDA_COPY_IMAGE_CLICKED = 206;
111 const int IDA_VIEW_IMAGE_CLICKED = 207;
112 const int IDA_SAVE_IMAGE_CLICKED = 208;
113 const int IDA_SHARE_IMAGE_CLICKED = 209;
115 const int IDA_COPY_TEXT_CLICKED = 210;
116 const int IDA_PASTE_TEXT_CLICKED = 211;
117 const int IDA_FIND_TEXT__CLICKED = 212;
118 const int IDA_SHARE_TEXT_CLICKED = 213;
120 const int IDA_GO_BACK = 214;
121 const int IDA_GO_FORWARD = 215;
122 const int IDA_REFRESH_BTN_CLICKED = 216;
123 const int IDA_STOP_BTN_CLICKED = 217;
124 const int IDA_CLEAR_URL = 218;
125 const int IDA_READER_BTN_CLICKED = 219;
128 const int IDA_HYPERLINK_OPEN_CLICKED = 220;
129 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221;
130 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
131 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
133 const int IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED = 224;
135 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
137 const int MainForm::IDA_FORMAT_BITMAP = 500;
138 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
139 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
140 const int MainForm::IDA_FORMAT_URL_STRING = 503;
141 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
143 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
144 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
145 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
147 MainForm::MainForm(void)
149 //__isLongPressedDone = false;
151 __pAddressbar = null;
152 // __pMostVisitedSitesPanel = null;
153 __pMostVisitedListView = null;
154 __pFooterPanel = null;
155 __pHitElementResult = null;
156 __pWindowInfo = null;
159 __pOptionMenu = null;
160 __pFindWordControl = null;
161 __pFindWordPanelLeftToRight = null;
162 __pFindWordPanelRightToLeft = null;
163 __pFindWordBgLabel = null;
164 __pFindWordBgLabelRightToLeft = null;
165 __pFindWordEditField = null;
166 __pFindWordEditFieldRightToLeft = null;
167 __pFindWordClear = null;
168 __pFindWordClearRightToLeft = null;
169 __pFindWordCountLabel = null;
170 __pFindWordClearRightToLeft = null;
171 __pFindWordNext = null;
172 __pFindWordPrev = null;
173 __previousZoomLevel = 1.0;
175 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
178 __currentSearchStr = L"";
179 __currentSelectedStr = L"";
180 __maxOccurrances = 0;
181 __currentWordIndex = 0;
184 //__inputEventToBeSupressed = false;
185 __isLoadingData = false;
186 __isLoadingCompleted = false;
187 __progressPercentage = 0;
188 __touchPoint1 = Point(-1,-1);
189 __touchPoint2 = Point(-1,-1);
190 __longPressPoint = Point(-1,-1);
192 // __pReaderPopup = null;
193 __pReaderData = null;
195 __pReaderCloseBtn = null;
196 //__pNewWindowButton = null;
197 __pMoreButton = null;
198 __pMultiWindowButton = null;
199 __pArticleReaderPanel = null;
200 __pBlankPanel = null;
201 __pArticleReaderLabel = null;
202 __webControlHeight = 0;
203 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
204 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
205 __pMostVisitedSites = null;
206 __pFooterUrlField = null;
208 __pGoForwardBtn = null;
209 __pRefreshBtn = null;
210 __pProgressbarLabel = null;
211 __pFooterLabel = null;
215 __isWebKeypadOpened = false;
217 __pNotification = null;
220 MainForm::~MainForm(void)
222 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
226 __pAddressbar->SetAddressbarEventListener(null);
229 if(__pHistory != null)
235 if (__pReaderData != null)
237 delete __pReaderData;
238 __pReaderData = null;
241 if (__pPopUp != null)
247 if (__pHitElementResult != null)
249 delete __pHitElementResult;
250 __pHitElementResult = null;
254 delete __pOptionMenu;
255 __pOptionMenu = null;
258 String* pSelectedScene = NULL;
259 Object* pValue = NULL;
260 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
261 pSelectedScene = (String*) pValue;
263 /*if (pSelectedScene != null)
265 delete pSelectedScene;
267 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
271 MainForm::Initialize(void)
273 Construct(L"IDL_FORM");
275 // SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER);
280 MainForm::OnInitializing(void)
282 AppLog("get client area width = %d",GetClientAreaBounds().width);
283 AppLog("get client area height = %d",GetClientAreaBounds().height);
284 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
285 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
287 __fontSize = CommonUtil::GetFontSize();
288 Panel* pFooterPanel = null;
290 __pSaveImage = new Image();
291 __pSaveImage->Construct();
293 // Setup back event listener
294 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
295 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
296 AddOrientationEventListener(*this);
298 AppLogDebug(" MainForm::OnInitializing ended");
299 if (__pMostVisitedSites == null)
301 __pMostVisitedSites = new(std::nothrow) ArrayList();
302 __pMostVisitedSites->Construct();
304 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
306 __pItemContext= new(std::nothrow) ListContextItem();
307 __pItemContext->Construct();
309 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),true);
312 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
313 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
314 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
316 __pItemContextLandscape= new(std::nothrow) ListContextItem();
317 __pItemContextLandscape->Construct();
319 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
320 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
321 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
322 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
323 SetFormMenuEventListener(this);
324 AppLog("SetFormMenuEventListener result %s",GetErrorMessage(GetLastResult()));
329 MainForm::InitAddressbar(void)
331 AppLogDebug("MainForm::InitAddressbar entered");
333 result r = E_SUCCESS;
335 if (__pAddressbar != null)
339 __pAddressbar = new(std::nothrow) Addressbar();
340 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
341 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
344 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
347 __pAddressbar->SetAddressbarEventListener(this);
348 AddControl(__pAddressbar);
349 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
350 SetControlAlwaysOnTop(*__pAddressbar, true);
351 __adressPanelPosition = __pAddressbar->GetPosition();
353 AppLogDebug("MainForm::InitAddressbar exit");
359 MainForm::CreateReaderPanel(void)
361 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
362 result r = E_FAILURE;
364 Button *pSmallFontBtn = null;
365 Button *pLargeFontBtn = null;
367 __pBlankPanel = new (std::nothrow) Panel();
368 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
370 __pArticleReaderPanel = new (std::nothrow) Panel();
371 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
373 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
374 if (__pReaderCloseBtn)
376 AppLogDebug("CreateReaderPanel() 6");
377 __pReaderCloseBtn->AddActionEventListener(*this);
378 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
381 __pWebReader = new (std::nothrow) Web();
382 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
384 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
385 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
387 r = __pWebReader->SetSetting(settings);
389 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
392 __pArticleReaderLabel = new Label();
393 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
395 __pBlankPanel->AddControl(__pArticleReaderLabel);
396 __pBlankPanel->AddControl(__pArticleReaderPanel);
397 AddControl(__pBlankPanel);
399 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
400 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
401 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
403 __pArticleReaderPanel->AddControl(__pWebReader);
404 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
405 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
406 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
408 if (pBitmap != null && pSrcBitmap != null)
410 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
412 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
414 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
417 pSmallFontBtn->AddActionEventListener(*this);
418 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
421 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
424 pLargeFontBtn->AddActionEventListener(*this);
425 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
434 if (pSrcBitmap != null)
440 SetControlAlwaysOnTop(*__pBlankPanel, true);
441 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
448 MainForm::InitWebControl()
450 AppLogDebug("MainForm::InitWebControl enter");
451 result r = E_SUCCESS;
452 AppLogDebug("InitWebControl");
454 if (__pAddressbar == null || __pFooterPanel == null)
457 const int Y_WEBCONTROL_POSITION = 0;
459 __webControlHeight = GetHeight() - __pFooterPanel->GetHeight();
461 if (__pMostVisitedListView)
463 __pMostVisitedListView->SetShowState(false);
465 if (__pWebViewer != null)
467 AppLogDebug("Already initialized");
470 __pWebViewer = new(std::nothrow) Web();
471 if(__pWebViewer == NULL)
473 AppLogDebug("Initialization failed");
476 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
480 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
487 r = AddControl(__pWebViewer);
493 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
496 __webControlPosition = __pWebViewer->GetPosition();
497 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
500 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
504 __pWebViewer->SetLoadingListener(this);
505 __pWebViewer->SetWebUiEventListenerF(this);
506 __pWebViewer->SetWebKeypadEventListener(this);
507 __pWebViewer->SetFocus();
508 __pWebViewer->AddTouchEventListener(*this);
510 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
511 __pWebViewer->SetTextSearchListener(this);
514 AppLogDebug("MainForm :before return");
516 AppLogDebug("MainForm::InitWebControl Exit");
522 MainForm::SetJavascriptEnabled()
524 WebSetting settings = __pWebViewer->GetSetting();
525 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
526 __pWebViewer->SetSetting(settings);
530 MainForm::SetImageLoadEnabled()
532 WebSetting settings = __pWebViewer->GetSetting();
533 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
534 __pWebViewer->SetSetting(settings);
538 MainForm::InitFooter(void)
540 AppLogDebug("MainForm::InitFooter entered");
541 Button* pBackButton = null;
542 Button* pBookmarkButton = null;
543 Button* pMultiWindowButton = null;
544 Bitmap *pIconBitmap = null;
545 Bitmap *pBGBitmap = null;
546 Label *pBGLabel = null;
548 if (__pFooterPanel == null)
550 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
553 if (__pFooterPanel == null)
558 SetControlAlwaysOnTop(*__pFooterPanel, true);
560 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
561 if ( __pFooterLabel == NULL )
565 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
566 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
569 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
573 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
575 if ( __pMultiWindowButton == NULL )
581 SetFormBackEventListener(this);
582 AppLog("SetFormBackEventListener result %s",GetErrorMessage(GetLastResult()));
583 if (__pMultiWindowButton != null)
585 Bitmap* pBitmap = null;
586 Bitmap* pPressedBitmap = null;
587 String imagePath = "I01_toolbar_icon_windows_manager_0";
588 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
589 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
590 imagePath.Append(totalCount);
591 imagePath.Append(".png");
593 pressedImagePath.Append(totalCount);
594 pressedImagePath.Append("_press.png");
596 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
597 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
598 if ( pBitmap == null )
603 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
606 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
607 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
612 __pMultiWindowButton->AddActionEventListener(*this);
613 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
618 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
619 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
622 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
623 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
624 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
628 __pMoreButton->AddActionEventListener(*this);
629 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
632 //Add the editfield for url
633 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
634 if (__pFooterUrlField == NULL)
636 return E_INVALID_KEY;
639 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
640 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
641 __pFooterUrlField->AddKeypadEventListener(*this);
642 __pFooterUrlField->SetPropagatedTouchEventListener(this);
644 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
646 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
648 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
650 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
654 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
655 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
659 //Add the go Back Button
660 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
661 if (__pGoBackBtn == NULL)
663 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
664 return E_INVALID_KEY;
666 __pGoBackBtn->SetActionId(IDA_GO_BACK);
667 __pGoBackBtn->AddActionEventListener(*this);
669 //Add the go forward Button
670 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
671 if (__pGoForwardBtn == NULL)
673 AppLogDebug("Control not found returning E_INVALID_KEY");
674 return E_INVALID_KEY;
676 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
677 __pGoForwardBtn->AddActionEventListener(*this);
678 if (__pWebViewer && __pWebViewer->CanGoForward())
680 SetForwardButtonEnabled(true);
684 SetForwardButtonEnabled(false);
687 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
688 if (__pRefreshBtn == NULL)
690 AppLogDebug("Control not found returning E_INVALID_KEY");
691 return E_INVALID_KEY;
694 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
695 __pRefreshBtn->AddActionEventListener(*this);
696 __pRefreshBtn->SetShowState(true);
698 //Add the backround label for displaying progressbar
699 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
700 if (__pProgressbarLabel == NULL)
702 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
703 return E_INVALID_KEY;
705 __pProgressbarLabel->SetShowState(false);
707 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
708 if (__pStopBtn == NULL)
710 AppLogDebug("Control not found returning E_INVALID_KEY");
711 return E_INVALID_KEY;
713 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
714 __pStopBtn->AddActionEventListener(*this);
715 __pStopBtn->SetShowState(false);
717 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
718 if (__pClearBtn == NULL)
720 AppLogDebug("Control not found returning E_INVALID_KEY");
721 return E_INVALID_KEY;
723 __pClearBtn->SetActionId(IDA_CLEAR_URL);
724 __pClearBtn->AddActionEventListener(*this);
725 __pClearBtn->SetShowState(false);
727 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
728 if (__pReaderBtn == NULL)
730 AppLogDebug("Control not found returning E_INVALID_KEY");
731 return E_INVALID_KEY;
733 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
734 __pReaderBtn->AddActionEventListener(*this);
735 __pReaderBtn->SetShowState(false);
737 // __pFooterPanel->Invalidate(true);
738 AppLogDebug("MainForm::InitFooter exit");
743 MainForm::InitOptionMenu()
745 result r = E_SUCCESS;
746 bool isPrivateBrowsing = false;
747 Bitmap* pBitmap = null;
749 if (__pOptionMenu != null)
751 __pOptionMenu->Invalidate(true);
755 __pOptionMenu = new(std::nothrow) OptionMenu();
756 r = __pOptionMenu->Construct();
757 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
759 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
762 if (isPrivateBrowsing == true)
764 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
768 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
771 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
773 if ( pBitmap != NULL)
775 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
778 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
779 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
780 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
783 __pOptionMenu->SetMaxVisibleItemsCount(6);
784 __pOptionMenu->SetShowState(false);
785 __pOptionMenu->AddActionEventListener(*this);
786 SetControlAlwaysOnTop(*__pOptionMenu, true);
792 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
794 result r = E_SUCCESS;
795 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
797 AppLog("MainForm::InitImageContextMenu clicked on image");
798 if (__pImageMenu != null)
803 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
808 __pImageMenu = new (std::nothrow) ContextMenu();
809 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
810 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
812 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
813 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
814 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
815 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
816 __pImageMenu->SetMaxVisibleItemsCount(4);
817 __pImageMenu->AddActionEventListener(*this);
818 SetControlAlwaysOnTop(*__pImageMenu, true);
824 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
826 result r = E_SUCCESS;
827 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
829 AppLog("MainForm::InitImageContextMenu clicked on image");
830 if (__pImageMenu != null)
836 // if(__pAddressbar->GetShowState() == true)
837 // p.y = p.y + __pAddressbar->GetHeight();
838 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
843 __pImageMenu = new (std::nothrow) ContextMenu();
844 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
845 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
847 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
848 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
849 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
850 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
852 __pImageMenu->SetMaxVisibleItemsCount(3);
853 __pImageMenu->AddActionEventListener(*this);
854 SetControlAlwaysOnTop(*__pImageMenu, true);
861 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
863 result r = E_SUCCESS;
864 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
866 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
867 if (__pImageMenu != null)
876 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
880 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
882 __pImageMenu = new (std::nothrow) ContextMenu();
883 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
884 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
886 if(onlyPasteOption == false)
888 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
890 if (pasteOption || onlyPasteOption)
892 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
894 if(onlyPasteOption == false)
896 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
897 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
900 __pImageMenu->SetMaxVisibleItemsCount(3);
901 __pImageMenu->AddActionEventListener(*this);
902 SetControlAlwaysOnTop(*__pImageMenu, true);
909 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
911 result r = E_SUCCESS;
912 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
914 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
915 if (__pImageMenu != null)
924 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
928 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
930 __pImageMenu = new (std::nothrow) ContextMenu();
931 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
932 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
934 if(onlyPasteOption == false)
936 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
938 if (pasteOption || onlyPasteOption)
940 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
942 if(onlyPasteOption == false)
944 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
945 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
948 __pImageMenu->SetMaxVisibleItemsCount(3);
949 __pImageMenu->AddActionEventListener(*this);
950 SetControlAlwaysOnTop(*__pImageMenu, true);
957 MainForm::InitFindWordPanel(void)
959 result r = E_SUCCESS;
960 Bitmap *pIconBitmap = null;
962 if (__pFindWordControl != null)
964 AppLogDebug("Findword panel already initialized");
965 if (__pFindWordBgLabel != null)
967 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
970 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
974 if (__pFindWordBgLabelRightToLeft != null)
976 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
979 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
986 __pFindWordControl = new (std::nothrow) Panel();
987 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
990 AppLogException("There is some problem in the xml file. Please check.");
993 AddControl(__pFindWordControl);
994 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
995 SetControlAlwaysOnTop(*__pFindWordControl,true);
996 __pFindWordControl->SetShowState(false);
997 __pFindWordControl->Invalidate(false);
999 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1000 __pFindWordPanelLeftToRight->SetShowState(true);
1002 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1003 __pFindWordPanelRightToLeft->SetShowState(false);
1005 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1006 if (__pFindWordBgLabel != null)
1008 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1009 Rectangle pRect = pPanel1->GetBounds();
1010 pRect.x = pRect.y = 0;
1011 __pFindWordBgLabel->SetBounds(pRect);
1012 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1013 if (pBitmap != null)
1015 AppLogDebug("InitFindWordPanel: Coming here");
1016 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1021 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1025 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1026 if (__pFindWordBgLabelRightToLeft != null)
1028 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1029 Rectangle pRect = pPanel1->GetBounds();
1030 pRect.x = pRect.y = 0;
1031 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1032 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1033 if (pBitmap != null)
1035 AppLogDebug("InitFindWordPanel: Coming here");
1036 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1041 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1045 Button* pfindWordCancel = null;
1046 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1047 if (pfindWordCancel == null)
1049 AppLogException("There is some problem in the xml file. Please check.");
1052 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1053 pfindWordCancel->AddActionEventListener(*this);
1055 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1056 if (__pFindWordClear == null)
1058 AppLogException("There is some problem in the xml file. Please check.");
1062 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1063 if (__pFindWordClearRightToLeft == null)
1065 AppLogException("There is some problem in the xml file. Please check.");
1069 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1070 __pFindWordClear->AddActionEventListener(*this);
1072 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1073 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1075 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1076 if (__pFindWordNext == null)
1078 AppLogException("There is some problem in the xml file. Please check.");
1082 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1083 __pFindWordNext->AddActionEventListener(*this);
1085 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1086 if (__pFindWordPrev == null)
1088 AppLogException("There is some problem in the xml file. Please check.");
1092 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1093 __pFindWordPrev->AddActionEventListener(*this);
1095 __pFindWordNext->SetEnabled(false);
1096 __pFindWordPrev->SetEnabled(false);
1098 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1099 if (__pFindWordCountLabel == null)
1101 AppLogException("There is some problem in the xml file. Please check.");
1105 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1106 if (__pFindWordCountLabel == null)
1108 AppLogException("There is some problem in the xml file. Please check.");
1112 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1113 if (__pFindWordEditField == null)
1115 AppLogException("There is some problem in the xml file. Please check.");
1118 __pFindWordEditField->AddTextEventListener(*this);
1119 __pFindWordEditField->AddKeypadEventListener(*this);
1120 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1121 __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1123 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1124 if (__pFindWordEditFieldRightToLeft == null)
1126 AppLogException("There is some problem in the xml file. Please check.");
1129 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1130 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1131 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1132 __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1137 MainForm::CreateItem (int index, int itemWidth)
1139 Rectangle listImageRect;
1140 Rectangle pagetTitleRect;
1141 Rectangle pageURLRect;
1142 Rectangle deleteImageRect;
1143 String pageTitle(L"");
1144 String pageURL(L"");
1145 result r = E_SUCCESS;
1146 Bitmap* pListIconImage = null;
1149 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1150 if(pHistory == null)
1154 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1155 if ( pAppResource == NULL )
1159 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1161 CustomItem* pItem = new(std::nothrow) CustomItem();
1162 pageTitle = pHistory->GetHistoryTitle();
1163 pageURL = pHistory->GetHistoryUrl();
1165 if (pageURL.GetLength() == 0)
1168 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1169 pageURL = L"<"+ nourl +">";
1173 Rectangle screenBounds = GetBounds();
1176 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1185 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1187 if ( pBitmap != NULL)
1189 pListIconImage = new Bitmap();
1190 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1194 if(pListIconImage == null)
1196 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1199 if ( pListIconImage != NULL)
1201 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1202 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60 + (__fontSize - 44));
1203 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1206 if (pItem != null && pListIconImage != NULL)
1208 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1212 if (pageTitle.CompareTo(L"") != 0)
1216 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1220 if (pageURL.CompareTo(L"") != 0)
1224 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1229 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1231 if ( __pItemContext!= NULL)
1235 pItem->SetContextItem(__pItemContext);
1241 if ( __pItemContextLandscape!= NULL)
1245 pItem->SetContextItem(__pItemContextLandscape);
1249 if( pListIconImage != NULL)
1251 delete pListIconImage;
1252 pListIconImage = null;
1259 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1266 MainForm::GetItemCount (void)
1268 if(__pMostVisitedSites != null)
1270 __pMostVisitedSites->RemoveAll(true);
1272 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1273 if(__pMostVisitedSites != null)
1275 return __pMostVisitedSites->GetCount();
1282 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1284 if(__pMostVisitedSites != null)
1286 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1287 if (pHistory != null)
1289 String url = pHistory->GetHistoryUrl();
1291 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1292 __pMostVisitedListView->UpdateList();
1298 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1300 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1301 String url = pHistory->GetHistoryUrl();
1309 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1315 MainForm::OnTerminating(void)
1317 result r = E_SUCCESS;
1319 RemoveOrientationEventListener(*this);
1323 __pAddressbar->SetAddressbarEventListener(null);
1328 __pWebViewer->RemoveTouchEventListener(*this);
1333 delete __pItemContext;
1335 if (__pItemContextLandscape)
1337 delete __pItemContextLandscape;
1341 delete __pSaveImage;
1343 if (__pMostVisitedSites)
1345 __pMostVisitedSites->RemoveAll(true);
1346 delete __pMostVisitedSites;
1352 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1354 result r = E_SUCCESS;
1356 AppLogDebug("Clicked : %d", actionId);
1359 case IDA_BACKBTN_CLICKED:
1361 if (__pWebViewer && __pWebViewer->CanGoBack())
1363 __pWebViewer->GoBack();
1365 else if(__pWindowInfo->isJavascriptInitiated == false)
1368 pApp = UiApp::GetInstance();
1371 r = pApp->Terminate();
1374 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1382 WindowInfo* pWindowInfo = null;
1384 SceneManager* pSceneManager = SceneManager::GetInstance();
1385 if (pSceneManager == null)
1389 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1390 if (pAllWindowList == NULL)
1392 pApp = UiApp::GetInstance();
1395 r = pApp->Terminate();
1398 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1403 if (pAllWindowList != null)
1405 totalCount = pAllWindowList->GetCount();
1407 for (int count = 0; count < totalCount; count++)
1409 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1410 if (pWindowInfo == null)
1412 pApp = UiApp::GetInstance();
1415 r = pApp->Terminate();
1418 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1425 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1427 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1430 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1433 r = pAllWindowList->RemoveAt(count, true);
1434 __pWindowInfo = null;
1437 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1442 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1446 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1448 if (pWindowInfo == null)
1450 pApp = UiApp::GetInstance();
1453 r = pApp->Terminate();
1459 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1462 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1474 case IDA_FORWARD_CLICKED:
1475 if (__pWebViewer == null)
1478 if (__pWebViewer->CanGoForward())
1480 __pWebViewer->GoForward();
1482 __pOptionMenu->SetShowState(false);
1483 __pOptionMenu->Invalidate(false);
1486 case IDA_FINDONPAGE_CLICKED:
1488 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1489 __currentSearchStr.Clear();
1491 InitFindWordPanel();
1492 __pOptionMenu->SetShowState(false);
1493 __pOptionMenu->Invalidate(false);
1495 ShowFindWordPanel(true);
1497 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1499 __pFindWordEditField->SetFocus();
1500 __pFindWordCountLabel->SetShowState(false);
1504 __pFindWordEditFieldRightToLeft->SetFocus();
1505 __pFindWordCountLabelRightToLeft->SetShowState(false);
1509 case IDA_PRIVATEON_CLICKED:
1511 result r = E_SUCCESS;
1513 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1514 Bitmap* pBitmap = null;
1515 if (isPrivateBrowsing == true)
1517 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1520 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1524 if (__pWebViewer != NULL)
1526 __pWebViewer->SetPrivateBrowsingEnabled(false);
1529 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1531 if (__pAddressbar != null)
1533 __pAddressbar->UpdateFaviconBitmap(false);
1539 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1542 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1546 if (__pWebViewer != NULL)
1548 __pWebViewer->SetPrivateBrowsingEnabled(true);
1551 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1553 if (__pAddressbar != null)
1555 __pAddressbar->UpdateFaviconBitmap(true);
1559 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1560 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1561 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1562 __pOptionMenu->Invalidate(true);
1563 if ( pBitmap != NULL )
1570 case IDA_SETTINGS_CLICKED:
1573 ArrayList* pArgList = new(std::nothrow) ArrayList();
1576 pArgList->Construct();
1577 pArgList->Add(*__pWindowInfo);
1578 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1580 __pOptionMenu->SetShowState(false);
1581 __pOptionMenu->Invalidate(false);
1583 if (pArgList != null)
1592 case IDA_ADDTOBOOKMARK_CLICKED:
1595 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1597 int bookmarkCount=0;
1600 url=__pWindowInfo->pageUrl;
1601 result r = E_SUCCESS;
1602 Bitmap* pBitmap = null;
1603 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1611 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1612 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1613 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1615 if(__pNotification != null)
1617 RemoveControl(__pNotification);
1618 __pNotification = null;
1620 __pNotification = new (std::nothrow) NotificationPanel(*this);
1621 if (__pNotification != null)
1623 __pNotification->SetText(message);
1624 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1625 __pNotification->ShowNotification();
1630 String title=__pWindowInfo->pageTitle;
1631 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1632 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1634 pBookmark->SetBookmarkTitle(title);
1635 pBookmark->SetUrl(url);
1636 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1638 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1640 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1641 pBookmark->SetFaviconId(id);
1642 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1643 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1645 if(__pNotification != null)
1647 RemoveControl(__pNotification);
1648 __pNotification = null;
1650 __pNotification = new (std::nothrow) NotificationPanel(*this);
1651 if (__pNotification != null)
1653 __pNotification->SetText(message);
1654 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1655 __pNotification->ShowNotification();
1656 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1659 if (pBitmap != null)
1661 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1666 __pOptionMenu->Invalidate(true);
1671 case IDA_PRINT_CLICKED:
1673 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1674 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1676 AppLog("RequestPrint called!");
1677 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1678 result nResult = E_FAILURE;
1681 AppLog("TestPrint if (pAc) == true");
1686 String fileType = L"service_print_files_type";
1687 String typeVal = L"DOC";
1689 String fileCount = L"service_print_files_count";
1690 String countVal = L"1";
1691 String fileFolder= L"service_print_files_folder_name";
1692 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1694 map.Add(&fileCount, &countVal);
1695 map.Add(&fileFolder, &folderVal);
1696 map.Add(&fileType, &typeVal);
1698 String fileName = L"service_print_files_files_name";
1700 ArrayList fileNameList;
1701 fileNameList.Construct();
1702 String file1 = L"test.pdf";
1704 fileNameList.Add(&file1);
1705 map.Add(&fileName, &fileNameList);
1707 nResult = pAc->Start(NULL, NULL, &map, NULL);
1709 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1710 else if (nResult == E_MAX_EXCEEDED)
1711 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1712 else if (nResult == E_OBJ_NOT_FOUND)
1713 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1714 else if (nResult == E_IN_PROGRESS)
1715 AppLog("TestPrint ret == E_IN_PROGRESS");
1716 else if (nResult == E_PRIVILEGE_DENIED)
1717 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1718 else if(nResult == E_SYSTEM)
1719 AppLog("TestPrint ret == E_SYSTEM");
1725 int __modalMsgBoxResult;
1726 MessageBox* pMsgBox = new MessageBox();
1727 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1728 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1731 __modalMsgBoxResult = 0;
1735 case IDA_SHARE_CLICKED:
1737 if(__pPopUp != null)
1744 __pAddressbar->HideKeypad();
1746 __pPopUp = new(std::nothrow) SharePopup();
1747 __pPopUp->Initialize();
1748 if (__pWindowInfo != null)
1750 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1751 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1752 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1753 pShareInfo->SetImageAttached(false);
1754 __pPopUp->RemoveAllShareInfo();
1755 __pPopUp->AddShareInfo(pShareInfo);
1757 __pPopUp->SetShowState(true);
1761 case IDA_BOOKMARKBTN_CLICKED:
1763 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1764 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1767 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1772 case IDA_MOREBTN_CLICKED:
1774 AppLog("IDA_MOREBTN_CLICKED");
1776 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1778 int bookmarkCount=0;
1781 url=__pWindowInfo->pageUrl;
1782 result r = E_SUCCESS;
1783 Bitmap* pBitmap = null;
1785 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1788 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1793 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1797 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1799 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1801 if (__pOptionMenu->GetItemCount() == 9)
1803 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1807 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1812 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1816 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1817 if (__pOptionMenu->GetItemCount() != 9)
1819 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1820 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1821 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1822 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1823 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1824 __pOptionMenu->SetMaxVisibleItemsCount(6);
1826 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1828 AppLog(" Orientation landscape");
1829 __pOptionMenu->SetMaxVisibleItemsCount(5);
1833 AppLog(" Orientation potrait");
1834 __pOptionMenu->SetMaxVisibleItemsCount(6);
1837 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1840 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1841 __pOptionMenu->SetShowState(true);
1842 __pOptionMenu->Invalidate(true);
1843 __pOptionMenu->Show();
1847 case IDA_HISTORY_CLICKED:
1849 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1850 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1853 case IDA_SAVED_PAGES_CLICKED:
1858 case IDA_DESKTOP_VIEW_CLICKED:
1863 case IDA_SAVE_CLICKED:
1868 case IDA_MULTIWINDOWBTN_CLICKED:
1870 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1871 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1875 case IDA_NEWWINDOWBTN_CLICKED:
1877 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
1879 if (pNewWindowInfo == null)
1883 result r = E_SUCCESS;
1884 SceneManager* pSceneManager = SceneManager::GetInstance();
1886 if (pSceneManager == NULL)
1890 ArrayList* pArgList = new(std::nothrow) ArrayList();
1891 if (pArgList == NULL)
1895 r = pArgList->Construct();
1898 pArgList->Add(*pNewWindowInfo);
1899 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1905 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1910 case IDA_SMALLFONT_BTN_CLICKED:
1912 WebSetting setting = __pWebReader->GetSetting();
1913 setting.SetFontSize(15);
1914 __pWebReader->SetSetting(setting);
1917 case IDA_LARGEFONT_BTN_CLICKED:
1919 WebSetting setting = __pWebReader->GetSetting();
1920 setting.SetFontSize(25);
1921 __pWebReader->SetSetting(setting);
1924 case IDA_READER_CLOSE_CLICKED:
1926 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1928 RemoveControl(__pBlankPanel);
1929 __pArticleReaderPanel = null;
1930 __pBlankPanel = null;
1931 __pArticleReaderLabel = null;
1933 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1936 case IDA_FINDWORD_CANCEL_CLICKED:
1938 __currentSearchStr = L"";
1939 __currentWordIndex = 0;
1940 __maxOccurrances = 0;
1942 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1944 __pFindWordEditField->SetText(L"");
1945 __pFindWordCountLabel->SetText(L"0/0");
1947 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
1949 __pFindWordEditFieldRightToLeft->SetText(L"");
1950 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1953 __pFindWordNext->SetEnabled(false);
1954 __pFindWordPrev->SetEnabled(false);
1955 __pFindWordCountLabel->SetText(L"0/0");
1956 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1957 AppLog("akjshdasd 1");
1958 __pFooterPanel->SetShowState(true);
1959 ShowFindWordPanel(false);
1962 case IDA_FINDWORD_SEARCH_CLICKED:
1964 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1966 __currentSearchStr = __pFindWordEditField->GetText();
1968 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
1970 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
1973 if (__currentSearchStr.GetLength() > 0)
1979 AppLogDebug("Enter something");
1983 case IDA_FINDWORD_CLEAR_CLICKED:
1985 __pFindWordCountLabel->SetText(L"0/0");
1986 __pFindWordEditField->SetText(L"");
1987 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1989 __currentSearchStr = L"";
1990 __pFindWordNext->SetEnabled(false);
1991 __pFindWordPrev->SetEnabled(false);
1992 __pFindWordCountLabel->SetShowState(false);
1993 __pFindWordControl->Invalidate(true);
1996 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
1998 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1999 __pFindWordEditFieldRightToLeft->SetText(L"");
2000 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2002 __currentSearchStr = L"";
2003 __pFindWordNext->SetEnabled(false);
2004 __pFindWordPrev->SetEnabled(false);
2005 __pFindWordCountLabelRightToLeft->SetShowState(false);
2006 __pFindWordControl->Invalidate(true);
2009 case IDA_FINDWORD_NEXT_CLICKED:
2014 case IDA_FINDWORD_PREV_CLICKED:
2016 FindNextWord(false);
2019 case IDA_BRIGHTNESS_BTN_CLICKED:
2021 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2022 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2025 case IDA_COPY_IMAGE_CLICKED:
2027 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2028 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2030 const Bitmap* pBitmap = null;
2031 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2033 pBitmap = __pHitElementResult->GetImage();
2036 String resourcePath = App::GetInstance()->GetAppResourcePath();
2037 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2038 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2039 // copying the item to clipboard
2040 Clipboard* pClipboard = Clipboard::GetInstance();
2041 if (pClipboard != null)
2043 r = pClipboard->CopyItem(item);
2044 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2048 case IDA_VIEW_IMAGE_CLICKED:
2050 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2051 WindowInfo* pNewWindowInfo = null;
2052 if (__pHitElementResult != null)
2054 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2055 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2061 case IDA_SAVE_IMAGE_CLICKED:
2063 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2064 const Bitmap* pSaveBitmap = null;
2065 String imageName = GetImagePath();
2066 AppLog("Content manager image name %ls",imageName.GetPointer());
2069 imagePath.Append(imageName);
2070 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2071 AppLog("Content manager image path %ls",imagePath.GetPointer());
2072 if (__pHitElementResult != null)
2074 pSaveBitmap = __pHitElementResult->GetImage();
2076 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2080 UpdateImageContent(pBuffer, imageName);
2082 if(__pNotification != null)
2084 RemoveControl(__pNotification);
2085 __pNotification = null;
2087 __pNotification = new NotificationPanel(*this);
2089 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2090 msg.Append(imagePath);
2091 if (__pNotification != null)
2093 __pNotification->SetText(msg);
2094 if (__pFooterPanel->GetShowState() == true)
2096 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2100 __pNotification->SetPositionDiff(0);
2103 __pNotification->ShowNotification();
2108 int __modalMsgBoxResult;
2109 MessageBox* pMsgBox = new MessageBox();
2110 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2111 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2114 __modalMsgBoxResult = 0;
2118 case IDA_SHARE_IMAGE_CLICKED:
2120 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2121 if (__pPopUp != null)
2128 __pAddressbar->HideKeypad();
2130 __pPopUp = new(std::nothrow) SharePopup();
2131 __pPopUp->Initialize();
2132 if (__pHitElementResult != null)
2134 const Bitmap* pSaveBitmap = null;
2135 String imageName = GetImagePath();
2136 AppLog("Content manager image name %ls",imageName.GetPointer());
2139 imagePath.Append(imageName);
2140 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2141 AppLog("Content manager image path %ls",imagePath.GetPointer());
2142 if (__pHitElementResult != null)
2144 pSaveBitmap = __pHitElementResult->GetImage();
2146 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2148 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2149 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2151 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2152 pShareInfo->SetPageTitle(L"");
2153 pShareInfo->SetPageUrl(srcUrl);
2154 pShareInfo->SetImageAttached(true);
2155 pShareInfo->SetImagePath(imagePath);
2156 __pPopUp->RemoveAllShareInfo();
2157 __pPopUp->AddShareInfo(pShareInfo);
2158 __pPopUp->SetShowState(true);
2163 case IDA_HYPERLINK_OPEN_CLICKED:
2165 if (__pHitElementResult != null)
2167 String srcUrl = __pHitElementResult->GetUrl();
2169 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2171 if (pNewWindowInfo == null)
2175 result r = E_SUCCESS;
2176 SceneManager* pSceneManager = SceneManager::GetInstance();
2177 if (pSceneManager == NULL)
2181 ArrayList* pArgList = new(std::nothrow) ArrayList();
2182 if (pArgList == NULL)
2186 pArgList->Construct();
2188 pArgList->Add(*pNewWindowInfo);
2189 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2190 if (pArgList != null)
2197 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2203 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2205 if (__pHitElementResult == null)
2210 if(__pPopUp != null)
2217 __pAddressbar->HideKeypad();
2219 __pPopUp = new(std::nothrow) SharePopup();
2220 __pPopUp->Initialize();
2222 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2223 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2224 pShareInfo->SetImageAttached(false);
2225 __pPopUp->RemoveAllShareInfo();
2226 __pPopUp->AddShareInfo(pShareInfo);
2228 __pPopUp->SetShowState(true);
2232 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2236 if (__pHitElementResult != null)
2238 url = __pHitElementResult->GetUrl();
2241 String resourcePath = App::GetInstance()->GetAppResourcePath();
2242 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2244 // copying the item to clipboard
2245 Clipboard* pClipboard = Clipboard::GetInstance();
2246 if (pClipboard != null)
2248 pClipboard->CopyItem(item);
2252 case IDA_FIND_TEXT__CLICKED:
2254 // AddressBarCancelledClicked(*__pAddressbar);
2255 RelayoutControls(false);
2256 // __pFooterPanel->SetShowState(false);
2257 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2258 __currentSearchStr.Clear();
2259 __currentSearchStr.Append(__currentSelectedStr);
2260 InitFindWordPanel();
2261 __pFindWordEditField->SetText(__currentSearchStr);
2263 if(__pOptionMenu != null)
2265 __pOptionMenu->SetShowState(false);
2266 __pOptionMenu->Invalidate(false);
2268 __adressPanelPosition.y = 0;
2270 if (__pAddressbar != null && __pWebViewer != NULL)
2272 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2273 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2275 if (__pFooterPanel->GetShowState() == false)
2276 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2278 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2279 __pWebViewer->Invalidate(true);
2282 ShowFindWordPanel(true);
2283 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2285 __pFindWordEditField->SetText(__currentSearchStr);
2286 __pFindWordEditField->SetFocus();
2288 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2290 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2291 __pFindWordEditFieldRightToLeft->SetFocus();
2294 if (__currentSearchStr.GetLength() > 0)
2300 AppLogDebug("Enter something");
2303 if (__pWebViewer != null)
2305 // releasing the set block
2306 __pWebViewer->ReleaseBlock();
2311 case IDA_SHARE_TEXT_CLICKED:
2313 __pWebViewer->ReleaseBlock();
2314 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2315 if(__pPopUp != null)
2322 __pAddressbar->HideKeypad();
2324 __pPopUp = new(std::nothrow) SharePopup();
2325 __pPopUp->Initialize();
2326 if (__pHitElementResult != null)
2328 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2329 pShareInfo->SetPageTitle(L"");
2330 pShareInfo->SetPageUrl(__currentSelectedStr);
2331 pShareInfo->SetImageAttached(false);
2332 __pPopUp->RemoveAllShareInfo();
2333 __pPopUp->AddShareInfo(pShareInfo);
2334 __pPopUp->SetShowState(true);
2339 case IDA_COPY_TEXT_CLICKED:
2341 __pWebViewer->ReleaseBlock();
2342 // need to implement
2343 //__currentSelectedStr
2344 // Sets data to a clip board item
2346 String resourcePath = App::GetInstance()->GetAppResourcePath();
2347 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2349 // copying the item to clipboard
2350 Clipboard* pClipboard = Clipboard::GetInstance();
2351 if (pClipboard != null)
2353 pClipboard->CopyItem(item);
2357 case IDA_PASTE_TEXT_CLICKED:
2359 Clipboard* pClipboard = Clipboard::GetInstance();
2361 if(pClipboard == null)
2365 // Retrieves a latest item
2366 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2372 //Gets data from the clipboard item
2373 String* pString = dynamic_cast<String*>(pItem->GetData());
2375 if (pString != null)
2377 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2378 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2379 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2382 if(idElement.GetLength() != 0)
2384 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; } } ";
2385 script.Append("insertAtCursor('");
2386 script.Append(idElement);
2387 script.Append("',");
2388 script.Append("\"");
2389 script.Append(*pString);
2390 script.Append("\");");
2392 else if (nameElement.GetLength() != 0)
2394 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; } } ";
2395 script.Append("insertAtCursor(document.getElementsByName('");
2396 script.Append(nameElement);
2397 script.Append("')[0],");
2398 script.Append("\"");
2399 script.Append(*pString);
2400 script.Append("\");");
2402 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2403 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2414 case IDA_GO_FORWARD:
2419 case IDA_REFRESH_BTN_CLICKED:
2421 __isLoadingCompleted = false;
2422 __isLoadingData = true;
2423 __progressPercentage = 0;
2424 __displayUrl = __pFooterUrlField->GetText();
2426 String url = __pFooterUrlField->GetText();
2427 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2429 if (__pWebViewer != null && __pAddressbar != null)
2431 __pWebViewer->Reload();
2432 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2436 UpdateProgressBitmap();
2439 case IDA_STOP_BTN_CLICKED:
2441 __isLoadingCompleted = false;
2442 __isLoadingData = false;
2443 __progressPercentage = 0;
2444 __pFooterUrlField->HideKeypad();
2445 __displayUrl = __pFooterUrlField->GetText();
2449 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2450 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2451 __pWebViewer->StopLoading();
2452 RequestRedraw(true);
2455 UpdateProgressBitmap();
2460 if (__pFooterUrlField->GetText().IsEmpty() == false)
2462 //__displayUrl = __pUrlField->GetText();
2463 __pFooterUrlField->Clear();
2468 case IDA_READER_BTN_CLICKED:
2479 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2481 result r = E_FAILURE;
2482 if (__pWebViewer && __pWebViewer->CanGoBack())
2484 __pWebViewer->GoBack();
2486 else if(__pWindowInfo->isJavascriptInitiated == false)
2489 pApp = UiApp::GetInstance();
2492 r = pApp->Terminate();
2495 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2503 WindowInfo* pWindowInfo = null;
2505 SceneManager* pSceneManager = SceneManager::GetInstance();
2506 if (pSceneManager == null)
2510 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2511 if (pAllWindowList == NULL)
2513 pApp = UiApp::GetInstance();
2516 r = pApp->Terminate();
2519 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2524 if (pAllWindowList != null)
2526 totalCount = pAllWindowList->GetCount();
2528 for (int count = 0; count < totalCount; count++)
2530 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2531 if (pWindowInfo == null)
2533 pApp = UiApp::GetInstance();
2536 r = pApp->Terminate();
2539 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2546 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2548 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2551 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2554 r = pAllWindowList->RemoveAt(count, true);
2555 __pWindowInfo = null;
2558 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2563 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2567 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2569 if (pWindowInfo == null)
2571 pApp = UiApp::GetInstance();
2574 r = pApp->Terminate();
2580 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2583 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2595 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2596 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2599 AppLog("MainForm::OnSceneActivatedN called");
2600 String* pSelectedScene = NULL;
2601 Object* pValue = NULL;
2602 String* pUrl = null;
2603 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2604 pSelectedScene = (String*) pValue;
2606 // removed because some times crash is happening here
2607 /*if (pSelectedScene != null)
2609 delete pSelectedScene;
2611 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2612 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2613 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2614 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2616 // setting the current scene ID
2617 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2619 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2621 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2623 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2624 if(__pWindowInfo == null)
2626 // if(__pWindowInfo == null)
2628 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2631 else if ( pArgs != null && pArgs->GetCount() == 1)
2633 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2636 if (selectedSceneID)
2638 delete selectedSceneID;
2639 selectedSceneID = null;
2645 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2647 // hiding the address bar
2648 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2649 __pAddressbar->SetShowState(false);
2650 // if(__pWebViewer != null)
2652 // __pWebViewer->Resume();
2655 if(pUrl != null && pUrl->GetLength() > 0)
2659 else if(__pWindowInfo != null)
2661 if(__pWindowInfo->pageUrl.GetLength() > 0 &&previousSceneId != IDSCN_BRIGHTNESS && previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_MULTIPLE_WINDOW && previousSceneId != IDSCN_MULTIPLE_WINDOW_GRID && previousSceneId != IDSCN_BOOKMARK_VIEW && previousSceneId != IDSCN_SETTINGS && previousSceneId != IDSCN_MAIN_VIEW)
2663 LoadUrl(__pWindowInfo->pageUrl);
2665 else if (__pWindowInfo->isJavascriptInitiated == true)
2669 __pWindowInfo->pCurrentWeb = __pWebViewer;
2673 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2674 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2675 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2677 InitMostVisitedSitesView(GetOrientationStatus());
2679 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2681 if(__pMostVisitedListView != null)
2683 __pMostVisitedListView->SetShowState(false);
2687 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2689 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2691 if (pBookmarkUrl == null)
2693 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2694 //__pAddressbar->SetUrl(*pBookmarkUrl);
2695 SetUrl(*pBookmarkUrl);
2697 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2698 __pWebViewer->LoadUrl(*pBookmarkUrl);
2699 delete pBookmarkUrl;
2702 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2703 Bitmap* pBitmap = null;
2704 if (isPrivateBrowsing == true)
2706 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2708 if (__pWebViewer != null)
2710 __pWebViewer->SetPrivateBrowsingEnabled(true);
2713 if (__pAddressbar != null)
2715 // __pAddressbar->UpdateFaviconBitmap(true);
2721 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2723 if (__pWebViewer != null)
2725 __pWebViewer->SetPrivateBrowsingEnabled(false);
2728 if (__pAddressbar != null)
2730 // __pAddressbar->UpdateFaviconBitmap(false);
2734 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2736 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2738 else if (__pOptionMenu != null )
2740 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2743 if (pBitmap != null)
2748 AppLog("ABC: OnSceneActivatedN started exit");
2753 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2754 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2756 Canvas* pWebCanvas = null;
2757 if (__pWebViewer != null)
2759 pWebCanvas = __pWebViewer->GetCanvasN();
2762 if (pWebCanvas == null)
2766 if (__pWindowInfo != null)
2768 if (__pWindowInfo->pWebCanvasBitmap != null)
2770 delete __pWindowInfo->pWebCanvasBitmap;
2772 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2773 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2774 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2776 Bitmap* pBitmap = GetCapturedBitmapN();
2777 AppLog("Coming here");
2778 Canvas* pCanvas = new(std::nothrow) Canvas();
2779 pCanvas->Construct(GetClientAreaBounds());
2782 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2785 if(__pWebViewer != null && __pWindowInfo != null)
2786 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2788 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2789 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2792 AppLog("Coming here");
2796 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2797 const Tizen::Base::String& realm,
2798 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2804 MainForm::OnHttpAuthenticationCanceled(void)
2809 MainForm::OnLoadingStarted(void)
2811 AppLogDebug("MainForm::OnLoadingStarted entered");
2813 if(__pAddressbar == NULL || __pWebViewer == null)
2818 // this is added in case if menu is opened and user load the page
2819 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2821 __pOptionMenu->SetShowState(false);
2822 __pOptionMenu->Invalidate(true);
2827 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2829 __pImageMenu->SetShowState(false);
2830 __pImageMenu->Invalidate(true);
2832 String url = __pWebViewer->GetUrl();
2833 if(url.Contains(IDS_TIZEN_SERVICE))
2836 String delim(L":;,");
2838 // Creates a StringTokenizer instance
2839 StringTokenizer strTok(url, delim);
2841 int count = strTok.GetTokenCount(); // count == 4
2843 HashMap *pMap = new HashMap();
2848 while (strTok.HasMoreTokens())
2850 AppLog("Token: %ls", token.GetPointer());
2851 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2852 if(token.Contains(IDS_APPID))
2854 token.SubString(6, appId);
2855 AppLog("AppID:%ls", appId.GetPointer());
2857 else if(token.Contains(IDS_KEY))
2859 token.SubString(4, key);
2860 AppLog("key:%ls", key.GetPointer());
2862 else if(token.Contains(IDS_VALUE))
2864 token.SubString(6, value);
2865 AppLog("value:%ls", value.GetPointer());
2868 pMap->Add(key, value);
2872 AppControl *pAppControl = null;
2873 String operationId = L"http://tizen.org/appcontrol/operation/main";
2874 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2877 AppLog("Starting AppControl");
2878 result r = pAppControl->Start(null, null, pMap, null);
2879 AppLog("Result of Start %s", GetErrorMessage(r));
2883 AppLogException("AppControl not found");
2888 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2890 __pAddressbar->SetShowState(false);
2891 AddressBarCancelledClicked(*__pAddressbar);
2892 __pAddressbar->Invalidate(true);
2894 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2897 __pAddressbar->SetFaviconBitmap(*pBitmap);
2900 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2902 // updating the address bar position with respect to web control
2903 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2904 __distanceMoved = 0;
2908 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2909 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2910 if (__pWebViewer != null)
2912 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2913 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2914 SetUrl(__pWebViewer->GetUrl());
2915 if (__pWindowInfo != NULL)
2917 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2918 __pWindowInfo->pageTitle = L"";
2919 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2921 __pAddressbar->Invalidate(true);
2927 MainForm::OnLoadingCanceled(void)
2934 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2936 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2941 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2943 AppLog("XYZ::MainForm::OnKeypadOpened");
2944 __pFooterPanel->SetShowState(false);
2949 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2951 AppLog("XYZ::MainForm::OnKeypadClosed");
2952 __pFooterPanel->SetShowState(true);
2953 RelayoutControls(true);
2957 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2959 AppLog("XYZ::KeypadBoundsChanged");
2960 RelayoutControls(false);
2964 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2965 const Tizen::Base::String& reason)
2967 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2971 MainForm::OnLoadingCompleted(void)
2973 AppLog("MainForm::OnLoadingCompleted start");
2975 result r = E_SUCCESS;
2977 if (__pWebViewer == null)
2982 if (__pAddressbar == null)
2987 if(__pImageMenu && __pImageMenu->GetShowState())
2989 __pImageMenu->SetShowState(false);
2990 __pImageMenu->Invalidate(true);
2993 if (__pWebViewer->CanGoForward())
2995 //__pAddressbar->SetForwardButtonEnabled(true);
2996 SetForwardButtonEnabled(true);
3000 //__pAddressbar->SetForwardButtonEnabled(false);
3001 SetForwardButtonEnabled(false);
3004 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3006 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3008 //__pAddressbar->UpdateProgress(0);
3012 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3014 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3018 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3019 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3020 if (isPrivateBrowsing == false)
3022 if(__pHistory != null)
3028 __pHistory = new(std::nothrow) History;
3029 HistoryPresentationModel::GetCurrentDateTime(date);
3032 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3033 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3035 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3036 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3038 __pHistory->SetVisitedTime(date);
3040 if (__pWebViewer != null)
3042 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3044 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3045 if (pTempBitmap != null)
3047 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3048 __pHistory->SetFavIconBitmap(*pTempBitmap);
3051 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3054 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3055 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3056 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3058 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3059 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3060 __pHistory->SetThumbnail(pBitmap);
3062 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3065 __pHistory->SetFavIconBitmap(*pFavIcon);
3069 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3076 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3078 // temperary fixed (webpage can be not loaded)
3082 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3083 if (isReaderEnabled == true)
3087 delete __pReaderData;
3088 __pReaderData = null;
3090 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3091 filePath.Append(L"data/reader.js");
3097 result r = E_SUCCESS;
3098 FileAttributes attr;
3100 File::GetAttributes(filePath,attr);
3102 r = file.Construct(filePath, L"r+");
3105 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3108 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3111 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3114 // file.Read(pScript,attr.GetFileSize());
3116 // AppLogDebug("scipt length %d",strlen(pScript));
3117 String strScript = L"";
3118 // strScript.Append(pScript);
3119 // for(int i=0; i<25; i++)
3121 file.Read(pScript,attr.GetFileSize());
3122 // AppLog("xyzz tell %d",file.Tell());
3123 // r = strScript.Append(pScript);
3124 // AppLog("xyzz append result %s",GetErrorMessage(r));
3125 // AppLog("xyzz strScript length %d",strScript.GetLength());
3127 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3129 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3130 if (__pReaderData == null)
3132 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3133 __pReaderData = new String(L"<meta name=\"viewport\" content=\"width=0, initial-scale=1.0, maximum-scale=2.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=medium-dpi\"> <h1>Chinese PM Li Keqiang vows to open up markets to India</h1><div><span class=\"arttle\"><h1>Chinese PM Li Keqiang vows to open up markets to India</h1></span></div>");
3136 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3137 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3139 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3140 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3146 AppLog("MainForm::OnLoadingCompleted done");
3150 MainForm::OnEstimatedProgress(int progress)
3152 AppLogDebug("MainForm::OnEstimatedProgress entered");
3154 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3155 progress = DEFAULT_PROGRESS_PERCENTAGE;
3157 // __pAddressbar->UpdateProgress(progress);
3158 UpdateProgress(progress);
3161 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3163 AppLog("MainForm::OnFaviconReceived");
3164 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3166 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3169 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3176 MainForm::OnUrlValueChanged(Addressbar&)
3182 MainForm::OnUrlSubmitted(Addressbar& addBar)
3184 AppLog("MainForm::OnUrlSubmitted");
3185 String url = addBar.GetUrl();
3186 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3188 if(__pFooterUrlField)
3189 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3190 AddressBarCancelledClicked(*__pAddressbar);
3195 MainForm::LoadUrl(String& url)
3199 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3200 AppLogDebug("MainForm::LoadUrl enter");
3202 if (__pWebViewer != null)
3204 __pWebViewer->SetShowState(true);
3205 __pWebViewer->Invalidate(true);
3208 if (url.CompareTo(L"") == 0)
3212 if(__pFooterPanel != null)
3214 __pFooterPanel->SetShowState(true);
3215 __pFooterPanel->Invalidate(true);
3222 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3223 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)
3225 RegularExpression firstRegex;
3226 RegularExpression secondRegex;
3228 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3229 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3232 ret = firstRegex.Match(url, false); // This returns true value
3233 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3235 if (ret == true && __pWebViewer != null)
3238 __pWebViewer->LoadUrl(url);
3240 else if(__pWebViewer != null)
3242 String tempUrl = L"http://";
3243 tempUrl.Append(url);
3247 __pWebViewer->LoadUrl(tempUrl);
3251 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3252 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3255 if (__pAddressbar != null)
3257 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3258 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3261 AppLogDebug("MainForm::LoadUrl exit");
3268 MainForm::OnStopClicked(Addressbar& addBar)
3270 AppLogDebug("MainForm::OnStopClicked called");
3273 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3274 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3275 __pWebViewer->StopLoading();
3276 RequestRedraw(true);
3281 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3283 // AppLog("MainForm::OnBackClicked");
3284 result r = E_FAILURE;
3286 if (__pWebViewer && __pWebViewer->CanGoBack())
3288 __pWebViewer->GoBack();
3290 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3293 pApp = UiApp::GetInstance();
3296 r = pApp->Terminate();
3299 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3307 WindowInfo* pWindowInfo = null;
3309 SceneManager* pSceneManager = SceneManager::GetInstance();
3310 if (pSceneManager == null)
3314 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3315 if (pAllWindowList == NULL)
3317 pApp = UiApp::GetInstance();
3320 r = pApp->Terminate();
3323 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3328 if (pAllWindowList != null)
3330 totalCount = pAllWindowList->GetCount();
3332 for (int count = 0; count < totalCount; count++)
3334 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3335 if (pWindowInfo == null)
3337 pApp = UiApp::GetInstance();
3340 r = pApp->Terminate();
3343 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3348 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3350 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3353 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3356 r = pAllWindowList->RemoveAt(count, true);
3357 __pWindowInfo = null;
3360 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3365 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3367 else if(pAllWindowList->GetCount() > 0)
3369 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3373 pApp = UiApp::GetInstance();
3376 r = pApp->Terminate();
3381 if (pWindowInfo == null)
3383 pApp = UiApp::GetInstance();
3386 r = pApp->Terminate();
3392 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3395 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3409 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3411 AppLog("MainForm::OnForwardClicked");
3412 if (__pWebViewer == null)
3415 if (__pWebViewer->CanGoForward())
3417 __pWebViewer->GoForward();
3422 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3424 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3425 if(__pFooterPanel != null)
3427 __pFooterPanel->SetShowState(false);
3430 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3432 __pAddressbar->SetShowState(true);
3433 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3436 RelayoutControls(false);
3440 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3442 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3444 int Height = GetClientAreaBounds().height;
3445 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3448 __pAddressbar->SetShowState(false);
3450 if (__pFooterPanel != null && addressbarKeyPadState == false)
3452 AppLog("akjshdasd 3");
3453 __pFooterPanel->SetShowState(true);
3456 RelayoutControls(false);
3460 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3462 AddressBarCancelledClicked(addBar);
3466 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3468 __prevAddressBarMode = __curAddressBarMode;
3470 if (__pAddressbar != null)
3472 __curAddressBarMode = GetAddressbarMode();
3475 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3477 __adressPanelPosition.y = 0;
3478 if (__pAddressbar != null)
3480 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3481 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3482 __pAddressbar->Invalidate(true);
3484 if (__pWebViewer != null)
3486 __pWebViewer->StopLoading();
3489 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3491 __adressPanelPosition.y = 0;
3492 if (__pAddressbar != null)
3494 __webControlPosition.y = 0;
3495 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3496 __pAddressbar->Invalidate(true);
3502 MainForm::OnClipboardClosed(const Addressbar& addBar)
3504 AppLog("XYZ::MainForm::OnClipboardClosed");
3505 RelayoutControls(false);
3509 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3511 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3512 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3514 AppLog("akjshdasd 3");
3515 __pFooterPanel->SetShowState(true);
3518 RelayoutControls(false,footerState);
3522 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3524 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3525 RelayoutControls(false);
3529 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3531 __pFooterPanel->SetShowState(false);
3535 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3537 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3538 RelayoutControls(false);
3542 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3544 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3547 __pWindowInfo->pageTitle = title;
3548 if (__pWebViewer != null)
3550 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3553 if (__pAddressbar != null && __pWebViewer != null)
3555 SetUrl(__pWebViewer->GetUrl());
3556 __pAddressbar->Invalidate(true);
3561 MainForm::UpdateFavicon(void)
3563 bool urlImageType = false;
3564 String *tempPath = null;
3566 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();");
3567 Bitmap* pBitmap = null;
3569 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3571 if (__pWindowInfo != null)
3574 url.SetUri(*tempPath);
3575 if (url.GetHost().GetLength() == 0)
3578 webUrl.SetUri(__pWebViewer->GetUrl());
3579 result r = url.SetHost(webUrl.GetHost());
3586 if (url.GetScheme().GetLength() == 0)
3589 webUrl.SetUri(__pWebViewer->GetUrl());
3590 url.SetScheme(webUrl.GetScheme());
3592 __pWindowInfo->faviconUrl = url.ToString();
3594 pBitmap = __pWebViewer->GetFaviconN();
3596 if (pBitmap != null)
3598 if (__pWindowInfo->pFavicon != NULL)
3600 __pWindowInfo->pFavicon = null;
3602 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3603 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3605 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3607 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3609 else if(__pWindowInfo->pFavicon != null)
3611 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3615 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3616 if(pDefaultBmp != null)
3618 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3627 if(tempPath != null)
3631 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3637 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3638 Tizen::Web::Controls::WebNavigationType type)
3640 AppLog("urlk %ls",url.GetPointer());
3641 // when load new page if find word panel is open its show state is false
3642 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3644 __currentSearchStr = L"";
3645 __currentWordIndex = 0;
3646 __maxOccurrances = 0;
3647 __pFindWordEditField->SetText(L"");
3648 __pFindWordNext->SetEnabled(false);
3649 __pFindWordPrev->SetEnabled(false);
3650 __pFindWordCountLabel->SetText(L"0/0");
3651 __pFindWordControl->SetShowState(false);
3652 __pFindWordEditField->HideKeypad();
3653 RelayoutControls(false);
3656 __pFooterPanel->Invalidate(true);
3659 uriInfo.SetUri(url);
3661 if(url.Contains(IDS_TIZEN_SERVICE))
3664 String delim(L":;,");
3666 // Creates a StringTokenizer instance
3667 StringTokenizer strTok(url, delim);
3669 int count = strTok.GetTokenCount(); // count == 4
3671 HashMap *pMap = new HashMap();
3677 while (strTok.HasMoreTokens())
3679 AppLog("Token: %ls", token.GetPointer());
3680 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3681 if(token.Contains(IDS_APPID))
3683 token.SubString(6, appId);
3684 AppLog("AppID:%ls", appId.GetPointer());
3686 else if(token.Contains(IDS_KEY))
3688 token.SubString(4, key);
3689 AppLog("key:%ls", key.GetPointer());
3691 else if(token.Contains(IDS_VALUE))
3693 token.SubString(6, value);
3694 AppLog("value:%ls", value.GetPointer());
3697 pMap->Add(key, value);
3701 AppControl *pAppControl = null;
3702 String operationId = L"http://tizen.org/appcontrol/operation/main";
3703 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3706 result r = pAppControl->Start(null, null, pMap, null);
3710 AppLogException("AppControl not found");
3720 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3721 const Tizen::Net::Http::HttpHeader& httpHeader)
3723 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3727 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
3729 AppLog("MainForm::OnWebPageBlockSelected");
3730 if (__pHitElementResult != null)
3732 delete __pHitElementResult;
3733 __pHitElementResult = null;
3736 if (__pWebViewer != null)
3738 AppLog("MainForm::OnWebPageBlockSelected web not null");
3739 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3741 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3743 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3744 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3745 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3747 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3749 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3753 if (__pHitElementResult == null)
3758 if (__pHitElementResult->HasImage() != true)
3760 String tagName = __pHitElementResult->GetTagName();
3761 String type = __pHitElementResult->GetAttributeValue("type");
3764 AppLog("TagName %ls",tagName.GetPointer());
3765 __currentSelectedStr.Clear();
3766 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3767 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3768 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3770 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
3772 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3774 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true);
3775 __pImageMenu->SetShowState(true);
3776 __pImageMenu->Show();
3777 __pImageMenu->Invalidate(true);
3779 else /*if(__isLongPressedDone == true)*/
3781 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3783 if(__pHitElementResult->GetUrl().GetLength() > 0)
3785 __currentSelectedStr.Clear();
3786 __currentSelectedStr = __pHitElementResult->GetUrl();
3788 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false);
3789 __pImageMenu->SetShowState(true);
3790 __pImageMenu->Show();
3791 __pImageMenu->Invalidate(true);
3794 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3795 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3796 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3802 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3808 MainForm::OnWebWindowCreateRequested(void)
3810 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
3812 if (pNewWindowInfo == null)
3816 result r = E_SUCCESS;
3817 SceneManager* pSceneManager = SceneManager::GetInstance();
3818 if (pSceneManager == NULL)
3822 ArrayList* pArgList = new(std::nothrow) ArrayList();
3823 if (pArgList == NULL)
3827 r = pArgList->Construct();
3830 pNewWindowInfo->isJavascriptInitiated = true;
3831 pArgList->Add(*pNewWindowInfo);
3832 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3836 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3843 return pNewWindowInfo->pCurrentWeb;
3847 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3849 AppLog("xyz:: MainForm::RelayoutControls called");
3850 __webControlPosition.y = 0;
3851 __webControlHeight = GetClientAreaBounds().height;
3852 AppLog("Client area height: %d", __webControlHeight);
3854 AppLog("Client area height: %d", __webControlHeight);
3855 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3857 __webControlPosition.y += __pAddressbar->GetHeight();
3858 __webControlHeight -= __pAddressbar->GetHeight();
3859 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3861 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3863 __webControlPosition.y += __pFindWordControl->GetHeight();
3864 __webControlHeight -= __pFindWordControl->GetHeight();
3865 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3868 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3870 __webControlHeight -= __pFooterPanel->GetHeight();
3872 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3874 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3876 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
3881 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
3882 __pWebViewer->Invalidate(false);
3885 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3887 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3894 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3896 if (__pFindWordControl == null)
3901 Tizen::Locales::LocaleManager localeManager;
3902 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
3904 String languageCode;
3905 result r = SettingInfo::GetValue(L"Language", languageCode);
3906 // int languagecode = local.GetLanguageCode();
3907 AppLog("rahul language is %S", languageCode.GetPointer());
3911 InitFindWordPanel();
3913 if (languageCode.CompareTo("ara") == 0)
3915 AppLog("rahul language is arabic");
3917 __pFindWordPanelLeftToRight->SetShowState(false);
3918 __pFindWordPanelRightToLeft->SetShowState(true);
3920 __pFindWordClear->SetShowState(false);
3921 __pFindWordCountLabel->SetShowState(false);
3922 __pFindWordEditField->SetShowState(false);
3924 __pFindWordClearRightToLeft->SetShowState(true);
3925 __pFindWordCountLabelRightToLeft->SetShowState(true);
3926 __pFindWordEditFieldRightToLeft->SetShowState(true);
3930 AppLog("rahul language is not arabic");
3933 __pFindWordPanelLeftToRight->SetShowState(true);
3934 __pFindWordPanelRightToLeft->SetShowState(false);
3936 __pFindWordClear->SetShowState(true);
3937 __pFindWordCountLabel->SetShowState(true);
3938 __pFindWordEditField->SetShowState(true);
3940 __pFindWordClearRightToLeft->SetShowState(false);
3941 __pFindWordCountLabelRightToLeft->SetShowState(false);
3942 __pFindWordEditFieldRightToLeft->SetShowState(false);
3944 __pFindWordControl->SetShowState(true);
3948 if(__pFindWordControl != null)
3950 __pFindWordControl->SetShowState(false);
3954 AppLog("MainForm::ShowFindWordPanel %d",show);
3955 if (show && !isTouchPressed)
3957 if (languageCode.CompareTo("ara") == 0)
3959 if (__pFindWordEditFieldRightToLeft)
3961 __pFindWordEditFieldRightToLeft->SetFocus();
3962 __pFindWordEditFieldRightToLeft->ShowKeypad();
3967 if (__pFindWordEditField)
3969 __pFindWordEditField->SetFocus();
3970 __pFindWordEditField->ShowKeypad();
3976 if (languageCode.CompareTo("ara") == 0)
3978 if (__pFindWordEditFieldRightToLeft)
3979 __pFindWordEditFieldRightToLeft->HideKeypad();
3983 if (__pFindWordEditField)
3984 __pFindWordEditField->HideKeypad();
3988 RelayoutControls(false);
3992 MainForm::StartWordSearch()
3994 //Get the count of occurances of the word in the current page
3995 __maxOccurrances = 0;
3996 __currentWordIndex = 0;
3998 __pFindWordPrev->SetEnabled(false);
3999 String *pCountStr = null;
4000 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4001 AppLog("Search Result %s",GetErrorMessage(r));
4002 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4003 if (pCountStr != null)
4005 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4009 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4014 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4016 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4017 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4019 if(totalCount == -1 || totalCount == 0)
4021 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4022 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4025 else if(totalCount > 100)
4027 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4028 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4032 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4033 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4036 __maxOccurrances = totalCount;
4037 __currentWordIndex = currentOrdinal;
4039 //Reset the UI controls as per the maxOccurrance value
4040 if (totalCount <= 0)
4042 AppLog("Word not found");
4043 //Show error notification to user
4044 __pFindWordNext->SetEnabled(false);
4045 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4047 __pFindWordCountLabel->SetText(L"0/0");
4048 __pFindWordCountLabel->Invalidate(false);
4050 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4052 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4053 __pFindWordCountLabelRightToLeft->Invalidate(false);
4055 __pFindWordNext->Invalidate(false);
4056 __pFindWordPrev->Invalidate(false);
4061 if (totalCount == 1)
4063 __pFindWordNext->SetEnabled(false);
4067 __pFindWordNext->SetEnabled(true);
4070 String countStr = L"";
4071 countStr.Append(__currentWordIndex);
4072 countStr.Append(L"/");
4073 countStr.Append(__maxOccurrances);
4074 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4076 __pFindWordCountLabel->SetText(countStr);
4077 __pFindWordCountLabel->Invalidate(false);
4078 __pFindWordCountLabel->Invalidate(false);
4080 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4082 __pFindWordCountLabelRightToLeft->SetText(countStr);
4083 __pFindWordCountLabelRightToLeft->Invalidate(false);
4084 __pFindWordCountLabelRightToLeft->Invalidate(false);
4086 //FindNextWord(true);
4087 //Update the controls
4088 __pFindWordNext->Invalidate(false);
4089 __pFindWordPrev->Invalidate(false);
4094 MainForm::FindNextWord(bool next)
4098 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4099 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4101 if (__currentWordIndex < __maxOccurrances)
4103 __currentWordIndex++;
4109 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4110 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4112 if(__currentWordIndex > 1)
4114 __currentWordIndex--;
4119 String countStr = L"";
4120 countStr.Append(__currentWordIndex);
4121 countStr.Append(L"/");
4122 countStr.Append(__maxOccurrances);
4124 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4126 __pFindWordCountLabel->SetText(countStr);
4127 __pFindWordCountLabel->Invalidate(false);
4129 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4131 __pFindWordCountLabelRightToLeft->SetText(countStr);
4132 __pFindWordCountLabelRightToLeft->Invalidate(false);
4135 if (__currentWordIndex >= __maxOccurrances)
4137 __pFindWordNext->SetEnabled(false);
4141 __pFindWordNext->SetEnabled(true);
4143 if (__currentWordIndex <= 1)
4145 __pFindWordPrev->SetEnabled(false);
4149 __pFindWordPrev->SetEnabled(true);
4151 __pFindWordPrev->Invalidate(false);
4152 __pFindWordNext->Invalidate(false);
4154 __pFindWordControl->Invalidate(true);
4158 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4160 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4161 __isWebKeypadOpened = true;
4162 __pFooterPanel->SetShowState(false);
4163 // OnAddressBarKeypadOpened(*__pAddressbar);
4167 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4169 AppLog("xyz::MainForm::OnWebKeypadOpened");
4171 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4173 __currentSearchStr = L"";
4174 __currentWordIndex = 0;
4175 __maxOccurrances = 0;
4176 __pFindWordEditField->SetText(L"");
4177 __pFindWordNext->SetEnabled(false);
4178 __pFindWordPrev->SetEnabled(false);
4179 __pFindWordCountLabel->SetText(L"0/0");
4180 __pWebViewer->SearchTextAllAsync(L"",false);
4181 __pFindWordControl->SetShowState(false);
4182 __pFindWordEditField->HideKeypad();
4186 if (__pWebViewer != null && __pFooterPanel != null)
4188 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4189 if(__pAddressbar != null)
4191 __pAddressbar->SetShowState(false);
4193 if(__pFindWordControl != null)
4195 __pFindWordControl->SetShowState(false);
4197 __pFooterPanel->SetShowState(false);
4198 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4200 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4202 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4203 // AppLog("omgomgomg");
4209 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4211 AppLog("xyz::MainForm::OnWebKeypadClosed");
4212 AppLog("akjshdasd 4");
4213 __pFooterPanel->SetShowState(true);
4214 // OnAddressBarKeypadClosed(*__pAddressbar);
4215 RelayoutControls(false);
4216 __isWebKeypadOpened = false;
4220 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4222 // RelativeLayout(false);
4223 if(__pWebViewer != null)
4225 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4230 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4232 Control* temp = const_cast< Control* >(&source);
4233 Header* pHeader = dynamic_cast< Header* >(temp);
4234 if (pHeader != null)
4236 //Header double - clicked
4237 AppLog("Header double clicked");
4239 if(__pFindWordControl)
4241 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4242 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4246 AppLog("MainScene::OnTouchDoublePressed");
4250 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4252 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4253 if(TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4255 AppLog("Returning because of more than one touch point.");
4258 __longPressPoint = currentPosition;
4260 if (__pHitElementResult != null)
4262 delete __pHitElementResult;
4263 __pHitElementResult = null;
4266 if (__pWebViewer != null)
4268 AppLog("MainForm::OnTouchLongPressed web not null");
4269 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4272 if (__pHitElementResult == null)
4277 if (__pHitElementResult->HasImage() == true)
4279 if(__pWebViewer != null)
4280 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4281 __pImageMenu->SetShowState(true);
4282 __pImageMenu->Show();
4283 __pImageMenu->Invalidate(true);
4285 else if(__pHitElementResult->HasUrl() == true)
4287 String tempURl = __pHitElementResult->GetUrl();
4288 AppLog("tempURl is %ls", tempURl.GetPointer());
4289 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4290 if (pBitmap != null)
4298 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4299 __pImageMenu->SetShowState(true);
4300 __pImageMenu->Show();
4301 __pImageMenu->Invalidate(true);
4305 String tagName = __pHitElementResult->GetTagName();
4306 String type = __pHitElementResult->GetAttributeValue("type");
4307 String value = __pHitElementResult->GetAttributeValue(L"value");
4308 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4310 __currentSelectedStr.Clear();
4311 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4313 AppLog("tag name is %ls", tagName.GetPointer());
4314 AppLog("type is %ls", type.GetPointer());
4318 //__isLongPressedDone = true;
4319 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4320 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 /*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4322 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4324 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4327 __pImageMenu->SetShowState(true);
4328 __pImageMenu->Show();
4329 __pImageMenu->Invalidate(true);
4332 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4335 // __inputEventToBeSupressed = true;
4339 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4341 AppLog("xyz:: MainForm::OnTouchReleased called");
4343 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4345 __pAddressbar->SetShowState(false);
4349 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4350 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4352 __pWebViewer->ConsumeInputEvent();
4354 if(pHitElement != null)
4358 __inputEventToBeSupressed = false;*/
4362 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4369 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4371 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4373 __currentSearchStr = L"";
4374 __currentWordIndex = 0;
4375 __maxOccurrances = 0;
4377 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4379 __pFindWordEditField->SetText(L"");
4380 __pFindWordEditField->HideKeypad();
4381 __pFindWordControl->SetShowState(false);
4382 __pFindWordCountLabel->SetText(L"0/0");
4384 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4386 __pFindWordEditFieldRightToLeft->SetText(L"");
4387 __pFindWordEditFieldRightToLeft->HideKeypad();
4388 __pFindWordControl->SetShowState(false);
4389 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4392 __pFindWordNext->SetEnabled(false);
4393 __pFindWordPrev->SetEnabled(false);
4395 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4396 __pFindWordControl->SetShowState(false);
4398 if(__pAddressbar->GetShowState() == false)
4400 __pAddressbar->SetAddressbarURLFocus();
4401 __pFooterPanel->SetShowState(false);
4408 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4414 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4420 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4426 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4432 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4438 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4440 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4441 int widthContextItem = 0;
4442 if(__pFindWordCountLabel)
4443 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4444 // As per the platform engineer comment removed this line
4445 /*if(__pWebViewer != null)
4447 // 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
4448 __pWebViewer->ReleaseBlock();
4451 // if(__pFindWordControl != null)
4452 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4453 if(__pNotification && __pNotification->GetShowState() == true)
4455 __pNotification->SetShowState(false);
4456 __pNotification->Invalidate(false);
4458 if ( __pFooterLabel != null)
4460 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4463 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4469 if (__pFindWordBgLabel != null)
4471 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4472 if (pBitmap != null)
4474 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4479 if (__pFindWordBgLabelRightToLeft != null)
4481 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4482 if (pBitmap != null)
4484 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4490 if(__pOptionMenu != null)
4491 __pOptionMenu->SetShowState(false);
4493 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4495 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4499 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4504 AppLog("__pFooterPanel->GetShowState() is true");
4506 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4507 __pFooterPanel->Invalidate(true);
4511 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4512 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4514 InitMostVisitedSitesView(orientationStatus);
4517 RelayoutControls(false);
4518 if (__pArticleReaderPanel != null)
4520 if (__pArticleReaderPanel->GetShowState() == true)
4522 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4524 if (__pBlankPanel != null)
4525 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4527 if (__pWebReader != null)
4529 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4531 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4532 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4534 if ( pBitmap != null && pSrcBitmap != null)
4536 AppLog("CreateReaderPanel ninepatchbitmap found");
4537 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4540 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4541 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4542 if (pBitmap != null)
4547 if (pSrcBitmap != null)
4556 if (__pAddressbar != null)
4558 int width = GetClientAreaBounds().width;
4559 __pAddressbar->OrientationChanged(width);
4564 MainForm::OnSettingsChange(int settingvalue)
4566 AppLogDebug("MainForm::OnSettingsChange entered");
4568 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4570 __pAddressbar->ResetGuideText();
4572 if (__pWebViewer == null)
4574 AppLogDebug("Webviewer is not initialized yet.");
4578 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4580 WebSetting settings = __pWebViewer->GetSetting();
4581 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4583 settings.SetAutoFittingEnabled(true);
4585 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4587 settings.SetAutoFittingEnabled(false);
4589 __pWebViewer->SetSetting(settings);
4591 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4593 WebSetting settings = __pWebViewer->GetSetting();
4594 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4595 __pWebViewer->SetSetting(settings);
4597 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4599 WebSetting settings = __pWebViewer->GetSetting();
4600 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4601 __pWebViewer->SetSetting(settings);
4602 __pWebViewer->Reload();
4604 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4606 WebSetting settings = __pWebViewer->GetSetting();
4607 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4608 __pWebViewer->SetSetting(settings);
4610 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4614 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4617 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4621 WebSetting settings = __pWebViewer->GetSetting();
4622 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4623 __pWebViewer->SetSetting(settings);
4626 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4630 WebSetting settings = __pWebViewer->GetSetting();
4631 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4632 __pWebViewer->SetSetting(settings);
4635 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4637 WebSetting settings = __pWebViewer->GetSetting();
4638 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4640 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4644 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4646 __pWebViewer->SetSetting(settings);
4648 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4652 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4653 WebSetting settings = __pWebReader->GetSetting();
4654 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4655 __pWebReader->SetSetting(settings);
4661 MainForm::OnSettingsReset()
4665 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4666 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4671 MainForm::OnClearCache()
4673 result r = E_SUCCESS;
4675 if (__pWebViewer != NULL)
4677 r = __pWebViewer->ClearCache();
4680 AppLogDebug("Cache cleared success");
4684 AppLogDebug("Cache cleared fail");
4690 MainForm::OnClearCookie()
4692 result r = E_SUCCESS;
4694 if (__pWebViewer != NULL)
4696 __pWebViewer->ClearCookie();
4700 AppLogDebug("Cookie cleared success");
4704 AppLogDebug("Cache cleared fail");
4709 MainForm::OnClearFormData()
4711 result r = E_SUCCESS;
4713 if (__pWebViewer != NULL)
4715 __pWebViewer->ClearFormData();
4719 AppLogDebug("Cookie cleared success");
4723 AppLogDebug("Cache cleared fail");
4728 MainForm::OnClearPasswords()
4730 result r = E_SUCCESS;
4732 if (__pWebViewer != NULL)
4734 __pWebViewer->ClearLoginFormData();
4738 AppLogDebug("Cookie cleared success");
4742 AppLogDebug("Cache cleared fail");
4748 MainForm::findDistance(int x1,int y1,int x2, int y2)
4750 int deltaX = Math::Abs(x2 - x1);
4751 int deltaY = Math::Abs(y2 - y1);
4752 double num = deltaX*deltaX + deltaY*deltaY;
4758 for (i = 0; i < 20; i++)
4760 x = (((x*x)+ num)/(2*x));
4771 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4773 AppLog("xyz:: MainForm::OnTouchPressed called");
4774 if(__pFindWordControl)
4776 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4777 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4779 //__isLongPressedDone = false;
4784 IList* pList = null;
4785 pList = touch.GetTouchInfoListN(source);
4789 int count = pList->GetCount();
4792 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4793 __touchPoint1 = pTouchInfo->position;
4795 /*if (__pAddressbar != null)
4797 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4799 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4801 __pAddressbar->SaveAddressbarEditText();
4803 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4806 __pAddressbar->Invalidate(true);
4808 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4810 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4812 //__pAddressbar->SaveAddressbarEditText();
4814 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4817 else if (count == 2)
4819 AppLogDebug("MainForm::OnTouchPressed count is two");
4820 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4821 __touchPoint1 = pTouchInfo->position;
4823 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4824 __touchPoint2 = pTouchInfo->position;
4829 pList->RemoveAll(true);
4833 __pAddressbar->SetShowState(false);
4834 RelayoutControls(false);
4839 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4841 // __currentWordIndex = 0;
4842 //__isLongPressedDone = false;
4847 MainForm::MoveUiControls()
4852 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4854 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4856 if(__pFooterUrlField->GetTextLength() == 0)
4858 __pFooterUrlField->SetKeypadActionEnabled(false);
4862 __pFooterUrlField->SetKeypadActionEnabled(true);
4865 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
4867 __currentSearchStr = __pFindWordEditField->GetText();
4868 if (__currentSearchStr.GetLength() > 0)
4870 __pFindWordCountLabel->SetShowState(true);
4874 __pFindWordCountLabel->SetShowState(false);
4876 __pFindWordNext->SetEnabled(false);
4877 __pFindWordPrev->SetEnabled(false);
4878 __pFindWordNext->Invalidate(true);
4879 __pFindWordPrev->Invalidate(true);
4880 __pFindWordCountLabel->SetText(L"0/0");
4881 __pFindWordCountLabel->Invalidate(true);
4883 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
4885 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
4886 if (__currentSearchStr.GetLength() > 0)
4888 __pFindWordCountLabelRightToLeft->SetShowState(true);
4892 __pFindWordCountLabelRightToLeft->SetShowState(false);
4895 __pFindWordNext->SetEnabled(false);
4896 __pFindWordPrev->SetEnabled(false);
4897 __pFindWordNext->Invalidate(true);
4898 __pFindWordPrev->Invalidate(true);
4899 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4900 __pFindWordCountLabelRightToLeft->Invalidate(true);
4902 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4903 if (__currentSearchStr.GetLength() > 0)
4909 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4911 __currentSearchStr = L"";
4912 AppLogDebug("Enter something");
4917 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4924 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4926 if(__pWebViewer != null)
4929 AppLog("MainForm::InitMostVisitedSitesView");
4930 result r = E_SUCCESS;
4933 if (__pWebViewer != null && __pMostVisitedListView != null)
4938 if (__pMostVisitedListView != null)
4940 RemoveControl(__pMostVisitedListView);
4942 if(__pMostVisitedSites != null)
4944 __pMostVisitedSites->RemoveAll(true);
4947 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4949 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4950 __pMostVisitedListView = new(std::nothrow) ListView();
4952 int height = GetClientAreaBounds().height;
4954 if(__pFooterPanel->GetShowState() == true)
4956 height = height - __pFooterPanel->GetHeight();
4958 if(__pAddressbar->GetShowState() == true)
4960 height -= __pAddressbar->GetHeight();
4963 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4967 delete __pMostVisitedListView;
4968 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4971 __pMostVisitedListView->SetItemProvider(*this);
4972 __pMostVisitedListView->AddListViewItemEventListener(*this);
4973 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4974 AddControl(__pMostVisitedListView);
4975 __pMostVisitedListView->UpdateList();
4982 MainForm::GetImagePath(void)
4986 String formattedTime;
4987 DateTime currentTime;
4988 LocaleManager localManager;
4989 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4991 localManager.Construct();
4992 Locale locale = localManager.GetSystemLocale();
4993 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4995 // Get date formatter
4996 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5000 pTimeFormatter->Format(currentTime, formattedTime);
5003 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5004 String delim(L" :");
5005 StringTokenizer strTok(formattedTime, delim);
5008 String str1("GMT+00");
5009 while (strTok.HasMoreTokens())
5011 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5012 if(token.Equals(str1))
5014 AppLog("token is %ls", token.GetPointer());
5015 imageName.Append(token);
5021 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5023 result r = E_FAILURE;
5024 AppLog("Content manager 1");
5025 ContentId contentId;
5026 ContentManager contentManager;
5027 r = contentManager.Construct();
5030 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5033 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5034 Tizen::Io::Directory::Create(contentPath,true);
5035 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5037 AppLog("Already exists");
5039 else if(GetLastResult() == E_SUCCESS)
5041 AppLog("created success");
5043 contentPath.Append(imageName);
5044 contentPath.Append(".jpg");
5045 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5046 ShowIndicatorNotification(L"Download Complete");
5047 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5051 MainForm::ShowIndicatorNotification(const String& messageText)
5053 AppLogDebug("ENTER");
5055 NotificationRequest request;
5056 request.SetAlertText(messageText);
5057 request.SetTitleText(L"");
5058 request.SetAppMessage(L"AppMessage");
5060 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5061 String homePath = pApp->GetAppRootPath();
5062 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5063 AppLog("The iconPath is : %ls", homePath.GetPointer());
5064 request.SetIconFilePath(iconPath);
5066 Tizen::Shell::NotificationManager notiMgr;
5067 notiMgr.Construct();
5068 notiMgr.Notify(request);
5070 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5075 MainForm::SetForwardButtonEnabled(bool isEnabled)
5077 __pGoForwardBtn->SetEnabled(isEnabled);
5078 __pGoForwardBtn->Invalidate(true);
5082 MainForm::SetBackButtonEnabled(bool isEnabled)
5084 __pGoBackBtn->SetEnabled(isEnabled);
5085 __pGoBackBtn->Invalidate(true);
5089 MainForm::UpdateProgress(int percentage)
5091 __progressPercentage = percentage;
5092 if (percentage == 0 || percentage == 100)
5094 __isLoadingData = false;
5095 if (percentage == 100)
5097 __isLoadingCompleted = true;
5098 __progressPercentage = 0;
5102 __isLoadingCompleted = false;
5107 __isLoadingData = true;
5109 UpdateProgressBitmap();
5113 MainForm::GetProgress(void)
5115 return __progressPercentage;
5119 MainForm::UpdateProgressBitmap(void)
5121 result r = E_SUCCESS;
5122 if (__pProgressbarLabel == null)
5124 int w = __pProgressbarLabel->GetWidth();
5125 int h = __pProgressbarLabel->GetHeight();
5127 int progressWidth = 0;
5128 Bitmap* pRetBitmap = null;
5130 if (__progressPercentage == 0 || __progressPercentage == 100)
5132 __pProgressbarLabel->SetShowState(false);
5133 __pProgressbarLabel->Invalidate(false);
5138 __pProgressbarLabel->SetShowState(true);
5139 __pProgressbarLabel->Invalidate(false);
5142 r = canvas.Construct(Rectangle(0, 0, w, h));
5146 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5151 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5155 pBgBmp->Scale(Dimension(w, h));
5156 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5160 progressWidth = (double) (w) * __progressPercentage / 100;
5161 AppLogDebug("progressWidth: %d", progressWidth);
5162 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5164 if (pProgressBmp != null)
5166 pProgressBmp->Scale(Dimension(progressWidth, h));
5167 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5168 delete pProgressBmp;
5171 pRetBitmap = new (std::nothrow) Bitmap();
5173 if (pRetBitmap == null)
5175 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5179 pRetBitmap->Construct(canvas, canvas.GetBounds());
5181 if (__pProgressbarLabel != null && pRetBitmap != null)
5183 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5184 __pProgressbarLabel->Invalidate(false);
5187 if (pRetBitmap != null)
5196 MainForm::ReaderClicked()
5198 result r = E_SUCCESS;
5199 ArrayList* pArgList = new(std::nothrow) ArrayList();
5200 if (pArgList != null)
5202 r = pArgList->Construct();
5209 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5216 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5223 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5231 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5237 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5239 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5241 __currentAddMode = addMode;
5245 case ADDRESSBAR_MODE_INVALID:
5250 case ADDRESSBAR_MODE_READER:
5252 __pStopBtn->SetShowState(false);
5253 __pRefreshBtn->SetShowState(false);
5254 __pClearBtn->SetShowState(false);
5255 __pReaderBtn->SetShowState(false);
5258 case ADDRESSBAR_MODE_LOADING:
5260 __pRefreshBtn->SetShowState(false);
5261 __pStopBtn->SetShowState(true);
5262 __pClearBtn->SetShowState(false);
5263 __pReaderBtn->SetShowState(false);
5266 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5268 // SetUrl(__pAddressbar->GetUrl());
5270 __pRefreshBtn->SetShowState(true);
5271 __pStopBtn->SetShowState(false);
5272 __pClearBtn->SetShowState(false);
5273 __pReaderBtn->SetShowState(false);
5276 case ADDRESSBAR_MODE_EDIT:
5278 __pRefreshBtn->SetShowState(false);
5279 __pStopBtn->SetShowState(false);
5280 __pReaderBtn->SetShowState(false);
5281 __pClearBtn->SetShowState(true);
5288 OnAddressBarModeChanged();
5291 AddressBarMode MainForm::GetAddressbarMode(void)
5293 return __currentAddMode;
5296 void MainForm::SetUrl(const String& url)
5299 if(__displayUrl.GetLength() > 2048)
5300 __displayUrl.SubString(0,2048,__displayUrl);
5302 if (__pFooterUrlField != NULL)
5304 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5305 if (removedHttpUrl.IsEmpty() == false)
5307 __pFooterUrlField->SetText(removedHttpUrl);
5308 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5309 __pAddressbar->SetUrl(__displayUrl);
5313 __pFooterUrlField->SetText(__displayUrl);
5314 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5315 __pAddressbar->SetUrl(__displayUrl);
5317 if(__pFooterUrlField)
5318 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5319 __pFooterUrlField->Invalidate(false);
5320 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5321 __pAddressbar->Invalidate(true);
5322 // __pFooterUrlField->SetCursorPosition(0);
5327 MainForm::RemoveHttpTextFromDisplayURL(void)
5329 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5331 // bool isHttpText = __displayUrl.Contains(L"http://");
5332 String updatedDisplayUrl;
5333 updatedDisplayUrl.Clear();
5334 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5336 __displayUrl.SubString(7,updatedDisplayUrl);
5338 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5340 __displayUrl.SubString(8,updatedDisplayUrl);
5342 return updatedDisplayUrl;
5345 void MainForm::OnSharePopupControlStarted(void)
5347 __pWebViewer->AddTouchEventListener(*this);
5351 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5353 if (requestId == BACK_GROUND_APP_EVENT)
5355 if(__pWebViewer != null)
5357 __pWebViewer->Pause();
5359 if(__pAddressbar != null)
5361 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5364 else if(requestId == FORE_GROUND_APP_EVENT)
5366 if(__pWebViewer != null)
5368 __pWebViewer->Resume();
5370 if(__pAddressbar != null)
5372 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5378 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5380 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5381 result r = E_SUCCESS;
5384 __pAddressbar->SetShowState(false);
5386 //AppLog("akjshdasd 5");
5387 //__pFooterPanel->SetShowState(true);
5390 __pWebViewer->SetFocus();
5391 else if(__pMostVisitedListView)
5392 __pMostVisitedListView->SetFocus();
5393 else if(__pMultiWindowButton)
5394 __pMultiWindowButton->SetFocus();
5395 else if(__pMoreButton)
5396 __pMoreButton->SetFocus();
5398 __pAddressbar->SetShowState(false);
5400 RelayoutControls(false);
5404 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5406 AppLog("MainForm::OnFormMenuRequested called");
5408 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
5410 int bookmarkCount=0;
5413 url=__pWindowInfo->pageUrl;
5414 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5415 result r = E_SUCCESS;
5416 Bitmap* pBitmap = null;
5417 String lastChar = L"";
5418 if(url.SubString(url.GetLength()-1,lastChar));
5419 // if(lastChar == L"/")
5421 // bool exist1 = false;
5422 // bool exist2 = false;
5423 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5424 // url.SubString(0,url.GetLength() - 1,url);
5425 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5426 // exist = exist1 | exist2;
5430 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5433 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5439 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5443 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5445 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5447 if (__pOptionMenu->GetItemCount() == 9)
5449 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5453 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5458 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5462 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5463 if (__pOptionMenu->GetItemCount() != 9)
5465 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5466 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5467 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5468 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5469 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5470 __pOptionMenu->SetMaxVisibleItemsCount(6);
5472 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5474 AppLog(" Orientation landscape");
5475 __pOptionMenu->SetMaxVisibleItemsCount(5);
5479 AppLog(" Orientation potrait");
5480 __pOptionMenu->SetMaxVisibleItemsCount(6);
5483 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5486 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5487 __pOptionMenu->SetShowState(true);
5488 __pOptionMenu->Invalidate(true);
5489 __pOptionMenu->Show();