Fixed Nabi Issues 47903,47887,47972
[apps/osp/Internet.git] / src / IntMainForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 //!Internet MainForm class
18 /*@file:        MainForm.cpp
19  *@brief:       The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,
20  *                      loading,handling events etc.
21  */
22
23 #include <FApp.h>
24 #include <FGraphics.h>
25 #include <FMedia.h>
26 #include <FUi.h>
27 #include <FContent.h>
28 #include <FShell.h>
29 //#include <FShellNotificationManager.h>
30
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"
39
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;
57
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";
80
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;
103
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;
109
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;
114
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;
119
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;
126
127
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;
132
133 const int IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED = 224;
134
135 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
136
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;
142
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;
146
147 static const wchar_t* APPCONTROL_OPERATION_ID_IMAGE_VIEWER = L"http://tizen.org/appcontrol/operation/view";
148 MainForm::MainForm(void)
149 {
150         __isLongPressedDone = false;
151         __pHistory = null;
152         __pAddressbar = null;
153         //      __pMostVisitedSitesPanel = null;
154         __pMostVisitedListView = null;
155         __pFooterPanel = null;
156         __pHitElementResult = null;
157         __pWindowInfo = null;
158         __pWebViewer = null;
159         __pImageMenu = null;
160         __pOptionMenu = null;
161         __pFindWordControl = null;
162         __pFindWordPanelLeftToRight = null;
163         __pFindWordPanelRightToLeft = null;
164         __pFindWordBgLabel = null;
165         __pFindWordBgLabelRightToLeft = null;
166         __pFindWordEditField = null;
167         __pFindWordEditFieldRightToLeft = null;
168         __pFindWordClear = null;
169         __pFindWordClearRightToLeft = null;
170         __pFindWordCountLabel = null;
171         __pFindWordClearRightToLeft = null;
172         __pFindWordNext = null;
173         __pFindWordPrev = null;
174         __previousZoomLevel = 1.0;
175         __pSaveImage = null;
176         __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
177         __displayUrl = L"";
178         __editTextUrl = L"";
179         __currentSearchStr = L"";
180         __currentSelectedStr = L"";
181         __maxOccurrances = 0;
182         __currentWordIndex = 0;
183         __distanceMoved = 0;
184         __isLoaded = false;
185         //__inputEventToBeSupressed = false;
186         __isLoadingData = false;
187         __isLoadingCompleted = false;
188         __progressPercentage = 0;
189         __touchPoint1 = Point(-1,-1);
190         __touchPoint2 = Point(-1,-1);
191         __longPressPoint = Point(-1,-1);
192         __pWebReader = null;
193         //      __pReaderPopup = null;
194         __pReaderData = null;
195         __pPopUp = null;
196         __pReaderCloseBtn = null;
197         //__pNewWindowButton = null;
198         __pMoreButton = null;
199         __pMultiWindowButton = null;
200         __pArticleReaderPanel = null;
201         __pBlankPanel = null;
202         __pArticleReaderLabel = null;
203         __webControlHeight = 0;
204         __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
205         __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
206         __pMostVisitedSites = null;
207         __pFooterUrlField = null;
208         __pGoBackBtn = null;
209         __pGoForwardBtn = null;
210         __pRefreshBtn = null;
211         __pProgressbarLabel = null;
212         __pFooterLabel = null;
213         __pStopBtn = null;
214         __pClearBtn = null;
215         __pReaderBtn = null;
216         __isKeypadOpened = false;
217         __fontSize = 44;
218         __pNotification = null;
219 }
220
221 MainForm::~MainForm(void)
222 {
223         SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
224
225         if(__pAddressbar)
226         {
227                 __pAddressbar->SetAddressbarEventListener(null);
228         }
229
230         if(__pHistory != null)
231         {
232                 delete __pHistory;
233                 __pHistory = null;
234         }
235
236         if (__pReaderData != null)
237         {
238                 delete __pReaderData;
239                 __pReaderData = null;
240         }
241
242         if (__pPopUp != null)
243         {
244                 delete __pPopUp;
245                 __pPopUp = null;
246         }
247
248         if (__pHitElementResult != null)
249         {
250                 delete __pHitElementResult;
251                 __pHitElementResult = null;
252         }
253         if(__pOptionMenu)
254         {
255                 delete __pOptionMenu;
256                 __pOptionMenu = null;
257         }
258
259         String* pSelectedScene = NULL;
260         Object* pValue = NULL;
261         MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
262         pSelectedScene = (String*) pValue;
263
264         /*if (pSelectedScene != null)
265         {
266                 delete pSelectedScene;
267         }
268         MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
269 }
270
271 bool
272 MainForm::Initialize(void)
273 {
274         Construct(L"IDL_FORM");
275
276 //      SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER);
277         return true;
278 }
279
280 result
281 MainForm::OnInitializing(void)
282 {
283         AppLog("get client area width = %d",GetClientAreaBounds().width);
284         AppLog("get client area height = %d",GetClientAreaBounds().height);
285         const int WIDTH_CONTEXT_MENU_BUTTON = 336;
286         const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
287
288         __fontSize = CommonUtil::GetFontSize();
289         Panel* pFooterPanel = null;
290
291         __pSaveImage = new Image();
292         __pSaveImage->Construct();
293
294         // Setup back event listener
295         SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
296         SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
297         AddOrientationEventListener(*this);
298
299         AppLogDebug(" MainForm::OnInitializing ended");
300         if (__pMostVisitedSites == null)
301         {
302                 __pMostVisitedSites = new(std::nothrow) ArrayList();
303                 __pMostVisitedSites->Construct();
304         }
305         HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
306
307         __pItemContext= new(std::nothrow) ListContextItem();
308         __pItemContext->Construct();
309
310         __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),true);
311
312
313         __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
314         __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
315         __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
316
317         __pItemContextLandscape= new(std::nothrow) ListContextItem();
318         __pItemContextLandscape->Construct();
319
320         __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
321         __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
322         __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
323         __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
324         SetFormMenuEventListener(this);
325         AppLog("SetFormMenuEventListener result %s",GetErrorMessage(GetLastResult()));
326         return E_SUCCESS;
327 }
328
329 result
330 MainForm::InitAddressbar(void)
331 {
332         AppLogDebug("MainForm::InitAddressbar entered");
333
334         result r = E_SUCCESS;
335
336         if (__pAddressbar != null)
337         {
338                 return E_SUCCESS;
339         }
340         __pAddressbar = new(std::nothrow) Addressbar();
341         AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
342         r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
343         if (r != E_SUCCESS)
344         {
345                 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
346                 return r;
347         }
348         __pAddressbar->SetAddressbarEventListener(this);
349         AddControl(__pAddressbar);
350         __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
351         SetControlAlwaysOnTop(*__pAddressbar, true);
352         __adressPanelPosition = __pAddressbar->GetPosition();
353
354         AppLogDebug("MainForm::InitAddressbar exit");
355
356         return E_SUCCESS;
357 }
358
359 result
360 MainForm::CreateReaderPanel(void)
361 {
362         AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
363         result r = E_FAILURE;
364         WebSetting settings;
365         Button *pSmallFontBtn = null;
366         Button *pLargeFontBtn = null;
367
368         __pBlankPanel = new (std::nothrow) Panel();
369         __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
370
371         __pArticleReaderPanel = new (std::nothrow) Panel();
372         __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
373
374         __pReaderCloseBtn =  static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
375         if (__pReaderCloseBtn)
376         {
377                 AppLogDebug("CreateReaderPanel() 6");
378                 __pReaderCloseBtn->AddActionEventListener(*this);
379                 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
380         }
381
382         __pWebReader = new (std::nothrow) Web();
383         __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
384
385         settings.SetInputStyle(INPUT_STYLE_OVERLAY);
386         settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
387
388         r = __pWebReader->SetSetting(settings);
389         if (IsFailed(r))
390                 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
391
392
393         __pArticleReaderLabel = new Label();
394         __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
395
396         __pBlankPanel->AddControl(__pArticleReaderLabel);
397         __pBlankPanel->AddControl(__pArticleReaderPanel);
398         AddControl(__pBlankPanel);
399
400         __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
401         __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
402         __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
403
404         __pArticleReaderPanel->AddControl(__pWebReader);
405         __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
406         Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
407         Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
408
409         if (pBitmap != null && pSrcBitmap != null)
410         {
411                 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
412         }
413         __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
414
415         pSmallFontBtn =  static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
416         if (pSmallFontBtn)
417         {
418                 pSmallFontBtn->AddActionEventListener(*this);
419                 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
420         }
421
422         pLargeFontBtn =  static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
423         if (pLargeFontBtn)
424         {
425                 pLargeFontBtn->AddActionEventListener(*this);
426                 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
427         }
428
429
430         if (pBitmap != null)
431         {
432                 delete pBitmap;
433                 pBitmap = null;
434         }
435         if (pSrcBitmap != null)
436         {
437                 delete pSrcBitmap;
438                 pSrcBitmap = null;
439         }
440
441         SetControlAlwaysOnTop(*__pBlankPanel, true);
442         //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
443         Invalidate(true);
444
445         return E_SUCCESS;
446 }
447
448 result
449 MainForm::InitWebControl()
450 {
451         AppLogDebug("MainForm::InitWebControl enter");
452         result r = E_SUCCESS;
453         AppLogDebug("InitWebControl");
454
455         if (__pAddressbar == null || __pFooterPanel == null)
456                 return E_FAILURE;
457
458         const int Y_WEBCONTROL_POSITION = 0;
459
460         __webControlHeight = GetHeight() - __pFooterPanel->GetHeight();
461
462         if (__pMostVisitedListView)
463         {
464                 __pMostVisitedListView->SetShowState(false);
465         }
466         if (__pWebViewer != null)
467         {
468                 AppLogDebug("Already initialized");
469                 return E_SUCCESS;
470         }
471         __pWebViewer = new(std::nothrow) Web();
472         if(__pWebViewer == NULL)
473         {
474                 AppLogDebug("Initialization failed");
475                 return E_FAILURE;
476         }
477         r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
478
479         if (IsFailed(r))
480         {
481                 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
482                 delete __pWebViewer;
483                 __pWebViewer = null;
484                 return r;
485         }
486         else
487         {
488                 r = AddControl(__pWebViewer);
489
490                 if (IsFailed(r))
491                 {
492                         delete __pWebViewer;
493                         __pWebViewer = null;
494                         AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
495                         return r;
496                 }
497                 __webControlPosition = __pWebViewer->GetPosition();
498                 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
499                 if (IsFailed(r))
500                 {
501                         AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
502                         return r;
503                 }
504
505                 __pWebViewer->SetLoadingListener(this);
506                 __pWebViewer->SetWebUiEventListenerF(this);
507                 __pWebViewer->SetWebKeypadEventListener(this);
508                 __pWebViewer->SetFocus();
509                 __pWebViewer->AddTouchEventListener(*this);
510
511                 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
512                 __pWebViewer->SetTextSearchListener(this);
513         }
514
515         AppLogDebug("MainForm :before return");
516         Invalidate(true);
517         AppLogDebug("MainForm::InitWebControl Exit");
518
519         return r;
520 }
521
522 void
523 MainForm::SetJavascriptEnabled()
524 {
525         WebSetting settings = __pWebViewer->GetSetting();
526         settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
527         __pWebViewer->SetSetting(settings);
528 }
529
530 void
531 MainForm::SetImageLoadEnabled()
532 {
533         WebSetting settings = __pWebViewer->GetSetting();
534         settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
535         __pWebViewer->SetSetting(settings);
536 }
537
538 result
539 MainForm::InitFooter(void)
540 {
541         AppLogDebug("MainForm::InitFooter entered");
542         Button* pBackButton = null;
543         Button* pBookmarkButton = null;
544         Button* pMultiWindowButton = null;
545         Bitmap *pIconBitmap = null;
546         Bitmap *pBGBitmap = null;
547         Label *pBGLabel = null;
548
549         if (__pFooterPanel == null)
550         {
551                 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
552         }
553
554         if (__pFooterPanel == null)
555         {
556                 return E_FAILURE;
557         }
558
559         SetControlAlwaysOnTop(*__pFooterPanel, true);
560
561         __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
562         if ( __pFooterLabel == NULL )
563         {
564                 return E_FAILURE;
565         }
566         //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
567         Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
568         if (pBitmap != null)
569         {
570                 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
571                 delete pBitmap;
572         }
573
574         __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
575
576         if ( __pMultiWindowButton == NULL )
577         {
578                 return E_FAILURE;
579         }
580
581
582         SetFormBackEventListener(this);
583         AppLog("SetFormBackEventListener result  %s",GetErrorMessage(GetLastResult()));
584         if (__pMultiWindowButton != null)
585         {
586                 Bitmap* pBitmap = null;
587                 Bitmap* pPressedBitmap = null;
588                 String imagePath = "I01_toolbar_icon_windows_manager_0";
589                 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
590                 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
591                 imagePath.Append(totalCount);
592                 imagePath.Append(".png");
593
594                 pressedImagePath.Append(totalCount);
595                 pressedImagePath.Append("_press.png");
596
597                 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
598                 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
599                 if ( pBitmap == null )
600                 {
601                         return E_FAILURE;
602                 }
603
604                 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
605                 if (pBitmap != null)
606                 {
607                         __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
608                         __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
609
610                         delete pBitmap;
611                 }
612
613                 __pMultiWindowButton->AddActionEventListener(*this);
614                 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
615                 if(pPressedBitmap)
616                 {
617                         delete pPressedBitmap;
618                         pPressedBitmap = null;
619                 }
620         }
621
622         if (__pMoreButton)
623         {
624                 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
625                 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
626                 if (pBitmap != null)
627                 {
628                         Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
629                         __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
630                         __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
631
632                         delete pBitmap;
633                 }
634                 __pMoreButton->AddActionEventListener(*this);
635                 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
636         }
637
638         //Add the editfield for url
639         __pFooterUrlField =  static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
640         if (__pFooterUrlField == NULL)
641         {
642                 return E_INVALID_KEY;
643         }
644
645         __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
646         __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
647         __pFooterUrlField->AddKeypadEventListener(*this);
648         __pFooterUrlField->SetPropagatedTouchEventListener(this);
649         __pFooterUrlField->AddFocusEventListener(*this);
650
651         if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
652         {
653                 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
654         }
655         else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
656         {
657                 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE"));
658         }
659         else
660         {
661                 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
662                 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
663         }
664
665
666         //Add the go Back Button
667         __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
668         if (__pGoBackBtn == NULL)
669         {
670                 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
671                 return E_INVALID_KEY;
672         }
673         __pGoBackBtn->SetActionId(IDA_GO_BACK);
674         __pGoBackBtn->AddActionEventListener(*this);
675
676         //Add the go forward Button
677         __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
678         if (__pGoForwardBtn == NULL)
679         {
680                 AppLogDebug("Control not found returning E_INVALID_KEY");
681                 return E_INVALID_KEY;
682         }
683         __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
684         __pGoForwardBtn->AddActionEventListener(*this);
685         if (__pWebViewer && __pWebViewer->CanGoForward())
686         {
687                 SetForwardButtonEnabled(true);
688         }
689         else
690         {
691                 SetForwardButtonEnabled(false);
692         }
693
694         __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
695         if (__pRefreshBtn == NULL)
696         {
697                 AppLogDebug("Control not found returning E_INVALID_KEY");
698                 return E_INVALID_KEY;
699         }
700
701         __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
702         __pRefreshBtn->AddActionEventListener(*this);
703         __pRefreshBtn->SetShowState(true);
704
705         //Add the backround label for displaying progressbar
706         __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
707         if (__pProgressbarLabel == NULL)
708         {
709                 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
710                 return E_INVALID_KEY;
711         }
712         __pProgressbarLabel->SetShowState(false);
713
714         __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
715         if (__pStopBtn == NULL)
716         {
717                 AppLogDebug("Control not found returning E_INVALID_KEY");
718                 return E_INVALID_KEY;
719         }
720         __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
721         __pStopBtn->AddActionEventListener(*this);
722         __pStopBtn->SetShowState(false);
723
724         __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
725         if (__pClearBtn == NULL)
726         {
727                 AppLogDebug("Control not found returning E_INVALID_KEY");
728                 return E_INVALID_KEY;
729         }
730         __pClearBtn->SetActionId(IDA_CLEAR_URL);
731         __pClearBtn->AddActionEventListener(*this);
732         __pClearBtn->SetShowState(false);
733
734         __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
735         if (__pReaderBtn == NULL)
736         {
737                 AppLogDebug("Control not found returning E_INVALID_KEY");
738                 return E_INVALID_KEY;
739         }
740         __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
741         __pReaderBtn->AddActionEventListener(*this);
742         __pReaderBtn->SetShowState(false);
743
744         //      __pFooterPanel->Invalidate(true);
745         if(__isKeypadOpened == false && __pAddressbar && __pAddressbar->GetShowState() == false)
746         {
747 //              AppLog("asdasdasdasda");
748                 __pFooterPanel->SetShowState(true);
749         }
750         else if(__pAddressbar == null)
751         {
752                 __pFooterPanel->SetShowState(true);
753         }
754         else
755                 __pFooterPanel->SetShowState(false);
756         AppLogDebug("MainForm::InitFooter exit");
757         return E_SUCCESS;
758 }
759
760 result
761 MainForm::InitOptionMenu()
762 {
763         result r = E_SUCCESS;
764         bool isPrivateBrowsing = false;
765         Bitmap* pBitmap = null;
766
767         if (__pOptionMenu != null)
768         {
769                 __pOptionMenu->SetFocusable(true);
770                 __pOptionMenu->Invalidate(true);
771                 return r;
772         }
773
774         __pOptionMenu = new(std::nothrow) OptionMenu();
775         r = __pOptionMenu->Construct();
776         TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
777
778         __pOptionMenu->SetFocusable(true);
779         isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
780
781
782         if (isPrivateBrowsing == true)
783         {
784                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
785         }
786         else
787         {
788                 pBitmap  = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
789         }
790
791         r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
792
793         if ( pBitmap != NULL)
794         {
795                 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
796                 delete pBitmap;
797         }
798         r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
799         r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
800         r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
801
802
803         __pOptionMenu->SetMaxVisibleItemsCount(6);
804         __pOptionMenu->SetShowState(false);
805         __pOptionMenu->AddActionEventListener(*this);
806         SetControlAlwaysOnTop(*__pOptionMenu, true);
807
808         CATCH:
809         return r;
810 }
811
812 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
813 {
814         result r = E_SUCCESS;
815         ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
816
817         AppLog("MainForm::InitImageContextMenu clicked on image");
818         if (__pImageMenu != null)
819         {
820                 delete __pImageMenu;
821                 __pImageMenu = null;
822         }
823         if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
824         {
825                 p.y = p.y + 54;
826         }
827
828         __pImageMenu = new (std::nothrow) ContextMenu();
829         r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
830         TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
831
832         r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
833         r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
834         r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
835         r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
836         __pImageMenu->SetMaxVisibleItemsCount(4);
837         __pImageMenu->AddActionEventListener(*this);
838         SetControlAlwaysOnTop(*__pImageMenu, true);
839         __pImageMenu->SetFocusable(true);
840
841         CATCH: return r;
842 }
843
844 result
845 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
846 {
847         result r = E_SUCCESS;
848         ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
849
850         AppLog("MainForm::InitImageContextMenu clicked on image");
851         if (__pImageMenu != null)
852         {
853                 delete __pImageMenu;
854                 __pImageMenu = null;
855         }
856
857 //      if(__pAddressbar->GetShowState() == true)
858 //              p.y = p.y + __pAddressbar->GetHeight();
859         if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
860         {
861                 p.y = p.y + 54;
862         }
863
864         __pImageMenu = new (std::nothrow) ContextMenu();
865         r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
866         TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
867
868         r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_OPEN_IN_NEW_WINDOW"),IDA_HYPERLINK_OPEN_CLICKED);
869         r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_LINK_URL"),IDA_HYPERLINK_COPY_LINK_CLICKED);
870         //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
871         r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
872
873         __pImageMenu->SetMaxVisibleItemsCount(3);
874         __pImageMenu->AddActionEventListener(*this);
875         SetControlAlwaysOnTop(*__pImageMenu, true);
876         __pImageMenu->SetFocusable(true);
877
878         CATCH: return r;
879
880 }
881
882 result
883 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
884 {
885         result r = E_SUCCESS;
886         bool clipboardAvailable = true;
887         ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
888
889         AppLog("MainForm::InitSelectTextContextMenu clicked on text");
890         if (__pImageMenu != null)
891         {
892                 delete __pImageMenu;
893                 __pImageMenu = null;
894         }
895
896         if(p.y < 150)
897         {
898                 p.y = p.y + 50;
899                 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
900         }
901         else
902         {
903                 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
904         }
905
906
907         Clipboard* pClipboard = Clipboard::GetInstance();
908
909         if(pClipboard == null)
910         {
911                 clipboardAvailable = false;
912         }
913         else
914         {
915                 // Retrieves a latest item
916                 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
917
918                 if(pItem == null)
919                 {
920                         clipboardAvailable = false;
921                 }
922                 else
923                 {
924                         //Gets data from the clipboard item
925                         String* pString = dynamic_cast<String*>(pItem->GetData());
926
927                         if(pString == null)
928                         {
929                                 clipboardAvailable = false;
930                         }
931                 }
932         }
933         if(clipboardAvailable == false && onlyPasteOption == true)
934         {
935                 return E_FAILURE;
936         }
937
938         __pImageMenu = new (std::nothrow) ContextMenu();
939         r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
940         TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
941
942         if(onlyPasteOption == false)
943         {
944                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
945         }
946         if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
947         {
948                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
949         }
950         if(onlyPasteOption == false)
951         {
952                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
953                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
954         }
955
956         __pImageMenu->SetMaxVisibleItemsCount(3);
957         __pImageMenu->AddActionEventListener(*this);
958         SetControlAlwaysOnTop(*__pImageMenu, true);
959         __pImageMenu->SetFocusable(true);
960
961         CATCH: return r;
962
963 }
964
965 result
966 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
967 {
968         result r = E_SUCCESS;
969         bool clipboardAvailable = true;
970         ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
971
972         AppLog("MainForm::InitSelectTextContextMenu clicked on text");
973         if (__pImageMenu != null)
974         {
975                 delete __pImageMenu;
976                 __pImageMenu = null;
977         }
978
979         if(p.y < 150)
980         {
981                 p.y = p.y + 50;
982                 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
983         }
984         else
985         {
986                 if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
987                 {
988                         AppLog("asdasdafdsfdgfd");
989                         p.y = p.y - 50;
990                 }
991                 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
992         }
993
994
995         Clipboard* pClipboard = Clipboard::GetInstance();
996
997         if(pClipboard == null)
998         {
999                 clipboardAvailable = false;
1000         }
1001         else
1002         {
1003                 // Retrieves a latest item
1004                 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1005
1006                 if(pItem == null)
1007                 {
1008                         clipboardAvailable = false;
1009                 }
1010                 else
1011                 {
1012                         //Gets data from the clipboard item
1013                         String* pString = dynamic_cast<String*>(pItem->GetData());
1014
1015                         if(pString == null)
1016                         {
1017                                 clipboardAvailable = false;
1018                         }
1019                 }
1020         }
1021         if(clipboardAvailable == false && onlyPasteOption == true)
1022         {
1023                 return E_FAILURE;
1024         }
1025         __pImageMenu = new (std::nothrow) ContextMenu();
1026         r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
1027         TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
1028
1029
1030
1031
1032
1033         if(onlyPasteOption == false)
1034         {
1035                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
1036         }
1037         if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
1038         {
1039                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
1040         }
1041         if(onlyPasteOption == false)
1042         {
1043                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
1044                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
1045         }
1046
1047         __pImageMenu->SetMaxVisibleItemsCount(3);
1048         __pImageMenu->AddActionEventListener(*this);
1049         SetControlAlwaysOnTop(*__pImageMenu, true);
1050         __pImageMenu->SetFocusable(true);
1051
1052         CATCH: return r;
1053
1054 }
1055
1056 result
1057 MainForm::InitFindWordPanel(void)
1058 {
1059         result r = E_SUCCESS;
1060         Bitmap *pIconBitmap = null;
1061
1062         if (__pFindWordControl != null)
1063         {
1064                 AppLogDebug("Findword panel already initialized");
1065                 if (__pFindWordBgLabel != null)
1066                 {
1067                         Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1068                         if (pBitmap != null)
1069                         {
1070                                 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1071                                 delete pBitmap;
1072                         }
1073                 }
1074                 if (__pFindWordBgLabelRightToLeft != null)
1075                 {
1076                         Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
1077                         if (pBitmap != null)
1078                         {
1079                                 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1080                                 delete pBitmap;
1081                         }
1082                 }
1083                 if(__pAddressbar)
1084                         __pAddressbar->SetShowState(false);
1085
1086                 if(__isKeypadOpened == false)
1087                         __pFooterPanel->SetShowState(true);
1088                 return r;
1089         }
1090
1091         __pFindWordControl = new (std::nothrow) Panel();
1092         r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
1093         if (IsFailed(r))
1094         {
1095                 AppLogException("There is some problem in the xml file. Please check.");
1096                 return E_FAILURE;
1097         }
1098         AddControl(__pFindWordControl);
1099         __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
1100         SetControlAlwaysOnTop(*__pFindWordControl,true);
1101         __pFindWordControl->SetShowState(false);
1102         __pFindWordControl->Invalidate(false);
1103
1104         __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1105         __pFindWordPanelLeftToRight->SetShowState(true);
1106
1107         __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1108         __pFindWordPanelRightToLeft->SetShowState(false);
1109
1110         __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1111         if (__pFindWordBgLabel != null)
1112         {
1113                 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1114                 Rectangle pRect = pPanel1->GetBounds();
1115                 pRect.x = pRect.y = 0;
1116                 __pFindWordBgLabel->SetBounds(pRect);
1117                 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1118                 if (pBitmap != null)
1119                 {
1120                         AppLogDebug("InitFindWordPanel: Coming here");
1121                         __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1122                         delete pBitmap;
1123                 }
1124                 else
1125                 {
1126                         AppLogDebug("InitFindWordPanel: shouldn't Come here");
1127                 }
1128         }
1129
1130         __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1131                 if (__pFindWordBgLabelRightToLeft != null)
1132                 {
1133                         Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1134                         Rectangle pRect = pPanel1->GetBounds();
1135                         pRect.x = pRect.y = 0;
1136                         __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1137                         Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1138                         if (pBitmap != null)
1139                         {
1140                                 AppLogDebug("InitFindWordPanel: Coming here");
1141                                 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1142                                 delete pBitmap;
1143                         }
1144                         else
1145                         {
1146                                 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1147                         }
1148                 }
1149
1150         Button* pfindWordCancel = null;
1151         pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1152         if (pfindWordCancel == null)
1153         {
1154                 AppLogException("There is some problem in the xml file. Please check.");
1155                 return E_FAILURE;
1156         }
1157         pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1158         pfindWordCancel->AddActionEventListener(*this);
1159
1160         __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1161         if (__pFindWordClear == null)
1162         {
1163                 AppLogException("There is some problem in the xml file. Please check.");
1164                 return E_FAILURE;
1165         }
1166
1167         __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1168                 if (__pFindWordClearRightToLeft == null)
1169                 {
1170                         AppLogException("There is some problem in the xml file. Please check.");
1171                         return E_FAILURE;
1172                 }
1173
1174         __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1175         __pFindWordClear->AddActionEventListener(*this);
1176
1177         __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1178         __pFindWordClearRightToLeft->AddActionEventListener(*this);
1179
1180         __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1181         if (__pFindWordNext == null)
1182         {
1183                 AppLogException("There is some problem in the xml file. Please check.");
1184                 return E_FAILURE;
1185         }
1186
1187         __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1188         __pFindWordNext->AddActionEventListener(*this);
1189
1190         __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1191         if (__pFindWordPrev == null)
1192         {
1193                 AppLogException("There is some problem in the xml file. Please check.");
1194                 return E_FAILURE;
1195         }
1196
1197         __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1198         __pFindWordPrev->AddActionEventListener(*this);
1199
1200         __pFindWordNext->SetEnabled(false);
1201         __pFindWordPrev->SetEnabled(false);
1202
1203         __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1204         if (__pFindWordCountLabel == null)
1205         {
1206                 AppLogException("There is some problem in the xml file. Please check.");
1207                 return E_FAILURE;
1208         }
1209
1210         __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1211         if (__pFindWordCountLabelRightToLeft == null)
1212         {
1213                 AppLogException("There is some problem in the xml file. Please check.");
1214                 return E_FAILURE;
1215         }
1216
1217         __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1218         if (__pFindWordEditField == null)
1219         {
1220                 AppLogException("There is some problem in the xml file. Please check.");
1221                 return E_FAILURE;
1222         }
1223         __pFindWordEditField->AddTextEventListener(*this);
1224         __pFindWordEditField->AddKeypadEventListener(*this);
1225         __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1226         __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1227
1228         __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1229         if (__pFindWordEditFieldRightToLeft == null)
1230         {
1231                 AppLogException("There is some problem in the xml file. Please check.");
1232                 return E_FAILURE;
1233         }
1234         __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1235         __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1236         __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1237         __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1238
1239         if(__pAddressbar)
1240                 __pAddressbar->SetShowState(false);
1241
1242         if(__isKeypadOpened == false)
1243                 __pFooterPanel->SetShowState(true);
1244         return r;
1245 }
1246
1247 ListItemBase*
1248 MainForm::CreateItem (int index, int itemWidth)
1249 {
1250         Rectangle listImageRect;
1251         Rectangle pagetTitleRect;
1252         Rectangle pageURLRect;
1253         Rectangle deleteImageRect;
1254         String pageTitle(L"");
1255         String pageURL(L"");
1256         result r = E_SUCCESS;
1257         Bitmap* pListIconImage = null;
1258
1259
1260         History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1261         if(pHistory == null)
1262         {
1263                 return null;
1264         }
1265         AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1266         if ( pAppResource == NULL )
1267         {
1268                 return null;
1269         }
1270         ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1271
1272         CustomItem* pItem = new(std::nothrow) CustomItem();
1273         pageTitle = pHistory->GetHistoryTitle();
1274         pageURL = pHistory->GetHistoryUrl();
1275
1276         if (pageURL.GetLength() == 0)
1277         {
1278                 String nourl;
1279                 pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", nourl);
1280                 pageURL = L"<"+ nourl +">";
1281
1282         }
1283
1284         Rectangle screenBounds = GetBounds();
1285         if (pItem != null)
1286         {
1287                 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1288         }
1289         if (IsFailed(r))
1290         {
1291                 delete pItem;
1292                 return NULL;
1293         }
1294
1295
1296         Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1297
1298         if ( pBitmap != NULL)
1299         {
1300                 pListIconImage = new Bitmap();
1301                 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1302                 delete pBitmap;
1303         }
1304
1305         if(pListIconImage == null)
1306         {
1307                 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1308         }
1309
1310         if ( pListIconImage != NULL)
1311         {
1312                 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28  + (__fontSize - 44)/2 , 72, 72);
1313                 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 72  + (__fontSize - 44));
1314                 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1315
1316
1317                 if (pItem != null && pListIconImage != NULL)
1318                 {
1319                         pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1320                 }
1321         }
1322
1323         if (pageTitle.CompareTo(L"") != 0)
1324         {
1325                 if (pItem != null)
1326                 {
1327                         pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1328                 }
1329         }
1330
1331         if (pageURL.CompareTo(L"") != 0)
1332         {
1333                 if (pItem != null)
1334                 {
1335                         pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1336                 }
1337         }
1338
1339
1340         if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1341         {
1342                 if ( __pItemContext!= NULL)
1343                 {
1344                         if (pItem != null)
1345                         {
1346                                 pItem->SetContextItem(__pItemContext);
1347                         }
1348                 }
1349         }
1350         else
1351         {
1352                 if ( __pItemContextLandscape!= NULL)
1353                 {
1354                         if (pItem != null)
1355                         {
1356                                 pItem->SetContextItem(__pItemContextLandscape);
1357                         }
1358                 }
1359         }
1360         if( pListIconImage != NULL)
1361         {
1362                 delete pListIconImage;
1363                 pListIconImage = null;
1364         }
1365
1366         return pItem;
1367 }
1368
1369 bool
1370 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1371 {
1372         delete pItem;
1373         return true;
1374 }
1375
1376 int
1377 MainForm::GetItemCount (void)
1378 {
1379         if(__pMostVisitedSites != null)
1380         {
1381                 __pMostVisitedSites->RemoveAll(true);
1382         }
1383         HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1384         if(__pMostVisitedSites != null)
1385         {
1386                 return __pMostVisitedSites->GetCount();
1387         }
1388         else
1389                 return 0;
1390 }
1391
1392 void
1393 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1394 {
1395         AppLog("MainForm::OnListViewContextItemStateChanged called");
1396         if(__pMostVisitedSites != null)
1397         {
1398                 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1399                 if (pHistory != null)
1400                 {
1401                         String url = pHistory->GetHistoryUrl();
1402
1403                         HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1404                         __pMostVisitedListView->UpdateList();
1405                 }
1406         }
1407 }
1408
1409 void
1410 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1411 {
1412         History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1413         String url = pHistory->GetHistoryUrl();
1414         if (url != null)
1415         {
1416                 LoadUrl(url);
1417         }
1418 }
1419
1420 void
1421 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1422 {
1423
1424 }
1425
1426 result
1427 MainForm::OnTerminating(void)
1428 {
1429         result r = E_SUCCESS;
1430
1431         RemoveOrientationEventListener(*this);
1432
1433         if(__pAddressbar)
1434         {
1435                 __pAddressbar->SetAddressbarEventListener(null);
1436         }
1437
1438         if(__pWebViewer)
1439         {
1440                 __pWebViewer->RemoveTouchEventListener(*this);
1441                 __pWebViewer->SetWebUiEventListenerF(null);
1442                 __pWebViewer->SetWebKeypadEventListener(null);
1443                 __pWebViewer->SetTextSearchListener(null);
1444         }
1445
1446
1447         if (__pItemContext)
1448         {
1449                 delete __pItemContext;
1450         }
1451         if (__pItemContextLandscape)
1452         {
1453                 delete __pItemContextLandscape;
1454         }
1455         if (__pSaveImage)
1456         {
1457                 delete __pSaveImage;
1458         }
1459         if (__pMostVisitedSites)
1460         {
1461                 __pMostVisitedSites->RemoveAll(true);
1462                 delete __pMostVisitedSites;
1463         }
1464         return r;
1465 }
1466
1467 void
1468 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1469 {
1470         result r = E_SUCCESS;
1471
1472         AppLogDebug("Clicked : %d", actionId);
1473         switch (actionId)
1474         {
1475         case IDA_BACKBTN_CLICKED:
1476         {
1477                 if(__pImageMenu && __pImageMenu->GetShowState() == true)
1478                 {
1479                         AppLog("Hiding the menu");
1480                         __pImageMenu->SetShowState(false);
1481                 }
1482                 if (__pWebViewer && __pWebViewer->CanGoBack())
1483                 {
1484                         __pWebViewer->GoBack();
1485                 }
1486                 else if(__pWindowInfo->isJavascriptInitiated == false)
1487                 {
1488                         UiApp* pApp = null;
1489                         pApp = UiApp::GetInstance();
1490                         if (pApp != null)
1491                         {
1492                                 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1493                                 if (IsFailed(r))
1494                                 {
1495                                         AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1496                                         return;
1497                                 }
1498                         }
1499                 }
1500                 else
1501                 {
1502                         UiApp* pApp = null;
1503                         WindowInfo* pWindowInfo = null;
1504                         int totalCount = 0;
1505                         SceneManager* pSceneManager = SceneManager::GetInstance();
1506                         if (pSceneManager == null)
1507                         {
1508                                 return;
1509                         }
1510                         ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1511                         if (pAllWindowList == NULL)
1512                         {
1513                                 pApp = UiApp::GetInstance();
1514                                 if (pApp != null)
1515                                 {
1516                                         r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1517                                         if (IsFailed(r))
1518                                         {
1519                                                 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1520                                                 return;
1521                                         }
1522                                 }
1523                         }
1524                         if (pAllWindowList != null)
1525                         {
1526                                 totalCount = pAllWindowList->GetCount();
1527                         }
1528                         for (int count = 0; count < totalCount; count++)
1529                         {
1530                                 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1531                                 if (pWindowInfo == null)
1532                                 {
1533                                         pApp = UiApp::GetInstance();
1534                                         if (pApp != null)
1535                                         {
1536                                                 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1537                                                 if (IsFailed(r))
1538                                                 {
1539                                                         AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1540                                                         return;
1541                                                 }
1542                                         }
1543                                 }
1544                                 else
1545                                 {
1546                                         if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1547                                         {
1548                                                 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1549                                                 if (IsFailed(r))
1550                                                 {
1551                                                         AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1552                                                         return;
1553                                                 }
1554                                                 r = pAllWindowList->RemoveAt(count, true);
1555                                                 __pWindowInfo = null;
1556                                                 if (IsFailed(r))
1557                                                 {
1558                                                         AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1559                                                         return;
1560                                                 }
1561                                                 if(count > 0)
1562                                                 {
1563                                                         pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1564                                                 }
1565                                                 else
1566                                                 {
1567                                                         pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1568                                                 }
1569                                                 if (pWindowInfo == null)
1570                                                 {
1571                                                         pApp = UiApp::GetInstance();
1572                                                         if (pApp != null)
1573                                                         {
1574                                                                 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1575                                                                 return;
1576                                                         }
1577                                                 }
1578                                                 else
1579                                                 {
1580                                                         r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
1581 //                                                      r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1582                                                         if (IsFailed(r))
1583                                                         {
1584                                                                 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1585                                                                 return;
1586                                                         }
1587                                                 }
1588                                                 break;
1589                                         }
1590                                 }
1591                         }
1592                 }
1593         }
1594                 break;
1595
1596         case IDA_FORWARD_CLICKED:
1597                 if (__pWebViewer == null)
1598                         return;
1599
1600                 if (__pWebViewer->CanGoForward())
1601                 {
1602                         __pWebViewer->GoForward();
1603                 }
1604                 __pOptionMenu->SetShowState(false);
1605                 __pOptionMenu->Invalidate(false);
1606                 break;
1607
1608         case IDA_FINDONPAGE_CLICKED:
1609         {
1610                 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1611                 __currentSearchStr.Clear();
1612
1613                 InitFindWordPanel();
1614                 __pOptionMenu->SetShowState(false);
1615                 __pOptionMenu->Invalidate(false);
1616
1617                 ShowFindWordPanel(true);
1618
1619                 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1620                 {
1621                         __pFindWordEditField->SetFocus();
1622 //                      __pFindWordCountLabel->SetShowState(false);
1623                 }
1624                 else
1625                 {
1626                         __pFindWordEditFieldRightToLeft->SetFocus();
1627                         __pFindWordCountLabelRightToLeft->SetShowState(false);
1628                 }
1629         }
1630         break;
1631         case IDA_PRIVATEON_CLICKED:
1632         {
1633                 result r = E_SUCCESS;
1634                 int itemIndex = 0;
1635                 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1636                 Bitmap* pBitmap = null;
1637                 if (isPrivateBrowsing == true)
1638                 {
1639                         pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1640                         if (IsFailed(r))
1641                         {
1642                                 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1643                                 return ;
1644                         }
1645
1646                         if (__pWebViewer != NULL)
1647                         {
1648                                 __pWebViewer->SetPrivateBrowsingEnabled(false);
1649                         }
1650
1651                         SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1652
1653                         if (__pAddressbar != null)
1654                         {
1655                                 __pAddressbar->UpdateFaviconBitmap(false);
1656                         }
1657
1658                 }
1659                 else
1660                 {
1661                         pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1662                         if (IsFailed(r))
1663                         {
1664                                 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1665                                 return ;
1666                         }
1667
1668                         if (__pWebViewer != NULL)
1669                         {
1670                                 __pWebViewer->SetPrivateBrowsingEnabled(true);
1671                         }
1672
1673                         SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1674
1675                         if (__pAddressbar != null)
1676                         {
1677                                 __pAddressbar->UpdateFaviconBitmap(true);
1678                         }
1679                 }
1680
1681                 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1682                 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1683                 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1684                 __pOptionMenu->Invalidate(true);
1685                 if ( pBitmap != NULL )
1686                 {
1687                         delete pBitmap;
1688                 }
1689
1690         }
1691         break;
1692         case IDA_SETTINGS_CLICKED:
1693         {
1694
1695                 ArrayList* pArgList = new(std::nothrow) ArrayList();
1696                 if (pArgList)
1697                 {
1698                         pArgList->Construct();
1699                         pArgList->Add(*__pWindowInfo);
1700                         SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1701                 }
1702                 __pOptionMenu->SetShowState(false);
1703                 __pOptionMenu->Invalidate(false);
1704
1705                 if (pArgList != null)
1706                 {
1707                         delete pArgList;
1708                         pArgList = null;
1709                 }
1710
1711         }
1712         break;
1713
1714         case IDA_ADDTOBOOKMARK_CLICKED:
1715         {
1716
1717                 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1718                 {
1719                         int bookmarkCount=0;
1720                         bool exist = false;
1721                         String url=L"";
1722                         url=__pWindowInfo->pageUrl;
1723                         result r = E_SUCCESS;
1724                         Bitmap* pBitmap = null;
1725                         r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1726
1727                         if (IsFailed(r))
1728                         {
1729                                 return;
1730                         }
1731                         if ( exist == true)
1732                         {
1733                                 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1734                                 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1735                                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1736
1737                                 if(__pNotification != null)
1738                                 {
1739                                         RemoveControl(__pNotification);
1740                                         __pNotification = null;
1741                                 }
1742                                 __pNotification = new (std::nothrow) NotificationPanel(*this);
1743                                 if (__pNotification != null)
1744                                 {
1745                                         __pNotification->SetText(message);
1746                                         __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1747                                         __pNotification->ShowNotification();
1748                                 }
1749                         }
1750                         else
1751                         {
1752                                 String title=__pWindowInfo->pageTitle;
1753                                 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1754                                 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1755
1756                                 pBookmark->SetBookmarkTitle(title);
1757                                 pBookmark->SetUrl(url);
1758                                 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1759                                 {
1760                                         pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1761                                 }
1762                                 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1763                                 pBookmark->SetFaviconId(id);
1764                                 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1765                                 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1766                                 delete pBookmark;
1767                                 if(__pNotification != null)
1768                                 {
1769                                         RemoveControl(__pNotification);
1770                                         __pNotification = null;
1771                                 }
1772                                 __pNotification = new (std::nothrow) NotificationPanel(*this);
1773                                 if (__pNotification != null)
1774                                 {
1775                                         __pNotification->SetText(message);
1776                                         __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1777                                         __pNotification->ShowNotification();
1778                                         pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1779                                 }
1780                         }
1781                         if (pBitmap != null)
1782                         {
1783                                 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1784                                 delete pBitmap;
1785                         }
1786
1787
1788                         __pOptionMenu->Invalidate(true);
1789                 }
1790
1791         }
1792         break;
1793         case IDA_PRINT_CLICKED:
1794         {
1795                 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1796                 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1797
1798                 AppLog("RequestPrint called!");
1799                 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1800                 result nResult = E_FAILURE;
1801                 if (pAc)
1802                 {
1803                         AppLog("TestPrint if (pAc) == true");
1804
1805                         HashMap map;
1806                         map.Construct();
1807
1808                         String fileType = L"service_print_files_type";
1809                         String typeVal = L"DOC";
1810
1811                         String fileCount = L"service_print_files_count";
1812                         String countVal = L"1";
1813                         String fileFolder= L"service_print_files_folder_name";
1814                         String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1815
1816                         map.Add(&fileCount, &countVal);
1817                         map.Add(&fileFolder, &folderVal);
1818                         map.Add(&fileType, &typeVal);
1819
1820                         String fileName = L"service_print_files_files_name";
1821
1822                         ArrayList fileNameList;
1823                         fileNameList.Construct();
1824                         String file1 = L"test.pdf";
1825
1826                         fileNameList.Add(&file1);
1827                         map.Add(&fileName, &fileNameList);
1828
1829                         nResult = pAc->Start(NULL, NULL, &map, NULL);
1830
1831                         if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1832                         else if (nResult == E_MAX_EXCEEDED)
1833                                 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1834                         else if (nResult == E_OBJ_NOT_FOUND)
1835                                 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1836                         else if (nResult == E_IN_PROGRESS)
1837                                 AppLog("TestPrint ret == E_IN_PROGRESS");
1838                         else if (nResult == E_PRIVILEGE_DENIED)
1839                                 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1840                         else if(nResult == E_SYSTEM)
1841                                 AppLog("TestPrint ret == E_SYSTEM");
1842
1843                         delete pAc;
1844                 }
1845                 else
1846                 {
1847                         int __modalMsgBoxResult;
1848                         MessageBox* pMsgBox = new MessageBox();
1849                         pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1850                         pMsgBox->ShowAndWait(__modalMsgBoxResult);
1851                         delete pMsgBox;
1852                         pMsgBox = null;
1853                         __modalMsgBoxResult = 0;
1854                 }
1855         }
1856         break;
1857         case IDA_SHARE_CLICKED:
1858         {
1859                 if(__pPopUp != null)
1860                 {
1861                         delete __pPopUp;
1862                         __pPopUp = null;
1863                 }
1864                 if(__pAddressbar)
1865                 {
1866                         __pAddressbar->HideKeypad();
1867                 }
1868                 __pPopUp = new(std::nothrow) SharePopup();
1869                 __pPopUp->Initialize();
1870                 if (__pWindowInfo != null)
1871                 {
1872                         ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1873                         pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1874                         pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1875                         pShareInfo->SetImageAttached(false);
1876                         __pPopUp->RemoveAllShareInfo();
1877                         __pPopUp->AddShareInfo(pShareInfo);
1878                 }
1879                 __pPopUp->SetShowState(true);
1880                 __pPopUp->Show();
1881         }
1882         break;
1883         case IDA_BOOKMARKBTN_CLICKED:
1884         {
1885                 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1886                 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1887         }
1888         break;
1889         case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1890         {
1891
1892         }
1893         break;
1894         case IDA_MOREBTN_CLICKED:
1895         {
1896                 AppLog("IDA_MOREBTN_CLICKED");
1897                 InitOptionMenu();
1898                 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1899                 {
1900                         int bookmarkCount=0;
1901                         bool exist = false;
1902                         String url=L"";
1903                         url=__pWindowInfo->pageUrl;
1904                         result r = E_SUCCESS;
1905                         Bitmap* pBitmap = null;
1906
1907                         r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1908                         if (IsFailed(r))
1909                         {
1910                                 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1911                                 return;
1912                         }
1913                         if ( exist == true)
1914                         {
1915                                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1916                         }
1917                         else
1918                         {
1919                                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1920                         }
1921                         AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1922
1923                         if (__pOptionMenu->GetItemCount() == 9)
1924                         {
1925                                 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1926                         }
1927                         else
1928                         {
1929                                 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1930                         }
1931
1932                         if (IsFailed(r))
1933                         {
1934                                 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1935                                 delete pBitmap;
1936                                 return ;
1937                         }
1938                         AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1939                         if (__pOptionMenu->GetItemCount() != 9)
1940                         {
1941                                 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1942                                 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1943         //                              __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1944                                 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1945                                 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1946                                 __pOptionMenu->SetMaxVisibleItemsCount(6);
1947                         }
1948                         if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1949                         {
1950                                 AppLog(" Orientation landscape");
1951                                 __pOptionMenu->SetMaxVisibleItemsCount(5);
1952                         }
1953                         else
1954                         {
1955                                 AppLog(" Orientation potrait");
1956                                 __pOptionMenu->SetMaxVisibleItemsCount(6);
1957                         }
1958
1959                         AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1960                         delete pBitmap;
1961                 }
1962                 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1963                 __pOptionMenu->SetShowState(true);
1964                 __pOptionMenu->Invalidate(true);
1965                 __pOptionMenu->Show();
1966
1967 }
1968         break;
1969         case IDA_HISTORY_CLICKED:
1970         {
1971                 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1972                 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1973         }
1974         break;
1975         case IDA_SAVED_PAGES_CLICKED:
1976         {
1977
1978         }
1979         break;
1980         case IDA_DESKTOP_VIEW_CLICKED:
1981         {
1982
1983         }
1984         break;
1985         case IDA_SAVE_CLICKED:
1986         {
1987
1988         }
1989         break;
1990         case IDA_MULTIWINDOWBTN_CLICKED:
1991         {
1992                 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1993                 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1994         }
1995         break;
1996
1997         case IDA_NEWWINDOWBTN_CLICKED:
1998         {
1999                 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
2000
2001                 if (pNewWindowInfo == null)
2002                 {
2003                         return;
2004                 }
2005                 result r = E_SUCCESS;
2006                 SceneManager* pSceneManager = SceneManager::GetInstance();
2007
2008                 if (pSceneManager == NULL)
2009                 {
2010                         return;
2011                 }
2012                 ArrayList* pArgList = new(std::nothrow) ArrayList();
2013                 if (pArgList == NULL)
2014                 {
2015                         return;
2016                 }
2017                 r = pArgList->Construct();
2018                 if (r == E_SUCCESS)
2019                 {
2020                         pArgList->Add(*pNewWindowInfo);
2021                         r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2022                 } 
2023                 delete pArgList;
2024                 pArgList = null;
2025                 if (IsFailed(r))
2026                 {
2027                         AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
2028                         return;
2029                 }
2030         }
2031         break;
2032         case IDA_SMALLFONT_BTN_CLICKED:
2033         {
2034                 WebSetting setting = __pWebReader->GetSetting();
2035                 setting.SetFontSize(15);
2036                 __pWebReader->SetSetting(setting);
2037         }
2038         break;
2039         case IDA_LARGEFONT_BTN_CLICKED:
2040         {
2041                 WebSetting setting = __pWebReader->GetSetting();
2042                 setting.SetFontSize(25);
2043                 __pWebReader->SetSetting(setting);
2044         }
2045         break;
2046         case IDA_READER_CLOSE_CLICKED:
2047         {
2048                 if (__pArticleReaderPanel != null && __pBlankPanel != null)
2049                 {
2050                         RemoveControl(__pBlankPanel);
2051                         __pArticleReaderPanel = null;
2052                         __pBlankPanel = null;
2053                         __pArticleReaderLabel = null;
2054                 }
2055                 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2056         }
2057         break;
2058         case IDA_FINDWORD_CANCEL_CLICKED:
2059         {
2060                 __currentSearchStr = L"";
2061                 __currentWordIndex = 0;
2062                 __maxOccurrances = 0;
2063
2064                 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2065                 {
2066                         __pFindWordEditField->SetText(L"");
2067                         __pFindWordCountLabel->SetText(L"0/0");
2068                 }
2069                 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2070                 {
2071                         __pFindWordEditFieldRightToLeft->SetText(L"");
2072                         __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2073                 }
2074
2075                 __pFindWordNext->SetEnabled(false);
2076                 __pFindWordPrev->SetEnabled(false);
2077                 __pFindWordCountLabel->SetText(L"0/0");
2078                 __pWebViewer->SearchTextAllAsync(L"",true);
2079                 AppLog("akjshdasd 1");
2080                 if(__isKeypadOpened == false)
2081                         __pFooterPanel->SetShowState(true);
2082                 ShowFindWordPanel(false);
2083         }
2084         break;
2085         case IDA_FINDWORD_SEARCH_CLICKED:
2086         {
2087                 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2088                 {
2089                         __currentSearchStr = __pFindWordEditField->GetText();
2090                 }
2091                 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2092                 {
2093                         __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
2094                 }
2095
2096                 if (__currentSearchStr.GetLength() > 0)
2097                 {
2098                         StartWordSearch();
2099                 }
2100                 else
2101                 {
2102                         AppLogDebug("Enter something");
2103                 }
2104         }
2105         break;
2106         case IDA_FINDWORD_CLEAR_CLICKED:
2107         {
2108                 __pFindWordCountLabel->SetText(L"0/0");
2109                 __pFindWordEditField->SetText(L"");
2110                 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2111                 StartWordSearch();
2112                 __currentSearchStr = L"";
2113                 __pFindWordNext->SetEnabled(false);
2114                 __pFindWordPrev->SetEnabled(false);
2115 //              __pFindWordCountLabel->SetShowState(false);
2116                 __pFindWordControl->Invalidate(true);
2117         }
2118         break;
2119         case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
2120         {
2121                 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2122                 __pFindWordEditFieldRightToLeft->SetText(L"");
2123                 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2124                 StartWordSearch();
2125                 __currentSearchStr = L"";
2126                 __pFindWordNext->SetEnabled(false);
2127                 __pFindWordPrev->SetEnabled(false);
2128 //              __pFindWordCountLabelRightToLeft->SetShowState(false);
2129                 __pFindWordControl->Invalidate(true);
2130         }
2131         break;
2132         case IDA_FINDWORD_NEXT_CLICKED:
2133         {
2134                 FindNextWord(true);
2135         }
2136         break;
2137         case IDA_FINDWORD_PREV_CLICKED:
2138         {
2139                 FindNextWord(false);
2140         }
2141         break;
2142         case IDA_BRIGHTNESS_BTN_CLICKED:
2143         {
2144                 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2145                 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2146         }
2147         break;
2148         case IDA_COPY_IMAGE_CLICKED:
2149         {
2150                 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2151                 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2152                 ClipboardItem item;
2153                 const Bitmap* pBitmap = null;
2154                 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2155                 {
2156                         pBitmap = __pHitElementResult->GetImage();
2157                 }
2158
2159                 String resourcePath = App::GetInstance()->GetAppResourcePath();
2160                 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2161                 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2162                 // copying the item to clipboard
2163                 Clipboard* pClipboard = Clipboard::GetInstance();
2164                 if (pClipboard != null)
2165                 {
2166                         r = pClipboard->CopyItem(item);
2167                         AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2168                 }
2169         }
2170         break;
2171         case IDA_VIEW_IMAGE_CLICKED:
2172         {
2173                 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2174                 WindowInfo* pNewWindowInfo = null;
2175                 if (__pHitElementResult != null)
2176                 {
2177                         String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2178                         AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2179                         LoadUrl(srcUrl);
2180
2181                 }
2182         }
2183         break;
2184         case IDA_SAVE_IMAGE_CLICKED:
2185         {
2186                 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2187                 const Bitmap* pSaveBitmap = null;
2188                 String imageName = GetImagePath();
2189                 AppLog("Content manager image name %ls",imageName.GetPointer());
2190                 String imagePath;
2191                 imagePath.Clear();
2192                 imagePath.Append(imageName);
2193                 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(),  imageName.GetPointer());
2194                 AppLog("Content manager image path %ls",imagePath.GetPointer());
2195                 if (__pHitElementResult != null)
2196                 {
2197                         pSaveBitmap = __pHitElementResult->GetImage();
2198                 }
2199                 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2200
2201                 if(pBuffer)
2202                 {
2203                         UpdateImageContent(pBuffer, imageName);
2204                         delete pBuffer;
2205                         if(__pNotification != null)
2206                         {
2207                                 RemoveControl(__pNotification);
2208                                 __pNotification = null;
2209                         }
2210                         __pNotification = new NotificationPanel(*this);
2211                         String msg;
2212                         AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2213                         msg.Append(imagePath);
2214                         if (__pNotification != null)
2215                         {
2216                                 __pNotification->SetText(msg);
2217                                 if (__pFooterPanel->GetShowState() == true)
2218                                 {
2219                                         __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2220                                 }
2221                                 else
2222                                 {
2223                                         __pNotification->SetPositionDiff(0);
2224                                 }
2225                                 __pNotification->ShowNotification();
2226                         }
2227                 }
2228                 else
2229                 {
2230                         int __modalMsgBoxResult;
2231                         MessageBox* pMsgBox = new MessageBox();
2232                         pMsgBox->Construct(CommonUtil::GetString(L"IDS_IMGE_POP_UNABLE_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_IMGE_POP_UNABLE_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2233                         pMsgBox->ShowAndWait(__modalMsgBoxResult);
2234                         delete pMsgBox;
2235                         pMsgBox = null;
2236                         __modalMsgBoxResult = 0;
2237                 }
2238         }
2239         break;
2240         case IDA_SHARE_IMAGE_CLICKED:
2241         {
2242                 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2243                 if (__pPopUp != null)
2244                 {
2245                         delete __pPopUp;
2246                         __pPopUp = null;
2247                 }
2248                 if(__pAddressbar)
2249                 {
2250                         __pAddressbar->HideKeypad();
2251                 }
2252                 __pPopUp = new(std::nothrow) SharePopup();
2253                 __pPopUp->Initialize();
2254                 if (__pHitElementResult != null)
2255                 {
2256                         const Bitmap* pSaveBitmap = null;
2257                         String imageName = GetImagePath();
2258                         AppLog("Content manager image name %ls",imageName.GetPointer());
2259                         String imagePath;
2260                         imagePath.Clear();
2261                         imagePath.Append(imageName);
2262                         imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(),  imageName.GetPointer());
2263                         AppLog("Content manager image path %ls",imagePath.GetPointer());
2264                         if (__pHitElementResult != null)
2265                         {
2266                                 pSaveBitmap = __pHitElementResult->GetImage();
2267                         }
2268                         __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2269
2270                         String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2271                         AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2272
2273                         ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2274                         pShareInfo->SetPageTitle(L"");
2275                         pShareInfo->SetPageUrl(srcUrl);
2276                         pShareInfo->SetImageAttached(true);
2277                         pShareInfo->SetImagePath(imagePath);
2278                         __pPopUp->RemoveAllShareInfo();
2279                         __pPopUp->AddShareInfo(pShareInfo);
2280                         __pPopUp->SetShowState(true);
2281                         __pPopUp->Show();
2282                 }
2283         }
2284         break;
2285         case IDA_HYPERLINK_OPEN_CLICKED:
2286         {
2287                 if (__pHitElementResult != null)
2288                 {
2289                         String srcUrl = __pHitElementResult->GetUrl();
2290
2291                         WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2292
2293                         if (pNewWindowInfo == null)
2294                         {
2295                                 return;
2296                         }
2297                         pNewWindowInfo->isJavascriptInitiated = true;
2298                         result r = E_SUCCESS;
2299                         SceneManager* pSceneManager = SceneManager::GetInstance();
2300                         if (pSceneManager == NULL)
2301                         {
2302                                 return;
2303                         }
2304                         ArrayList* pArgList = new(std::nothrow) ArrayList();
2305                         if (pArgList == NULL)
2306                         {
2307                                 return;
2308                         }
2309                         pArgList->Construct();
2310
2311                         pArgList->Add(*pNewWindowInfo);
2312                         r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2313                         if (pArgList != null)
2314                         {
2315                                 delete pArgList;
2316                                 pArgList = null;
2317                         }
2318                         if(IsFailed(r))
2319                         {
2320                                 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2321                                 return;
2322                         }
2323                 }
2324         }
2325         break;
2326         case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2327         {
2328                 if (__pHitElementResult == null)
2329                 {
2330                         return;
2331                 }
2332
2333                 if(__pPopUp != null)
2334                 {
2335                         delete __pPopUp;
2336                         __pPopUp = null;
2337                 }
2338                 if(__pAddressbar)
2339                 {
2340                         __pAddressbar->HideKeypad();
2341                 }
2342                 __pPopUp = new(std::nothrow) SharePopup();
2343                 __pPopUp->Initialize();
2344
2345                 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2346                 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2347                 pShareInfo->SetImageAttached(false);
2348                 __pPopUp->RemoveAllShareInfo();
2349                 __pPopUp->AddShareInfo(pShareInfo);
2350
2351                 __pPopUp->SetShowState(true);
2352                 __pPopUp->Show();
2353         }
2354         break;
2355         case IDA_HYPERLINK_COPY_LINK_CLICKED:
2356         {
2357                 ClipboardItem item;
2358                 String url;
2359                 if (__pHitElementResult != null)
2360                 {
2361                         url = __pHitElementResult->GetUrl();
2362                 }
2363
2364                 String resourcePath = App::GetInstance()->GetAppResourcePath();
2365                 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2366
2367                 // copying the item to clipboard
2368                 Clipboard* pClipboard = Clipboard::GetInstance();
2369                 if (pClipboard != null)
2370                 {
2371                         pClipboard->CopyItem(item);
2372                 }
2373         }
2374         break;
2375         case IDA_FIND_TEXT__CLICKED:
2376         {
2377 //              AddressBarCancelledClicked(*__pAddressbar);
2378                 RelayoutControls(false);
2379 //              __pFooterPanel->SetShowState(false);
2380                 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2381                 __currentSearchStr.Clear();
2382                 __currentSearchStr.Append(__currentSelectedStr);
2383                 InitFindWordPanel();
2384                 __pFindWordEditField->SetText(__currentSearchStr);
2385
2386                 if(__pOptionMenu != null)
2387                 {
2388                         __pOptionMenu->SetShowState(false);
2389                         __pOptionMenu->Invalidate(false);
2390                 }
2391                 __adressPanelPosition.y = 0;
2392
2393                 if (__pAddressbar != null && __pWebViewer != NULL)
2394                 {
2395                         __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2396                         __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2397
2398                         if (__pFooterPanel->GetShowState() == false)
2399                                 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2400                         else
2401                                 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2402                         __pWebViewer->Invalidate(true);
2403                 }
2404
2405                 ShowFindWordPanel(true);
2406                 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2407                 {
2408                         __pFindWordEditField->SetText(__currentSearchStr);
2409                         __pFindWordEditField->SetFocus();
2410                 }
2411                 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2412                 {
2413                         __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2414                         __pFindWordEditFieldRightToLeft->SetFocus();
2415                 }
2416
2417                 if (__currentSearchStr.GetLength() > 0)
2418                 {
2419                         StartWordSearch();
2420                 }
2421                 else
2422                 {
2423                         AppLogDebug("Enter something");
2424                 }
2425
2426                 if (__pWebViewer != null)
2427                 {
2428                         // releasing the set block
2429                         __pWebViewer->ReleaseBlock();
2430                 }
2431
2432         }
2433         break;
2434         case IDA_SHARE_TEXT_CLICKED:
2435         {
2436                 __pWebViewer->ReleaseBlock();
2437                 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2438                 if(__pPopUp != null)
2439                 {
2440                         delete __pPopUp;
2441                         __pPopUp = null;
2442                 }
2443                 if(__pAddressbar)
2444                 {
2445                         __pAddressbar->HideKeypad();
2446                 }
2447                 __pPopUp = new(std::nothrow) SharePopup();
2448                 __pPopUp->Initialize();
2449                 if (__pHitElementResult != null)
2450                 {
2451                         ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2452                         pShareInfo->SetPageTitle(L"");
2453                         pShareInfo->SetPageUrl(__currentSelectedStr);
2454                         pShareInfo->SetImageAttached(false);
2455                         __pPopUp->RemoveAllShareInfo();
2456                         __pPopUp->AddShareInfo(pShareInfo);
2457                         __pPopUp->SetShowState(true);
2458                         __pPopUp->Show();
2459                 }
2460         }
2461         break;
2462         case IDA_COPY_TEXT_CLICKED:
2463         {
2464                 __pWebViewer->ReleaseBlock();
2465                 // need to implement
2466                 //__currentSelectedStr
2467                 // Sets data to a clip board item
2468                 ClipboardItem item;
2469                 String resourcePath = App::GetInstance()->GetAppResourcePath();
2470                 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2471
2472                 // copying the item to clipboard
2473                 Clipboard* pClipboard = Clipboard::GetInstance();
2474                 if (pClipboard != null)
2475                 {
2476                         pClipboard->CopyItem(item);
2477                 }
2478         }
2479         break;
2480         case IDA_PASTE_TEXT_CLICKED:
2481         {
2482                 Clipboard* pClipboard = Clipboard::GetInstance();
2483
2484                 if(pClipboard == null)
2485                 {
2486                         return;
2487                 }
2488                 // Retrieves a latest item
2489                 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2490
2491                 if(pItem == null)
2492                 {
2493                         return;
2494                 }
2495                 //Gets data from the clipboard item
2496                 String* pString = dynamic_cast<String*>(pItem->GetData());
2497
2498                 if (pString != null)
2499                 {
2500                         String idElement = __pHitElementResult->GetAttributeValue(L"id");
2501                         String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2502                         String tagElement  = __pHitElementResult->GetTagName();
2503                         AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2504
2505                         String script;
2506                         if(idElement.GetLength() != 0)
2507                         {
2508                                 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;   }  } ";
2509                                 script.Append("insertAtCursor('");
2510                                 script.Append(idElement);
2511                                 script.Append("',");
2512                                 script.Append("\"");
2513                                 script.Append(*pString);
2514                                 script.Append("\");");
2515                         }
2516                         else if (nameElement.GetLength() != 0)
2517                         {
2518                                 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;   }  } ";
2519                                 script.Append("insertAtCursor(document.getElementsByName('");
2520                                 script.Append(nameElement);
2521                                 script.Append("')[0],");
2522                                 script.Append("\"");
2523                                 script.Append(*pString);
2524                                 script.Append("\");");
2525                         }
2526                         else//adding for twitter post page
2527                         {
2528                                 script = L"function insertAtCursor(myField, myValue) {  if (document.selection) {   document.getElementsByTagName(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.getElementsByTagName(myField)[0].value += myValue;   }  } ";
2529                                 script.Append("insertAtCursor(document.getElementsByTagName('");
2530                                 script.Append(tagElement);
2531                                 script.Append("')[0],");
2532                                 script.Append("\"");
2533                                 script.Append(*pString);
2534                                 script.Append("\");");
2535                         }
2536                         AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2537                         String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2538                         delete pStr;
2539                 }
2540                 delete pItem;
2541         }
2542         break;
2543         case IDA_GO_BACK:
2544         {
2545                 OnBackClicked();
2546         }
2547         break;
2548         case IDA_GO_FORWARD:
2549         {
2550                 OnForwardClicked();
2551         }
2552         break;
2553         case IDA_REFRESH_BTN_CLICKED:
2554         {
2555                 __isLoadingCompleted = false;
2556                 __isLoadingData = true;
2557                 __progressPercentage = 0;
2558                 __displayUrl = __pFooterUrlField->GetText();
2559
2560                 String url = __pFooterUrlField->GetText();
2561                 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2562 //              LoadUrl(url);
2563                 if (__pWebViewer != null && __pAddressbar != null)
2564                 {
2565                         __pWebViewer->Reload();
2566                         SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2567                 }
2568
2569                 //OnUrlSubmitted();
2570                 UpdateProgressBitmap();
2571         }
2572         break;
2573         case IDA_STOP_BTN_CLICKED:
2574         {
2575                 __isLoadingCompleted = false;
2576                 __isLoadingData = false;
2577                 __progressPercentage = 0;
2578                 __pFooterUrlField->HideKeypad();
2579                 __displayUrl = __pFooterUrlField->GetText();
2580
2581                 if (__pWebViewer)
2582                 {
2583                         //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2584                         SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2585                         __pWebViewer->StopLoading();
2586                         RequestRedraw(true);
2587                 }
2588
2589                 UpdateProgressBitmap();
2590         }
2591         break;
2592         case IDA_CLEAR_URL:
2593         {
2594                 if (__pFooterUrlField->GetText().IsEmpty() == false)
2595                 {
2596                         //__displayUrl = __pUrlField->GetText();
2597                         __pFooterUrlField->Clear();
2598
2599                 }
2600         }
2601         break;
2602         case IDA_READER_BTN_CLICKED:
2603         {
2604                 ReaderClicked();
2605         }
2606         break;
2607         default:
2608                 break;
2609         }
2610 }
2611
2612 void
2613 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2614 {
2615         AppLog("MainForm::OnFormBackRequested entered");
2616         result r = E_FAILURE;
2617         if(__pImageMenu && __pImageMenu->GetShowState() == true)
2618         {
2619                 AppLog("Hiding the menu");
2620                 __pImageMenu->SetShowState(false);
2621         }
2622         if (__pWebViewer && __pWebViewer->CanGoBack())
2623         {
2624                 __pWebViewer->GoBack();
2625         }
2626         else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2627         {
2628                 UiApp* pApp = null;
2629                 pApp = UiApp::GetInstance();
2630                 if (pApp != null)
2631                 {
2632                         r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2633                         if (IsFailed(r))
2634                         {
2635                                 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2636                                 return;
2637                         }
2638                 }
2639         }
2640         else
2641         {
2642                 UiApp* pApp = null;
2643                 WindowInfo* pWindowInfo = null;
2644                 int totalCount = 0;
2645                 SceneManager* pSceneManager = SceneManager::GetInstance();
2646                 if (pSceneManager == null)
2647                 {
2648                         return;
2649                 }
2650                 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2651                 if (pAllWindowList == NULL)
2652                 {
2653                         pApp = UiApp::GetInstance();
2654                         if (pApp != null)
2655                         {
2656                                 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2657                                 if (IsFailed(r))
2658                                 {
2659                                         AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2660                                         return;
2661                                 }
2662                         }
2663                 }
2664                 if (pAllWindowList != null)
2665                 {
2666                         totalCount = pAllWindowList->GetCount();
2667                 }
2668                 for (int count = 0; count < totalCount; count++)
2669                 {
2670                         pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2671                         if (pWindowInfo == null)
2672                         {
2673                                 pApp = UiApp::GetInstance();
2674                                 if (pApp != null)
2675                                 {
2676                                         r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2677                                         if (IsFailed(r))
2678                                         {
2679                                                 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2680                                                 return;
2681                                         }
2682                                 }
2683                         }
2684                         else
2685                         {
2686                                 if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2687                                 {
2688                                         r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2689                                         if (IsFailed(r))
2690                                         {
2691                                                 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2692                                                 return;
2693                                         }
2694                                         r = pAllWindowList->RemoveAt(count, true);
2695 //                                      __pWindowInfo = null;
2696                                         if (IsFailed(r))
2697                                         {
2698                                                 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2699                                                 return;
2700                                         }
2701                                         if(count > 0)
2702                                         {
2703                                                 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2704                                         }
2705                                         else
2706                                         {
2707                                                 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2708                                         }
2709                                         if (pWindowInfo == null)
2710                                         {
2711                                                 pApp = UiApp::GetInstance();
2712                                                 if (pApp != null)
2713                                                 {
2714                                                         r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2715                                                         return;
2716                                                 }
2717                                         }
2718                                         else
2719                                         {
2720                                                 if(pWindowInfo != null)
2721                                                         r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
2722                                                 if (IsFailed(r))
2723                                                 {
2724                                                         AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2725                                                         return;
2726                                                 }
2727                                         }
2728                                         break;
2729                                 }
2730 //                              else if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == false)
2731 //                              {
2732 //                                      UiApp* pApp = null;
2733 //                                      pApp = UiApp::GetInstance();
2734 //                                      if (pApp != null)
2735 //                                      {
2736 //                                              r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2737 //                                              if (IsFailed(r))
2738 //                                              {
2739 //                                                      AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2740 //                                                      return;
2741 //                                              }
2742 //                                      }
2743 //                              }
2744                         }
2745                 }
2746         }
2747         AppLog("MainForm::OnFormBackRequested exit");
2748 }
2749
2750 void
2751 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2752                 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2753 {
2754
2755         AppLog("MainForm::OnSceneActivatedN called");
2756         String* pSelectedScene = NULL;
2757         Object* pValue = NULL;
2758         String* pUrl = null;
2759         MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2760         pSelectedScene = (String*) pValue;
2761
2762         if (pSelectedScene != null)
2763         {
2764                 delete pSelectedScene;
2765         }
2766         MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2767         String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2768         AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2769         AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2770
2771         // setting the current scene ID
2772         MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2773
2774         MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2775
2776         if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2777         {
2778                 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2779                 if(__pWindowInfo == null)
2780                         return;
2781                 //              if(__pWindowInfo == null)
2782                 {
2783                         pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2784                 }
2785         }
2786         else if ( pArgs != null && pArgs->GetCount() == 1)
2787         {
2788                 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2789         }
2790
2791         InitFooter();
2792         InitAddressbar();
2793
2794         __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2795
2796         // hiding the address bar
2797         //      __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2798         __pAddressbar->SetShowState(false);
2799 //      if(__pWebViewer != null)
2800 //      {
2801 //              __pWebViewer->Resume();
2802 //      }
2803
2804         if(pUrl != null && pUrl->GetLength() > 0)
2805         {
2806                 LoadUrl(*pUrl);
2807         }
2808         else if(__pWindowInfo != null)
2809         {
2810                 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.Contains(IDSCN_MAIN_VIEW) == false)
2811                 {
2812                         LoadUrl(__pWindowInfo->pageUrl);
2813                 }
2814                 else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true)
2815                 {
2816                         LoadUrl(__pWindowInfo->pageUrl);
2817                         __pWindowInfo->isAppcontrolTriggered = false;
2818                 }
2819                 else if (__pWindowInfo->isJavascriptInitiated == true && __pWindowInfo->isFirstLaunch == true)
2820                 {
2821                         __pWindowInfo->isFirstLaunch = false;
2822                         AppLog("Called");
2823                         InitWebControl();
2824                         __pWindowInfo->pCurrentWeb = __pWebViewer;
2825                         if(__pWindowInfo->pageUrl.GetLength() > 0)
2826                                 LoadUrl(__pWindowInfo->pageUrl);
2827                 }
2828         }
2829
2830         String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2831         AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2832         if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2833         {
2834                 InitMostVisitedSitesView(GetOrientationStatus());
2835         }
2836         else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2837         {
2838                 if(__pMostVisitedListView != null)
2839                 {
2840                         __pMostVisitedListView->SetShowState(false);
2841                 }
2842         }
2843
2844         if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2845         {
2846                 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2847
2848                 if (pBookmarkUrl == null)
2849                         return;
2850                 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2851                 //__pAddressbar->SetUrl(*pBookmarkUrl);
2852                 SetUrl(*pBookmarkUrl);
2853
2854                 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2855                         __pWebViewer->LoadUrl(*pBookmarkUrl);
2856                 delete pBookmarkUrl;
2857         }
2858
2859         bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2860         Bitmap* pBitmap = null;
2861         if (isPrivateBrowsing == true)
2862         {
2863                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2864
2865                 if (__pWebViewer != null)
2866                 {
2867                         __pWebViewer->SetPrivateBrowsingEnabled(true);
2868                 }
2869
2870                 if (__pAddressbar != null)
2871                 {
2872                         //      __pAddressbar->UpdateFaviconBitmap(true);
2873                 }
2874
2875         }
2876         else
2877         {
2878                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2879
2880                 if (__pWebViewer != null)
2881                 {
2882                         __pWebViewer->SetPrivateBrowsingEnabled(false);
2883                 }
2884
2885                 if (__pAddressbar != null)
2886                 {
2887                         //      __pAddressbar->UpdateFaviconBitmap(false);
2888                 }
2889         }
2890
2891         if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2892         {
2893                 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2894         }
2895         else if (__pOptionMenu != null )
2896         {
2897                 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2898         }
2899
2900         if (pBitmap != null)
2901         {
2902                 delete pBitmap;
2903         }
2904
2905         RelayoutControls(false);
2906         AppLog("ABC: OnSceneActivatedN started exit");
2907
2908 }
2909
2910 void
2911 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2912                 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2913 {
2914         Canvas* pWebCanvas = null;
2915         if (__pWebViewer != null)
2916         {
2917                 pWebCanvas = __pWebViewer->GetCanvasN();
2918
2919         }
2920         if (pWebCanvas == null)
2921         {
2922                 return;
2923         }
2924         if (__pWindowInfo != null)
2925         {
2926                 if (__pWindowInfo->pWebCanvasBitmap != null)
2927                 {
2928                         delete __pWindowInfo->pWebCanvasBitmap;
2929                 }
2930                 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2931                 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2932                 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2933         }
2934         Bitmap* pBitmap = GetCapturedBitmapN();
2935         AppLog("Coming here");
2936         Canvas* pCanvas = new(std::nothrow) Canvas();
2937         pCanvas->Construct(GetClientAreaBounds());
2938         if(pBitmap != null)
2939         {
2940                 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2941                 delete pBitmap;
2942         }
2943         if(__pWebViewer != null && __pWindowInfo != null)
2944                 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2945
2946         WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2947         WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2948         delete pCanvas;
2949         delete pWebCanvas;
2950         if(__pAddressbar)
2951                 __pAddressbar->SetShowState(false);
2952         AppLog("Coming here");
2953 }
2954
2955 bool
2956 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2957                 const Tizen::Base::String& realm,
2958                 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2959 {
2960         return false;
2961 }
2962
2963 void
2964 MainForm::OnHttpAuthenticationCanceled(void)
2965 {
2966 }
2967
2968 void
2969 MainForm::OnLoadingStarted(void)
2970 {
2971         AppLogDebug("MainForm::OnLoadingStarted entered");
2972         __isLoaded = true;
2973         if(__pAddressbar == NULL || __pWebViewer == null)
2974         {
2975                 return;
2976         }
2977
2978         // this is added in case if menu is opened and user load the page
2979         if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2980         {
2981                 __pOptionMenu->SetShowState(false);
2982                 __pOptionMenu->Invalidate(true);
2983         }
2984
2985
2986
2987         if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2988         {
2989                 __pImageMenu->SetShowState(false);
2990                 __pImageMenu->Invalidate(true);
2991         }
2992         String url = __pWebViewer->GetUrl();
2993         if(url.Contains(IDS_TIZEN_SERVICE))
2994         {
2995                 String appId;
2996                 String delim(L":;,");
2997
2998                 // Creates a StringTokenizer instance
2999                 StringTokenizer strTok(url, delim);
3000
3001                 int count = strTok.GetTokenCount();     // count == 4
3002
3003                 HashMap *pMap = new HashMap();
3004                 pMap->Construct();
3005                 String token;
3006                 String key;
3007                 String value;
3008                 while (strTok.HasMoreTokens())
3009                 {
3010                         AppLog("Token: %ls", token.GetPointer());
3011                         strTok.GetNextToken(token);         // Tizen, StringTokenizer, Sample, code
3012                         if(token.Contains(IDS_APPID))
3013                         {
3014                                 token.SubString(6, appId);
3015                                 AppLog("AppID:%ls", appId.GetPointer());
3016                         }
3017                         else if(token.Contains(IDS_KEY))
3018                         {
3019                                 token.SubString(4, key);
3020                                 AppLog("key:%ls", key.GetPointer());
3021                         }
3022                         else if(token.Contains(IDS_VALUE))
3023                         {
3024                                 token.SubString(6, value);
3025                                 AppLog("value:%ls", value.GetPointer());
3026                         }
3027                 }
3028                 pMap->Add(key, value);
3029
3030                 if(appId != "")
3031                 {
3032                         AppControl *pAppControl = null;
3033                         String operationId = L"http://tizen.org/appcontrol/operation/main";
3034                         pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3035                         if(pAppControl)
3036                         {
3037                                 AppLog("Starting AppControl");
3038                                 result r = pAppControl->Start(null, null, pMap, null);
3039                                 AppLog("Result of Start %s", GetErrorMessage(r));
3040                         }
3041                         else
3042                         {
3043                                 AppLogException("AppControl not found");
3044                         }
3045                         return;
3046                 }
3047         }
3048         if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3049         {
3050                 __pAddressbar->SetShowState(false);
3051                 AddressBarCancelledClicked(*__pAddressbar);
3052                 __pAddressbar->Invalidate(true);
3053         }
3054         Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
3055         if(pBitmap != null)
3056         {
3057                 __pAddressbar->SetFaviconBitmap(*pBitmap);
3058         }
3059         delete pBitmap;
3060         if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
3061         {
3062                 // updating the address bar position with respect to web control
3063                 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
3064                 __distanceMoved = 0;
3065                 MoveUiControls();
3066         }
3067
3068         //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3069         SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3070         if (__pWebViewer != null)
3071         {
3072                 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
3073                 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
3074                 SetUrl(__pWebViewer->GetUrl());
3075                 if (__pWindowInfo != NULL)
3076                 {
3077                         // resetting the page title to blank, it will be received in OnPageTitleReceived()
3078                         __pWindowInfo->pageTitle = L"";
3079                         __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3080                 }
3081                 __pAddressbar->Invalidate(true);
3082         }
3083
3084 }
3085
3086 void
3087 MainForm::OnLoadingCanceled(void)
3088 {
3089
3090 }
3091
3092
3093 void
3094 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
3095 {
3096         AppLog("XYZ::MainForm::OnKeypadWillOpen");
3097
3098 }
3099
3100 void
3101 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
3102 {
3103         AppLog("XYZ::MainForm::OnKeypadOpened");
3104         __isKeypadOpened = true;
3105         __pFooterPanel->SetShowState(false);
3106
3107 }
3108
3109 void
3110 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3111 {
3112         AppLog("XYZ::MainForm::OnKeypadClosed");
3113         __isKeypadOpened = false;
3114         __pFooterPanel->SetShowState(true);
3115         RelayoutControls(true);
3116 }
3117
3118 void
3119 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3120 {
3121         AppLog("XYZ::KeypadBoundsChanged");
3122         RelayoutControls(false);
3123 }
3124
3125 void
3126 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3127                 const Tizen::Base::String& reason)
3128 {
3129         AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3130 }
3131
3132 void
3133 MainForm::OnLoadingCompleted(void)
3134 {
3135         AppLog("MainForm::OnLoadingCompleted start");
3136         DateTime date;
3137         result r = E_SUCCESS;
3138
3139         if (__pWebViewer == null)
3140         {
3141                 return;
3142         }
3143
3144         if (__pAddressbar == null)
3145         {
3146                 return;
3147         }
3148
3149         if(__pImageMenu && __pImageMenu->GetShowState())
3150         {
3151                 __pImageMenu->SetShowState(false);
3152                 __pImageMenu->Invalidate(true);
3153         }
3154
3155         if (__pWebViewer->CanGoForward())
3156         {
3157                 //__pAddressbar->SetForwardButtonEnabled(true);
3158                 SetForwardButtonEnabled(true);
3159         }
3160         else
3161         {
3162                 //__pAddressbar->SetForwardButtonEnabled(false);
3163                 SetForwardButtonEnabled(false);
3164         }
3165
3166         /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3167         {
3168                 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3169
3170                 //__pAddressbar->UpdateProgress(0);
3171                 UpdateProgress(0);
3172         }*/
3173
3174         if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3175         {
3176                 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3177                 UpdateProgress(0);
3178         }
3179
3180         AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3181         bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3182         if (isPrivateBrowsing == false)
3183         {
3184                 if(__pHistory != null)
3185                 {
3186                         delete __pHistory;
3187                         __pHistory = null;
3188                 }
3189
3190                 __pHistory = new(std::nothrow) History;
3191                 HistoryPresentationModel::GetCurrentDateTime(date);
3192                 if (__pWindowInfo)
3193                 {
3194                         __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3195                         AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3196
3197                         __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3198                         AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3199                 }
3200                 __pHistory->SetVisitedTime(date);
3201
3202                 if (__pWebViewer != null)
3203                 {
3204                         AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3205
3206                         Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3207                         if (pTempBitmap != null)
3208                         {
3209                                 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3210                                 __pHistory->SetFavIconBitmap(*pTempBitmap);
3211                         }
3212
3213                         AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3214                 }
3215
3216                 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3217                 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3218                 if ( pCanvas != null &&  pCanvas != null && pBitmap != null)
3219                 {
3220                         pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3221                         pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3222                         __pHistory->SetThumbnail(pBitmap);
3223                 }
3224                 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3225                 if (pFavIcon)
3226                 {
3227                         __pHistory->SetFavIconBitmap(*pFavIcon);
3228                         delete pFavIcon;
3229                 }
3230
3231                 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3232                 //delete pHistory;
3233         }
3234         else
3235         {
3236                 return;
3237         }
3238 //      if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3239         {
3240                 // temperary fixed (webpage can be not loaded)
3241                 UpdateFavicon();
3242         }
3243
3244         bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3245         if (isReaderEnabled == true)
3246         {
3247                 if (__pReaderData)
3248                 {
3249                         delete __pReaderData;
3250                         __pReaderData = null;
3251                 }
3252                 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3253                 filePath.Append(L"data/reader.js");
3254                 File file;
3255                 char buffer[10];
3256                 char buffer2[5];
3257                 int i;
3258                 int readCnt;
3259                 result r = E_SUCCESS;
3260                 FileAttributes attr;
3261
3262                 File::GetAttributes(filePath,attr);
3263                 // Creates file
3264                 r = file.Construct(filePath, L"r+");
3265                 if (IsFailed(r))
3266                 {
3267                         AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3268                         return;
3269                 }
3270                 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3271                 if(pScript == null)
3272                 {
3273                         AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3274                         return;
3275                 }
3276 //              file.Read(pScript,attr.GetFileSize());
3277 //
3278 //              AppLogDebug("scipt length %d",strlen(pScript));
3279                 String strScript = L"";
3280 //              strScript.Append(pScript);
3281 //              for(int i=0; i<25; i++)
3282                 {
3283                         file.Read(pScript,attr.GetFileSize());
3284 //                      AppLog("xyzz tell %d",file.Tell());
3285 //                      r = strScript.Append(pScript);
3286 //                      AppLog("xyzz append result %s",GetErrorMessage(r));
3287 //                      AppLog("xyzz strScript length %d",strScript.GetLength());
3288                 }
3289 //              AppLog("xyzz final strScript length %d",strScript.GetLength());
3290
3291                 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3292                 if (__pReaderData == null)
3293                 {
3294                         AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3295                         __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>");
3296 //                      return;
3297                 }
3298                 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3299                 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3300                 {
3301                         //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3302                         SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3303                 }
3304                 delete[] pScript;
3305         }
3306
3307
3308         AppLog("MainForm::OnLoadingCompleted done");
3309 }
3310
3311 void
3312 MainForm::OnEstimatedProgress(int progress)
3313 {
3314         AppLogDebug("MainForm::OnEstimatedProgress entered %d",progress);
3315
3316         if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3317                 progress = DEFAULT_PROGRESS_PERCENTAGE;
3318         //if(__pAddressbar)
3319         //      __pAddressbar->UpdateProgress(progress);
3320         UpdateProgress(progress);
3321 }
3322
3323 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3324 {
3325         AppLog("MainForm::OnFaviconReceived");
3326         if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3327         {
3328                 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3329                 if(favIcon != null)
3330                 {
3331                         HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3332                         delete favIcon;
3333                 }
3334         }
3335 }
3336
3337 void
3338 MainForm::OnUrlValueChanged(Addressbar&)
3339 {
3340         Invalidate(true);
3341 }
3342
3343 void
3344 MainForm::OnUrlSubmitted(Addressbar& addBar)
3345 {
3346         AppLog("MainForm::OnUrlSubmitted");
3347         String url = addBar.GetUrl();
3348         AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3349
3350         if(__pFooterUrlField)
3351                 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3352         AddressBarCancelledClicked(*__pAddressbar);
3353         LoadUrl(url);
3354 }
3355
3356 void
3357 MainForm::LoadUrl(String& url)
3358 {
3359         url.Trim();
3360         String encodedUrl;
3361 //      UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3362         AppLogDebug("MainForm::LoadUrl enter");
3363
3364         if (__pWebViewer != null)
3365         {
3366                 __pWebViewer->SetShowState(true);
3367                 __pWebViewer->Invalidate(true);
3368         }
3369
3370         if (url.CompareTo(L"") == 0)
3371         {
3372                 return;
3373         }
3374         if(__pFooterPanel != null)
3375         {
3376                 __pFooterPanel->SetShowState(true);
3377                 __pFooterPanel->Invalidate(true);
3378         }
3379         InitWebControl();
3380
3381         bool ret = false;
3382         bool flag = false;
3383
3384         String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3385         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)
3386
3387         RegularExpression firstRegex;
3388         RegularExpression secondRegex;
3389
3390         firstRegex.Construct(firstPattern, REGEX_CASELESS);
3391         secondRegex.Construct(secondPattern, REGEX_CASELESS);
3392
3393         // Match
3394         ret = firstRegex.Match(url, false); // This returns true value
3395         flag = secondRegex.Match(url, false);  // Checks whether URL typed is of type  abc.com (i.e without protocol in front of it)
3396
3397         if (ret == true && __pWebViewer != null)
3398         {
3399                 SetUrl(url);
3400                 __pWebViewer->LoadUrl(url);
3401         }
3402         else if(__pWebViewer != null)
3403         {
3404                 String tempUrl = L"http://";
3405                 tempUrl.Append(url);
3406
3407                 if (flag == true)
3408                 {
3409                         __pWebViewer->LoadUrl(tempUrl);
3410                 }
3411                 else
3412                 {
3413                                 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3414                         __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3415                 }
3416         }
3417         if (__pAddressbar != null)
3418         {
3419                 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3420                 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3421         }
3422
3423         AppLogDebug("MainForm::LoadUrl exit");
3424
3425         return;
3426
3427 }
3428
3429 void
3430 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
3431 {
3432         AppLog("MainForm::OnFocusGained");
3433         if(__pFooterPanel)
3434         {
3435                 __pFooterPanel->SetShowState(false);
3436         }
3437
3438         if(__pAddressbar)
3439         {
3440                 __pAddressbar->SetShowState(true);
3441                 __pAddressbar->SetAddressbarURLFocus();
3442         }
3443         if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3444         {
3445                 __currentSearchStr = L"";
3446                 __currentWordIndex = 0;
3447                 __maxOccurrances = 0;
3448
3449                 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
3450                 {
3451                         __pFindWordEditField->SetText(L"");
3452                         __pFindWordEditField->HideKeypad();
3453                         __pFindWordControl->SetShowState(false);
3454                         __pFindWordCountLabel->SetText(L"0/0");
3455                 }
3456                 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
3457                 {
3458                         __pFindWordEditFieldRightToLeft->SetText(L"");
3459                         __pFindWordEditFieldRightToLeft->HideKeypad();
3460                         __pFindWordControl->SetShowState(false);
3461                         __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3462                 }
3463
3464                 __pFindWordNext->SetEnabled(false);
3465                 __pFindWordPrev->SetEnabled(false);
3466
3467                 __pWebViewer->SearchTextAllAsync(L"",true);
3468                 __pFindWordControl->SetShowState(false);
3469         }
3470         RelayoutControls(false);
3471 }
3472
3473 void
3474 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3475 {
3476         AppLog("MainForm::OnFocusLost called");
3477 }
3478
3479 void
3480 MainForm::OnStopClicked(Addressbar& addBar)
3481 {
3482         AppLogDebug("MainForm::OnStopClicked called");
3483         if (__pWebViewer)
3484         {
3485                 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3486                 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3487                 __pWebViewer->StopLoading();
3488                 RequestRedraw(true);
3489         }
3490 }
3491
3492 void
3493 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3494 {
3495         //      AppLog("MainForm::OnBackClicked");
3496         result r = E_FAILURE;
3497         if(__pImageMenu && __pImageMenu->GetShowState() == true)
3498         {
3499                 AppLog("Hiding the menu");
3500                 __pImageMenu->SetShowState(false);
3501         }
3502
3503         if (__pWebViewer && __pWebViewer->CanGoBack())
3504         {
3505                 __pWebViewer->GoBack();
3506         }
3507         else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3508         {
3509                 UiApp* pApp = null;
3510                 pApp = UiApp::GetInstance();
3511                 if (pApp != null)
3512                 {
3513                         r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3514                         if (IsFailed(r))
3515                         {
3516                                 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3517                                 return;
3518                         }
3519                 }
3520         }
3521         else
3522         {
3523                 UiApp* pApp = null;
3524                 WindowInfo* pWindowInfo = null;
3525                 int totalCount = 0;
3526                 SceneManager* pSceneManager = SceneManager::GetInstance();
3527                 if (pSceneManager == null)
3528                 {
3529                         return;
3530                 }
3531                 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3532                 if (pAllWindowList == NULL)
3533                 {
3534                         pApp = UiApp::GetInstance();
3535                         if (pApp != null)
3536                         {
3537                                 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3538                                 if (IsFailed(r))
3539                                 {
3540                                         AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3541                                         return;
3542                                 }
3543                         }
3544                 }
3545                 if (pAllWindowList != null)
3546                 {
3547                         totalCount = pAllWindowList->GetCount();
3548                 }
3549                 for (int count = 0; count < totalCount; count++)
3550                 {
3551                         pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3552                         if (pWindowInfo == null)
3553                         {
3554                                 pApp = UiApp::GetInstance();
3555                                 if (pApp != null)
3556                                 {
3557                                         r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3558                                         if (IsFailed(r))
3559                                         {
3560                                                 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3561                                                 return;
3562                                         }
3563                                 }
3564                         }
3565                         if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3566                         {
3567                                 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3568                                 if (IsFailed(r))
3569                                 {
3570                                         AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3571                                         return;
3572                                 }
3573                                 r = pAllWindowList->RemoveAt(count, true);
3574                                 __pWindowInfo = null;
3575                                 if (IsFailed(r))
3576                                 {
3577                                         AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3578                                         return;
3579                                 }
3580                                 if(count > 0)
3581                                 {
3582                                         pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3583                                 }
3584                                 else if(pAllWindowList->GetCount() > 0)
3585                                 {
3586                                         pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3587                                 }
3588                                 else
3589                                 {
3590                                         pApp = UiApp::GetInstance();
3591                                         if (pApp != null)
3592                                         {
3593                                                 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3594                                                 return;
3595                                         }
3596
3597                                 }
3598                                 if (pWindowInfo == null)
3599                                 {
3600                                         pApp = UiApp::GetInstance();
3601                                         if (pApp != null)
3602                                         {
3603                                                 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3604                                                 return;
3605                                         }
3606                                 }
3607                                 else
3608                                 {
3609                                         r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
3610 //                                      r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3611                                         if (IsFailed(r))
3612                                         {
3613                                                 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3614                                                 return;
3615                                         }
3616                                 }
3617                                 break;
3618                         }
3619
3620                 }
3621
3622         }
3623
3624 }
3625
3626 void
3627 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3628 {
3629         AppLog("MainForm::OnForwardClicked");
3630         if (__pWebViewer == null)
3631                 return;
3632
3633         if (__pWebViewer->CanGoForward())
3634         {
3635                 __pWebViewer->GoForward();
3636         }
3637 }
3638
3639 void
3640 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3641 {
3642         AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3643         if(__pFooterPanel != null)
3644         {
3645                 __pFooterPanel->SetShowState(false);
3646         }
3647
3648         if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3649         {
3650                 __pAddressbar->SetShowState(true);
3651                 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3652         }
3653
3654         RelayoutControls(false);
3655 }
3656
3657 void
3658 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3659 {
3660         AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3661
3662         int Height = GetClientAreaBounds().height;
3663         AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3664
3665         RelayoutControls(false);
3666 }
3667
3668 void
3669 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3670 {
3671         AddressBarCancelledClicked(addBar);
3672 }
3673
3674 void
3675 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3676 {
3677         __prevAddressBarMode = __curAddressBarMode;
3678
3679         if (__pAddressbar != null)
3680         {
3681                 __curAddressBarMode = GetAddressbarMode();
3682         }
3683
3684         if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3685         {
3686                 __adressPanelPosition.y = 0;
3687                 if (__pAddressbar != null)
3688                 {
3689                         __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3690                         __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3691                         __pAddressbar->Invalidate(true);
3692                 }
3693                 if (__pWebViewer != null)
3694                 {
3695                         __pWebViewer->StopLoading();
3696                 }
3697         }
3698         else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3699         {
3700                 __adressPanelPosition.y = 0;
3701                 if (__pAddressbar != null)
3702                 {
3703                         __webControlPosition.y = 0;
3704                         __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3705                         __pAddressbar->Invalidate(true);
3706                 }
3707         }
3708 }
3709
3710 void
3711 MainForm::OnClipboardClosed(const Addressbar& addBar)
3712 {
3713         AppLog("XYZ::MainForm::OnClipboardClosed");
3714         if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3715         {
3716                 AppLog("akjshdasd 3");
3717                 __pFooterPanel->SetShowState(true);
3718         }
3719         __isKeypadOpened = false;
3720         RelayoutControls(false);
3721 }
3722
3723 void
3724 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3725 {
3726         AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3727         if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3728         {
3729                 AppLog("akjshdasd 3");
3730                 __pFooterPanel->SetShowState(true);
3731         }
3732         __isKeypadOpened = false;
3733
3734         RelayoutControls(false,footerState);
3735 }
3736
3737 void
3738 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3739 {
3740         AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3741         __isKeypadOpened = true;
3742         RelayoutControls(false);
3743 }
3744
3745 void
3746 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3747 {
3748         __isKeypadOpened = true;
3749         __pFooterPanel->SetShowState(false);
3750 }
3751
3752 void
3753 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3754 {
3755         AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3756         RelayoutControls(false);
3757 }
3758
3759 void
3760 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3761 {
3762         AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3763         if (__pWindowInfo)
3764         {
3765                 __pWindowInfo->pageTitle = title;
3766                 if (__pWebViewer != null)
3767                 {
3768                         __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3769                         AppLog("MainForm::OnPageTitleReceived url %ls",__pWindowInfo->pageUrl.GetPointer());
3770                 }
3771         }
3772         if (__pAddressbar != null && __pWebViewer != null)
3773         {
3774                 SetUrl(__pWebViewer->GetUrl());
3775                 __pAddressbar->Invalidate(true);
3776         }
3777 }
3778
3779 void
3780 MainForm::UpdateFavicon(void)
3781 {
3782         bool urlImageType = false;
3783         String *tempPath = null;
3784         if(__pWebViewer)
3785                 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();");
3786         Bitmap* pBitmap = null;
3787
3788         if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3789         {
3790                 if (__pWindowInfo != null)
3791                 {
3792                         Uri url;
3793                         url.SetUri(*tempPath);
3794                         if (url.GetHost().GetLength() == 0)
3795                         {
3796                                 Uri webUrl;
3797                                 if(__pWebViewer)
3798                                         webUrl.SetUri(__pWebViewer->GetUrl());
3799                                 result r = url.SetHost(webUrl.GetHost());
3800                                 if(IsFailed(r))
3801                                 {
3802                                         delete tempPath;
3803                                         return;
3804                                 }
3805                         }
3806                         if (url.GetScheme().GetLength() == 0)
3807                         {
3808                                 Uri webUrl;
3809                                 if(__pWebViewer)
3810                                         webUrl.SetUri(__pWebViewer->GetUrl());
3811                                 url.SetScheme(webUrl.GetScheme());
3812                         }
3813                         __pWindowInfo->faviconUrl = url.ToString();
3814
3815                         pBitmap = __pWebViewer->GetFaviconN();
3816
3817                         if (pBitmap != null)
3818                         {
3819                                 if (__pWindowInfo->pFavicon != NULL)
3820                                 {
3821                                         __pWindowInfo->pFavicon = null;
3822                                 }
3823                                 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3824                                 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3825
3826                                 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3827
3828                                 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3829                         }
3830                         else if(__pWindowInfo->pFavicon != null)
3831                         {
3832                                 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3833                         }
3834                         else
3835                         {
3836                                 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3837                                 if(pDefaultBmp != null)
3838                                 {
3839                                         __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3840                                 }
3841                         }
3842                         if(pBitmap)
3843                         {
3844                                 delete pBitmap;
3845                                 pBitmap = null;
3846                         }
3847                 }
3848                 delete tempPath;
3849         }
3850         else
3851         {
3852                 // do not remove
3853                 if(tempPath != null)
3854                 {
3855                         delete tempPath;
3856                 }
3857                 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3858         }
3859
3860 }
3861
3862 bool
3863 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3864                 Tizen::Web::Controls::WebNavigationType type)
3865 {
3866         AppLog("urlk %ls",url.GetPointer());
3867         // when load new page if find word panel is open its show state is false
3868         if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3869         {
3870                 __currentSearchStr = L"";
3871                 __currentWordIndex = 0;
3872                 __maxOccurrances = 0;
3873                 __pFindWordEditField->SetText(L"");
3874                 __pFindWordNext->SetEnabled(false);
3875                 __pFindWordPrev->SetEnabled(false);
3876                 __pFindWordCountLabel->SetText(L"0/0");
3877                 __pFindWordControl->SetShowState(false);
3878                 __pFindWordEditField->HideKeypad();
3879                 RelayoutControls(false);
3880         }
3881
3882         __pFooterPanel->Invalidate(true);
3883
3884         Uri uriInfo;
3885         uriInfo.SetUri(url);
3886
3887         if(url.Contains(IDS_TIZEN_SERVICE))
3888         {
3889                 String appId;
3890                 String delim(L":;,");
3891
3892                 // Creates a StringTokenizer instance
3893                 StringTokenizer strTok(url, delim);
3894
3895                 int count = strTok.GetTokenCount();     // count == 4
3896
3897                 HashMap *pMap = new HashMap();
3898                 pMap->Construct();
3899
3900                 String token;
3901                 String key;
3902                 String value;
3903                 while (strTok.HasMoreTokens())
3904                 {
3905                         AppLog("Token: %ls", token.GetPointer());
3906                         strTok.GetNextToken(token);         // Tizen, StringTokenizer, Sample, code
3907                         if(token.Contains(IDS_APPID))
3908                         {
3909                                 token.SubString(6, appId);
3910                                 AppLog("AppID:%ls", appId.GetPointer());
3911                         }
3912                         else if(token.Contains(IDS_KEY))
3913                         {
3914                                 token.SubString(4, key);
3915                                 AppLog("key:%ls", key.GetPointer());
3916                         }
3917                         else if(token.Contains(IDS_VALUE))
3918                         {
3919                                 token.SubString(6, value);
3920                                 AppLog("value:%ls", value.GetPointer());
3921                         }
3922                 }
3923                 pMap->Add(key, value);
3924
3925                 if(appId != "")
3926                 {
3927                         AppControl *pAppControl = null;
3928                         String operationId = L"http://tizen.org/appcontrol/operation/main";
3929                         pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3930                         if(pAppControl)
3931                         {
3932                                 result r = pAppControl->Start(null, null, pMap, null);
3933                         }
3934                         else
3935                         {
3936                                 AppLogException("AppControl not found");
3937                         }
3938                         return true;
3939                 }
3940         }
3941
3942         return false;
3943 }
3944
3945 DecisionPolicy
3946 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3947                 const Tizen::Net::Http::HttpHeader& httpHeader)
3948 {
3949         return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3950 }
3951
3952 void
3953 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
3954 {
3955         AppLog("MainForm::OnWebPageBlockSelected");
3956 //      if(__isLongPressedDone == false)
3957 //              return;
3958
3959         if (__pHitElementResult != null)
3960         {
3961                 delete __pHitElementResult;
3962                 __pHitElementResult = null;
3963         }
3964
3965         if (__pWebViewer != null)
3966         {
3967                 AppLog("MainForm::OnWebPageBlockSelected web not null");
3968                 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3969
3970                 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
3971                 {
3972                         AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3973                         __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3974                         if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
3975                         {
3976                                 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3977                         }
3978                         AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3979                 }
3980         }
3981
3982         if (__pHitElementResult == null)
3983         {
3984                 return;
3985         }
3986
3987         if (__pHitElementResult->HasImage() != true)
3988         {
3989                 String tagName = __pHitElementResult->GetTagName();
3990                 String type = __pHitElementResult->GetAttributeValue("type");
3991
3992
3993                 AppLog("TagName %ls",tagName.GetPointer());
3994                 __currentSelectedStr.Clear();
3995                 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3996                 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3997                 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3998                 if(tagName.Equals(L"TEXTAREA",false) == true)
3999                 {
4000                         AppLog("Tagnameseemstobe TEXTAREA");
4001                 }
4002                 else if(tagName.Equals(L"INPUT",false) == true)
4003                 {
4004                         AppLog("Tagnameseemstobe INPUT");
4005                 }
4006
4007                 if (((tagName.Equals(L"INPUT",false) == true)  || tagName.Equals(L"TEXTAREA",false) == true) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
4008                 {
4009                         AppLog("MainForm::OnWebPageBlockSelected show paste option");
4010
4011                         InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true);
4012                         if(__pImageMenu)
4013                         {
4014                                 __pImageMenu->SetShowState(true);
4015                                 __pImageMenu->Show();
4016                                 __pImageMenu->Invalidate(true);
4017                         }
4018                 }
4019                 else /*if(__isLongPressedDone == true)*/
4020                 {
4021                         AppLog("MainForm::OnWebPageBlockSelected no paste option");
4022
4023                         if(__pHitElementResult->GetUrl().GetLength() > 0)
4024                         {
4025                                 __currentSelectedStr.Clear();
4026                                 __currentSelectedStr = __pHitElementResult->GetUrl();
4027                         }
4028                         InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false);
4029                         if(__pImageMenu)
4030                         {
4031                                 __pImageMenu->SetShowState(true);
4032                                 __pImageMenu->Show();
4033                                 __pImageMenu->Invalidate(true);
4034                         }
4035                 }
4036
4037                 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
4038                 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
4039                 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
4040         }
4041
4042 }
4043
4044 void
4045 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
4046 {
4047
4048 }
4049
4050 Web*
4051 MainForm::OnWebWindowCreateRequested(void)
4052 {
4053         AppLog("MainForm::OnWebWindowCreateRequested entered");
4054         WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4055
4056         if (pNewWindowInfo == null)
4057         {
4058                 return null;
4059         }
4060         result r = E_SUCCESS;
4061         SceneManager* pSceneManager = SceneManager::GetInstance();
4062         if (pSceneManager == NULL)
4063         {
4064                 return null;
4065         }
4066         ArrayList* pArgList = new(std::nothrow) ArrayList();
4067         if (pArgList == NULL)
4068         {
4069                 return null;
4070         }
4071         r = pArgList->Construct();
4072         if (r == E_SUCCESS)
4073         {
4074                 pNewWindowInfo->isJavascriptInitiated = true;
4075                 pArgList->Add(*pNewWindowInfo);
4076                 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4077                 delete pArgList;
4078                 if (IsFailed(r))
4079                 {
4080                         AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
4081                         return null;
4082                 }
4083         } else {
4084                 delete pArgList;
4085         }
4086
4087         return pNewWindowInfo->pCurrentWeb;
4088 }
4089
4090 void
4091 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
4092 {
4093         AppLog("xyz:: MainForm::RelayoutControls called");
4094         __webControlPosition.y = 0;
4095         __webControlHeight = GetClientAreaBounds().height;
4096         AppLog("Client area height: %d", __webControlHeight);
4097
4098         AppLog("Client area height: %d", __webControlHeight);
4099         if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
4100         {
4101                 __webControlPosition.y += __pAddressbar->GetHeight();
4102                 __webControlHeight -= __pAddressbar->GetHeight();
4103                 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
4104         }
4105         else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
4106         {
4107                 __webControlPosition.y += __pFindWordControl->GetHeight();
4108                 __webControlHeight -= __pFindWordControl->GetHeight();
4109                 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4110         }
4111
4112         if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4113         {
4114                 __webControlHeight -= __pFooterPanel->GetHeight();
4115
4116                 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
4117                 __webControlHeight = __webControlHeight + 12;
4118         }
4119         if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4120         {
4121                 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight )
4122                 {
4123                 }
4124                 else
4125                 {
4126                         __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight );
4127                         AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
4128                         __pWebViewer->Invalidate(false);
4129                 }
4130         }
4131         if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4132         {
4133                 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4134         }
4135
4136         Invalidate(true);
4137 }
4138
4139 void
4140 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4141 {
4142         if (__pFindWordControl == null)
4143         {
4144                 return;
4145         }
4146
4147         Tizen::Locales::LocaleManager localeManager;
4148         Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4149
4150         String languageCode;
4151         result r = SettingInfo::GetValue(L"Language", languageCode);
4152         // int languagecode = local.GetLanguageCode();
4153         AppLog("rahul language is %S", languageCode.GetPointer());
4154
4155         if (show == true)
4156         {
4157                 InitFindWordPanel();
4158
4159                 if (languageCode.CompareTo("ara") == 0)
4160                 {
4161                         AppLog("rahul language is arabic");
4162
4163                         __pFindWordPanelLeftToRight->SetShowState(false);
4164                         __pFindWordPanelRightToLeft->SetShowState(true);
4165
4166                         __pFindWordClear->SetShowState(false);
4167                         __pFindWordCountLabel->SetShowState(false);
4168                         __pFindWordEditField->SetShowState(false);
4169
4170                         __pFindWordClearRightToLeft->SetShowState(true);
4171                         __pFindWordCountLabelRightToLeft->SetShowState(true);
4172                         __pFindWordEditFieldRightToLeft->SetShowState(true);
4173                 }
4174                 else
4175                 {
4176                         AppLog("rahul language is not arabic");
4177
4178
4179                         __pFindWordPanelLeftToRight->SetShowState(true);
4180                         __pFindWordPanelRightToLeft->SetShowState(false);
4181
4182                         __pFindWordClear->SetShowState(true);
4183                         __pFindWordCountLabel->SetShowState(true);
4184                         __pFindWordEditField->SetShowState(true);
4185
4186                         __pFindWordClearRightToLeft->SetShowState(false);
4187                         __pFindWordCountLabelRightToLeft->SetShowState(false);
4188                         __pFindWordEditFieldRightToLeft->SetShowState(false);
4189                 }
4190                 __pFindWordControl->SetShowState(true);
4191         }
4192         else
4193         {
4194                 if(__pFindWordControl != null)
4195                 {
4196                         __pFindWordControl->SetShowState(false);
4197                 }
4198         }
4199
4200         AppLog("MainForm::ShowFindWordPanel %d",show);
4201         if (show && !isTouchPressed)
4202         {
4203                 if (languageCode.CompareTo("ara") == 0)
4204                 {
4205                         if (__pFindWordEditFieldRightToLeft)
4206                         {
4207                                 __pFindWordEditFieldRightToLeft->SetFocus();
4208                                 __pFindWordEditFieldRightToLeft->ShowKeypad();
4209                         }
4210                 }
4211                 else
4212                 {
4213                         if (__pFindWordEditField)
4214                         {
4215                                 __pFindWordEditField->SetFocus();
4216                                 __pFindWordEditField->ShowKeypad();
4217                         }
4218                 }
4219         }
4220         else
4221         {
4222                 if (languageCode.CompareTo("ara") == 0)
4223                 {
4224                         if (__pFindWordEditFieldRightToLeft)
4225                                 __pFindWordEditFieldRightToLeft->HideKeypad();
4226                 }
4227                 else
4228                 {
4229                         if (__pFindWordEditField)
4230                                 __pFindWordEditField->HideKeypad();
4231                 }
4232         }
4233
4234         RelayoutControls(false);
4235 }
4236
4237 void
4238 MainForm::StartWordSearch()
4239 {
4240         //Get the count of occurances of the word in the current page
4241         __maxOccurrances = 0;
4242         __currentWordIndex = 0;
4243
4244         __pFindWordPrev->SetEnabled(false);
4245         String *pCountStr = null;
4246         result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4247         AppLog("Search Result %s",GetErrorMessage(r));
4248         /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/"  + __currentSearchStr + "/gi).length;");
4249         if (pCountStr != null)
4250         {
4251                 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4252                 delete pCountStr;
4253         }
4254
4255         AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4256          */
4257
4258 }
4259
4260 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4261 {
4262         AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4263         AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4264
4265         if(totalCount == -1 || totalCount == 0)
4266         {
4267                 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4268                 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4269 //              return;
4270         }
4271         else if(totalCount > 100)
4272         {
4273                 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4274                 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4275         }
4276         else
4277         {
4278                 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4279                 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4280         }
4281
4282         __maxOccurrances = totalCount;
4283         __currentWordIndex = currentOrdinal;
4284
4285         //Reset the UI controls as per the maxOccurrance value
4286         if (totalCount <= 0)
4287         {
4288                 AppLog("Word not found");
4289                 //Show error notification to user
4290                 __pFindWordNext->SetEnabled(false);
4291                 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4292                 {
4293                         __pFindWordCountLabel->SetText(L"0/0");
4294                         __pFindWordCountLabel->Invalidate(false);
4295                 }
4296                 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4297                 {
4298                         __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4299                         __pFindWordCountLabelRightToLeft->Invalidate(false);
4300                 }
4301                 __pFindWordNext->Invalidate(false);
4302                 __pFindWordPrev->Invalidate(false);
4303
4304                 return;
4305         }
4306
4307         if (totalCount == 1 || totalCount == currentOrdinal)
4308         {
4309                 __pFindWordNext->SetEnabled(false);
4310         }
4311         else
4312         {
4313                 __pFindWordNext->SetEnabled(true);
4314         }
4315
4316         String countStr = L"";
4317         countStr.Append(__currentWordIndex);
4318         countStr.Append(L"/");
4319         countStr.Append(__maxOccurrances);
4320         if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4321         {
4322         __pFindWordCountLabel->SetText(countStr);
4323         __pFindWordCountLabel->Invalidate(false);
4324         __pFindWordCountLabel->Invalidate(false);
4325         }
4326         else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4327         {
4328                 __pFindWordCountLabelRightToLeft->SetText(countStr);
4329                 __pFindWordCountLabelRightToLeft->Invalidate(false);
4330                 __pFindWordCountLabelRightToLeft->Invalidate(false);
4331         }
4332         //FindNextWord(true);
4333         //Update the controls
4334         __pFindWordNext->Invalidate(false);
4335         __pFindWordPrev->Invalidate(false);
4336
4337 }
4338
4339 void
4340 MainForm::FindNextWord(bool next)
4341 {
4342         if (next == true)
4343         {
4344                 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4345                         if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4346                         {
4347                                 if (__currentWordIndex < __maxOccurrances)
4348                                 {
4349                                         __currentWordIndex++;
4350                                 }
4351                         }
4352         }
4353         else
4354         {
4355                 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4356                 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4357                 {
4358                         if(__currentWordIndex > 1)
4359                         {
4360                                 __currentWordIndex--;
4361                         }
4362                 }
4363         }
4364
4365         String countStr = L"";
4366         countStr.Append(__currentWordIndex);
4367         countStr.Append(L"/");
4368         countStr.Append(__maxOccurrances);
4369
4370         if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4371         {
4372         __pFindWordCountLabel->SetText(countStr);
4373         __pFindWordCountLabel->Invalidate(false);
4374         }
4375         else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4376         {
4377                 __pFindWordCountLabelRightToLeft->SetText(countStr);
4378                 __pFindWordCountLabelRightToLeft->Invalidate(false);
4379         }
4380
4381         if (__currentWordIndex >= __maxOccurrances)
4382         {
4383                 __pFindWordNext->SetEnabled(false);
4384         }
4385         else
4386         {
4387                 __pFindWordNext->SetEnabled(true);
4388         }
4389         if (__currentWordIndex <= 1)
4390         {
4391                 __pFindWordPrev->SetEnabled(false);
4392         }
4393         else
4394         {
4395                 __pFindWordPrev->SetEnabled(true);
4396         }
4397         __pFindWordPrev->Invalidate(false);
4398         __pFindWordNext->Invalidate(false);
4399
4400         __pFindWordControl->Invalidate(true);
4401 }
4402
4403 void
4404 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4405 {
4406         AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4407         __isKeypadOpened = true;
4408         __pFooterPanel->SetShowState(false);
4409         //      OnAddressBarKeypadOpened(*__pAddressbar);
4410 }
4411
4412 void
4413 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4414 {
4415         __isKeypadOpened = true;
4416         AppLog("xyz::MainForm::OnWebKeypadOpened");
4417
4418         if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4419         {
4420                 __currentSearchStr = L"";
4421                 __currentWordIndex = 0;
4422                 __maxOccurrances = 0;
4423                 __pFindWordEditField->SetText(L"");
4424                 __pFindWordNext->SetEnabled(false);
4425                 __pFindWordPrev->SetEnabled(false);
4426                 __pFindWordCountLabel->SetText(L"0/0");
4427                 __pWebViewer->SearchTextAllAsync(L"",false);
4428                 __pFindWordControl->SetShowState(false);
4429                 __pFindWordEditField->HideKeypad();
4430         }
4431
4432
4433         if (__pWebViewer != null && __pFooterPanel != null)
4434         {
4435                 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4436                 if(__pAddressbar != null)
4437                 {
4438                         __pAddressbar->SetShowState(false);
4439                 }
4440                 if(__pFindWordControl != null)
4441                 {
4442                         __pFindWordControl->SetShowState(false);
4443                 }
4444                 __pFooterPanel->SetShowState(false);
4445                 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4446         }
4447 //      if(__pImageMenu && __pImageMenu->GetShowState() == true)
4448 //      {
4449 //              __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4450 //              AppLog("omgomgomg");
4451 //      }
4452         Invalidate(true);
4453 }
4454
4455 void
4456 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4457 {
4458         AppLog("xyz::MainForm::OnWebKeypadClosed");
4459         AppLog("akjshdasd 4");
4460         __pFooterPanel->SetShowState(true);
4461 //      OnAddressBarKeypadClosed(*__pAddressbar);
4462         RelayoutControls(false);
4463         __isKeypadOpened = false;
4464 }
4465
4466 void
4467 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4468 {
4469         //      RelativeLayout(false);
4470         if(__pWebViewer != null)
4471         {
4472                 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4473         }
4474 }
4475
4476 void
4477 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4478 {
4479         Control* temp = const_cast< Control* >(&source);
4480         Header* pHeader = dynamic_cast< Header* >(temp);
4481         if (pHeader != null)
4482         {
4483                 //Header double - clicked
4484                 AppLog("Header double clicked");
4485         }
4486         if(__pFindWordControl)
4487         {
4488                 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4489                 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4490         }
4491
4492
4493         AppLog("MainScene::OnTouchDoublePressed");
4494
4495 }
4496
4497 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4498 {
4499         AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4500         if(TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4501         {
4502                 AppLog("Returning because of more than one touch point.");
4503                 return;
4504         }
4505         __longPressPoint = currentPosition;
4506
4507         if (__pHitElementResult != null)
4508         {
4509                 delete __pHitElementResult;
4510                 __pHitElementResult = null;
4511         }
4512
4513         if (__pWebViewer != null)
4514         {
4515                 AppLog("MainForm::OnTouchLongPressed web not null");
4516                 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4517         }
4518
4519         if (__pHitElementResult == null)
4520         {
4521                 return;
4522         }
4523
4524         if (__pHitElementResult->HasImage() == true)
4525         {
4526                 if(__pWebViewer != null)
4527                         InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4528                 __pImageMenu->SetShowState(true);
4529                 __pImageMenu->Show();
4530                 __pImageMenu->Invalidate(true);
4531         }
4532         else if(__pHitElementResult->HasUrl() == true)
4533         {
4534                 String tempURl = __pHitElementResult->GetUrl();
4535                 AppLog("tempURl is %ls", tempURl.GetPointer());
4536                 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4537                 if (pBitmap != null)
4538                 {
4539                         AppLog("not null");
4540                 }
4541                 else
4542                 {
4543                         AppLog(null);
4544                 }
4545                 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4546                 __pImageMenu->SetShowState(true);
4547                 __pImageMenu->Show();
4548                 __pImageMenu->Invalidate(true);
4549         }
4550         else
4551         {
4552                 String tagName = __pHitElementResult->GetTagName();
4553                 String type = __pHitElementResult->GetAttributeValue("type");
4554                 String value = __pHitElementResult->GetAttributeValue(L"value");
4555                 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4556
4557                 __currentSelectedStr.Clear();
4558                 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4559
4560                 AppLog("tag name is %ls", tagName.GetPointer());
4561                 AppLog("type is %ls", type.GetPointer());
4562
4563
4564
4565                 __isLongPressedDone = true;
4566                 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4567                 if (((tagName.Equals(L"INPUT",false) == true)  || tagName.Equals(L"TEXTAREA",false) == true) && innerHtml.GetLength() == 0  && type.Equals(L"submit",false) !=true && type.Equals(L"range",false) !=true/*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.Equals(L"",false) == true && r == E_INVALID_ARG)
4568                 {
4569                         AppLog("MainForm::OnWebPageBlockSelected show paste option");
4570
4571                         InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4572                         if(__pImageMenu)
4573                         {
4574                                 __pImageMenu->SetShowState(true);
4575                                 __pImageMenu->Show();
4576                                 __pImageMenu->Invalidate(true);
4577                         }
4578                 }
4579                 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4580
4581         }
4582 //      __inputEventToBeSupressed = true;
4583 }
4584
4585 void
4586 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4587 {
4588         AppLog("xyz:: MainForm::OnTouchReleased called");
4589
4590         if (__pAddressbar && __pAddressbar->GetShowState() == true)
4591         {
4592                 __pAddressbar->SetShowState(false);
4593         }
4594         if(__pFooterPanel && __isKeypadOpened == false)
4595         {
4596                 __pFooterPanel->SetShowState(true);
4597         }
4598
4599         // Not reuired now.
4600         /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4601         if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4602         {
4603                 __pWebViewer->ConsumeInputEvent();
4604         }
4605         if(pHitElement != null)
4606         {
4607                 delete pHitElement;
4608         }
4609         __inputEventToBeSupressed = false;*/
4610 }
4611
4612 bool
4613 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4614 {
4615
4616         return true;
4617 }
4618
4619 bool
4620 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4621 {
4622         if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4623         {
4624                 __currentSearchStr = L"";
4625                 __currentWordIndex = 0;
4626                 __maxOccurrances = 0;
4627
4628                 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4629                 {
4630                         __pFindWordEditField->SetText(L"");
4631                         __pFindWordEditField->HideKeypad();
4632                         __pFindWordControl->SetShowState(false);
4633                         __pFindWordCountLabel->SetText(L"0/0");
4634                 }
4635                 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4636                 {
4637                         __pFindWordEditFieldRightToLeft->SetText(L"");
4638                         __pFindWordEditFieldRightToLeft->HideKeypad();
4639                         __pFindWordControl->SetShowState(false);
4640                         __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4641                 }
4642
4643                 __pFindWordNext->SetEnabled(false);
4644                 __pFindWordPrev->SetEnabled(false);
4645
4646                 __pWebViewer->SearchTextAllAsync(L"",true);
4647                 __pFindWordControl->SetShowState(false);
4648         }
4649         AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
4650         if(__pAddressbar->GetShowState() == false)
4651         {
4652                 __pAddressbar->SetAddressbarURLFocus();
4653                 __pFooterPanel->SetShowState(false);
4654         }
4655
4656         return false;
4657 }
4658
4659 bool
4660 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4661 {
4662         return true;
4663 }
4664
4665 bool
4666 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4667 {
4668         return true;
4669 }
4670
4671 bool
4672 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4673 {
4674         return true;
4675 }
4676
4677 bool
4678 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4679 {
4680         return true;
4681 }
4682
4683 bool
4684 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4685 {
4686         return true;
4687 }
4688
4689 void
4690 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4691 {
4692         AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4693         int widthContextItem = 0;
4694         if(__pFindWordCountLabel)
4695                 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4696         // As per the platform engineer comment removed this line
4697         /*if(__pWebViewer != null)
4698         {
4699                 // 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
4700                 __pWebViewer->ReleaseBlock();
4701         }*/
4702
4703 //      if(__pFindWordControl != null)
4704 //              ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4705
4706         if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
4707         {
4708                 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4709                 {
4710                         AppLog(" Orientation landscape");
4711                         __pOptionMenu->SetMaxVisibleItemsCount(5);
4712                 }
4713                 else
4714                 {
4715                         AppLog(" Orientation potrait");
4716                         __pOptionMenu->SetMaxVisibleItemsCount(6);
4717                 }
4718         }
4719         if(__pNotification && __pNotification->GetShowState() == true)
4720         {
4721                 __pNotification->SetShowState(false);
4722                 __pNotification->Invalidate(false);
4723         }
4724         if ( __pFooterLabel != null)
4725         {
4726                 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4727                 if(pBitmap != null)
4728                 {
4729                         __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4730                         delete pBitmap;
4731                 }
4732
4733
4734         }
4735         if (__pFindWordBgLabel != null)
4736         {
4737                 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4738                 if (pBitmap != null)
4739                 {
4740                         __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4741                         delete pBitmap;
4742                 }
4743         }
4744
4745         if (__pFindWordBgLabelRightToLeft != null)
4746         {
4747                 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4748                 if (pBitmap != null)
4749                 {
4750                         __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4751                         delete pBitmap;
4752                 }
4753         }
4754
4755
4756 //      if(__pOptionMenu != null)
4757 //              __pOptionMenu->SetShowState(false);
4758
4759         if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4760         {
4761                 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4762         }
4763         else
4764         {
4765                 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4766         }
4767
4768         if (__pFooterPanel)
4769         {
4770                 AppLog("__pFooterPanel->GetShowState() is true");
4771                 InitFooter();
4772                 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4773                 __pFooterPanel->Invalidate(true);
4774         }
4775         InitAddressbar();
4776
4777         String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4778         if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4779         {
4780                 InitMostVisitedSitesView(orientationStatus);
4781         }
4782
4783         RelayoutControls(false);
4784         if (__pArticleReaderPanel != null)
4785         {
4786                 if (__pArticleReaderPanel->GetShowState() == true)
4787                 {
4788                         __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4789
4790                         if (__pBlankPanel != null)
4791                                 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4792
4793                         if (__pWebReader != null)
4794                         {
4795                                 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4796                         }
4797                         Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4798                         Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4799
4800                         if ( pBitmap != null && pSrcBitmap != null)
4801                         {
4802                                 AppLog("CreateReaderPanel ninepatchbitmap found");
4803                                 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4804                         }
4805
4806                         __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4807                         __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4808                         if (pBitmap != null)
4809                         {
4810                                 delete pBitmap;
4811                                 pBitmap = null;
4812                         }
4813                         if (pSrcBitmap != null)
4814                         {
4815                                 delete pSrcBitmap;
4816                                 pSrcBitmap = null;
4817                         }
4818                 }
4819         }
4820         Invalidate(true);
4821         
4822     if (__pAddressbar != null)
4823         {
4824                 int width = GetClientAreaBounds().width;
4825                 __pAddressbar->OrientationChanged(width);
4826         }
4827 }
4828
4829 void
4830 MainForm::OnSettingsChange(int settingvalue)
4831 {
4832         AppLogDebug("MainForm::OnSettingsChange entered");
4833
4834         if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4835         {
4836                 __pAddressbar->ResetGuideText();
4837         }
4838         if (__pWebViewer == null)
4839         {
4840                 AppLogDebug("Webviewer is not initialized yet.");
4841                 return;
4842         }
4843
4844         if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4845         {
4846                 WebSetting settings = __pWebViewer->GetSetting();
4847                 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4848                 {
4849                         settings.SetAutoFittingEnabled(true);
4850                 }
4851                 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4852                 {
4853                         settings.SetAutoFittingEnabled(false);
4854                 }
4855                 __pWebViewer->SetSetting(settings);
4856         }
4857         else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4858         {
4859                 WebSetting settings = __pWebViewer->GetSetting();
4860                 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4861                 __pWebViewer->SetSetting(settings);
4862         }
4863         else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4864         {
4865                 WebSetting settings = __pWebViewer->GetSetting();
4866                 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4867                 __pWebViewer->SetSetting(settings);
4868                 __pWebViewer->Reload();
4869         }
4870         else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4871         {
4872                 WebSetting settings = __pWebViewer->GetSetting();
4873                 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4874                 __pWebViewer->SetSetting(settings);
4875         }
4876         else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4877         {
4878                 if (__pWebViewer)
4879                 {
4880                         __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4881                 }
4882         }
4883         else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4884         {
4885                 if (__pWebViewer)
4886                 {
4887                         WebSetting settings = __pWebViewer->GetSetting();
4888                         settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4889                         __pWebViewer->SetSetting(settings);
4890                 }
4891         }
4892         else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4893         {
4894                 if (__pWebViewer)
4895                 {
4896                         WebSetting settings = __pWebViewer->GetSetting();
4897                         settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4898                         __pWebViewer->SetSetting(settings);
4899                 }
4900         }
4901         else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4902         {
4903                 WebSetting settings = __pWebViewer->GetSetting();
4904                 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4905                 {
4906                         settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4907                 }
4908                 else
4909                 {
4910                         settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4911                 }
4912                 __pWebViewer->SetSetting(settings);
4913         }
4914         else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4915         {
4916                 if (__pWebReader)
4917                 {
4918                         AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4919                         WebSetting settings = __pWebReader->GetSetting();
4920                         settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4921                         __pWebReader->SetSetting(settings);
4922                 }
4923         }
4924 }
4925
4926 void
4927 MainForm::OnSettingsReset()
4928 {
4929         if (__pWebViewer)
4930         {
4931                 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4932                 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4933         }
4934 }
4935
4936 void
4937 MainForm::OnClearCache()
4938 {
4939         result r = E_SUCCESS;
4940
4941         if (__pWebViewer != NULL)
4942         {
4943                 r = __pWebViewer->ClearCache();
4944                 if (r == E_SUCCESS)
4945                 {
4946                         AppLogDebug("Cache cleared success");
4947                 }
4948                 else
4949                 {
4950                         AppLogDebug("Cache cleared fail");
4951                 }
4952         }
4953 }
4954
4955 void
4956 MainForm::OnClearCookie()
4957 {
4958         result r = E_SUCCESS;
4959
4960         if (__pWebViewer != NULL)
4961         {
4962                 __pWebViewer->ClearCookie();
4963         }
4964         if (r == E_SUCCESS)
4965         {
4966                 AppLogDebug("Cookie cleared success");
4967         }
4968         else
4969         {
4970                 AppLogDebug("Cache cleared fail");
4971         }
4972 }
4973
4974 void
4975 MainForm::OnClearFormData()
4976 {
4977         result r = E_SUCCESS;
4978
4979         if (__pWebViewer != NULL)
4980         {
4981                 __pWebViewer->ClearFormData();
4982         }
4983         if (r == E_SUCCESS)
4984         {
4985                 AppLogDebug("Cookie cleared success");
4986         }
4987         else
4988         {
4989                 AppLogDebug("Cache cleared fail");
4990         }
4991 }
4992
4993 void
4994 MainForm::OnClearPasswords()
4995 {
4996         result r = E_SUCCESS;
4997
4998         if (__pWebViewer != NULL)
4999         {
5000                 __pWebViewer->ClearLoginFormData();
5001         }
5002         if (r == E_SUCCESS)
5003         {
5004                 AppLogDebug("Cookie cleared success");
5005         }
5006         else
5007         {
5008                 AppLogDebug("Cache cleared fail");
5009         }
5010 }
5011
5012
5013 double
5014 MainForm::findDistance(int x1,int y1,int x2, int y2)
5015 {
5016         int deltaX = Math::Abs(x2 - x1);
5017         int deltaY = Math::Abs(y2 - y1);
5018         double num = deltaX*deltaX + deltaY*deltaY;
5019
5020         if (num >= 0)
5021         {
5022                 double x = num;
5023                 int i;
5024                 for (i = 0; i < 20; i++)
5025                 {
5026                         x = (((x*x)+ num)/(2*x));
5027                 }
5028                 return num;
5029         }
5030         else
5031         {
5032                 return 0.0;
5033         }
5034 }
5035
5036 void
5037 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5038 {
5039         AppLog("xyz:: MainForm::OnTouchPressed called");
5040         if(__pFindWordControl)
5041         {
5042                 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
5043 //              ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
5044         }
5045         __isLongPressedDone = false;
5046
5047
5048
5049         Touch touch;
5050         IList* pList = null;
5051         pList = touch.GetTouchInfoListN(source);
5052
5053         if (pList != null)
5054         {
5055                 int count = pList->GetCount();
5056                 if (count == 1)
5057                 {
5058                         TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5059                         __touchPoint1 = pTouchInfo->position;
5060
5061                         /*if (__pAddressbar != null)
5062                         {
5063                                 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5064                                 {
5065                                         if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5066                                         {
5067                                                 __pAddressbar->SaveAddressbarEditText();
5068                                         }
5069                                         __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5070                                 }
5071
5072                                 __pAddressbar->Invalidate(true);
5073                         }*/
5074                         if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5075                         {
5076                                 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5077                                 {
5078                                         //__pAddressbar->SaveAddressbarEditText();
5079                                 }
5080                                 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5081                         }
5082                 }
5083                 else if (count == 2)
5084                 {
5085                         AppLogDebug("MainForm::OnTouchPressed count is two");
5086                         TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5087                         __touchPoint1 = pTouchInfo->position;
5088
5089                         pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
5090                         __touchPoint2 = pTouchInfo->position;
5091                 }
5092         }
5093         if( pList != NULL)
5094         {
5095                 pList->RemoveAll(true);
5096                 delete pList;
5097         }
5098         if(__pAddressbar)
5099         {
5100                 __pAddressbar->SetShowState(false);
5101         }
5102         if(__pFooterPanel && __isKeypadOpened == false)
5103         {
5104                 __pFooterPanel->SetShowState(true);
5105         }
5106         RelayoutControls(false);
5107         return;
5108 }
5109
5110 void
5111 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5112 {
5113 //      __currentWordIndex = 0;
5114         __isLongPressedDone = false;
5115
5116 }
5117
5118 void
5119 MainForm::MoveUiControls()
5120 {
5121 }
5122
5123 void
5124 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5125 {
5126         if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5127         {
5128                 if(__pFooterUrlField->GetTextLength() == 0)
5129                 {
5130                         __pFooterUrlField->SetKeypadActionEnabled(false);
5131                 }
5132                 else
5133                 {
5134                         __pFooterUrlField->SetKeypadActionEnabled(true);
5135                 }
5136         }
5137         if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5138         {
5139                 __currentSearchStr = __pFindWordEditField->GetText();
5140                 if (__currentSearchStr.GetLength() > 0)
5141                 {
5142                         __pFindWordCountLabel->SetShowState(true);
5143                 }
5144                 else
5145                 {
5146 //                      __pFindWordCountLabel->SetShowState(false);
5147                         __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
5148                         __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
5149
5150                 }
5151                 __pFindWordNext->SetEnabled(false);
5152                 __pFindWordPrev->SetEnabled(false);
5153                 __pFindWordNext->Invalidate(true);
5154                 __pFindWordPrev->Invalidate(true);
5155                 __pFindWordCountLabel->SetText(L"0/0");
5156                 __pFindWordCountLabel->Invalidate(true);
5157         }
5158         else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5159         {
5160                 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5161                 if (__currentSearchStr.GetLength() > 0)
5162                 {
5163                         __pFindWordCountLabelRightToLeft->SetShowState(true);
5164                 }
5165                 else
5166                 {
5167                         __pFindWordCountLabelRightToLeft->SetShowState(false);
5168                 }
5169
5170                 __pFindWordNext->SetEnabled(false);
5171                 __pFindWordPrev->SetEnabled(false);
5172                 __pFindWordNext->Invalidate(true);
5173                 __pFindWordPrev->Invalidate(true);
5174                 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5175                 __pFindWordCountLabelRightToLeft->Invalidate(true);
5176         }
5177         AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5178         if (__currentSearchStr.GetLength() > 0)
5179         {
5180                 StartWordSearch();
5181         }
5182         else
5183         {
5184                 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5185                 StartWordSearch();
5186                 __currentSearchStr = L"";
5187                 AppLogDebug("Enter something");
5188         }
5189 }
5190
5191 result
5192 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5193 {
5194         return E_SUCCESS;
5195
5196 }
5197
5198 result
5199 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5200 {
5201         if(__pWebViewer != null)
5202                 return E_SUCCESS;
5203
5204         AppLog("MainForm::InitMostVisitedSitesView");
5205         result r = E_SUCCESS;
5206
5207
5208         if (__pWebViewer != null && __pMostVisitedListView != null)
5209         {
5210                 return E_SUCCESS;
5211         }
5212
5213         if (__pMostVisitedListView != null)
5214         {
5215                 RemoveControl(__pMostVisitedListView);
5216         }
5217         if(__pMostVisitedSites != null)
5218         {
5219                 __pMostVisitedSites->RemoveAll(true);
5220         }
5221
5222         HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5223
5224         __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5225         __pMostVisitedListView = new(std::nothrow) ListView();
5226
5227         int height = GetClientAreaBounds().height;
5228
5229         if(__pFooterPanel->GetShowState() == true)
5230         {
5231                 height = height - __pFooterPanel->GetHeight();
5232         }
5233         if(__pAddressbar->GetShowState() == true)
5234         {
5235                 height -= __pAddressbar->GetHeight();
5236         }
5237
5238         r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5239
5240         if (r != E_SUCCESS)
5241         {
5242                 delete __pMostVisitedListView;
5243                 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5244                 return r;
5245         }
5246         __pMostVisitedListView->SetItemProvider(*this);
5247         __pMostVisitedListView->AddListViewItemEventListener(*this);
5248         __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5249         AddControl(__pMostVisitedListView);
5250         __pMostVisitedListView->UpdateList();
5251
5252         return E_SUCCESS;
5253
5254 }
5255
5256 String
5257 MainForm::GetImagePath(void)
5258 {
5259
5260         String str;
5261         String formattedTime;
5262         DateTime currentTime;
5263         LocaleManager localManager;
5264         SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5265
5266         localManager.Construct();
5267         Locale locale = localManager.GetSystemLocale();
5268         //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5269
5270         // Get date formatter
5271         DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5272
5273         if (pTimeFormatter)
5274         {
5275                 pTimeFormatter->Format(currentTime, formattedTime);
5276         }
5277
5278         AppLog("current time stamp is %ls", formattedTime.GetPointer());
5279         String delim(L" :");
5280         StringTokenizer strTok(formattedTime, delim);
5281         String token;
5282         String imageName;
5283         String str1("GMT+00");
5284         while (strTok.HasMoreTokens())
5285         {
5286                 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5287                 if(token.Equals(str1))
5288                         break;
5289                 AppLog("token is %ls", token.GetPointer());
5290                 imageName.Append(token);
5291         }
5292         return imageName;
5293
5294 }
5295
5296 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5297 {
5298         result r = E_FAILURE;
5299         AppLog("Content manager 1");
5300         ContentId contentId;
5301         ContentManager contentManager;
5302         r = contentManager.Construct();
5303         if(IsFailed(r))
5304         {
5305                 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5306                 return;
5307         }
5308         Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5309         Tizen::Io::Directory::Create(contentPath,true);
5310         if(GetLastResult() == E_FILE_ALREADY_EXIST)
5311         {
5312                 AppLog("Already exists");
5313         }
5314         else if(GetLastResult() == E_SUCCESS)
5315         {
5316                 AppLog("created success");
5317         }
5318         contentPath.Append(imageName);
5319         contentPath.Append(".jpg");
5320         contentId = contentManager.CreateContent(*aBuffer, contentPath);
5321         ShowIndicatorNotification(L"Download Complete",contentPath);
5322         AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5323 }
5324
5325 void
5326 MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
5327 {
5328         AppLogDebug("ENTER");
5329
5330         NotificationRequest request;
5331         request.SetAlertText(messageText);
5332         request.SetTitleText(L"");
5333         request.SetAppMessage(contentPath);
5334         request.SetOngoingActivityType(ONGOING_ACTIVITY_TYPE_TEXT);
5335         request.SetNotificationStyle(NOTIFICATION_STYLE_THUMBNAIL);
5336         Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5337         String homePath = pApp->GetAppRootPath();
5338         String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5339         AppLog("The iconPath is : %ls", homePath.GetPointer());
5340         request.SetIconFilePath(iconPath);
5341
5342         Tizen::Shell::NotificationManager notiMgr;
5343         notiMgr.Construct();
5344         notiMgr.NotifyOngoingActivity(request);
5345         AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5346         return;
5347 }
5348
5349 void
5350 MainForm::SetForwardButtonEnabled(bool isEnabled)
5351 {
5352         __pGoForwardBtn->SetEnabled(isEnabled);
5353         __pGoForwardBtn->Invalidate(true);
5354 }
5355
5356 void
5357 MainForm::SetBackButtonEnabled(bool isEnabled)
5358 {
5359         __pGoBackBtn->SetEnabled(isEnabled);
5360         __pGoBackBtn->Invalidate(true);
5361 }
5362
5363 void
5364 MainForm::UpdateProgress(int percentage)
5365 {
5366         __progressPercentage = percentage;
5367         if (percentage == 0 || percentage == 100)
5368         {
5369                 __isLoadingData = false;
5370                 if (percentage == 100)
5371                 {
5372                         __isLoadingCompleted = true;
5373                         __progressPercentage = 0;
5374                 }
5375                 else
5376                 {
5377                         __isLoadingCompleted = false;
5378                 }
5379         }
5380         else
5381         {
5382                 __isLoadingData = true;
5383         }
5384         UpdateProgressBitmap();
5385 }
5386
5387 int
5388 MainForm::GetProgress(void)
5389 {
5390         return __progressPercentage;
5391 }
5392
5393 void
5394 MainForm::UpdateProgressBitmap(void)
5395 {
5396         result r = E_SUCCESS;
5397         if (__pProgressbarLabel == null)
5398                 return;
5399         int w = __pProgressbarLabel->GetWidth();
5400         int h = __pProgressbarLabel->GetHeight();
5401         Canvas canvas;
5402         int progressWidth = 0;
5403         Bitmap* pRetBitmap = null;
5404
5405         if (__progressPercentage == 0 || __progressPercentage == 100)
5406         {
5407                 __pProgressbarLabel->SetShowState(false);
5408                 __pProgressbarLabel->Invalidate(false);
5409                 return;
5410         }
5411         else
5412         {
5413                 __pProgressbarLabel->SetShowState(true);
5414                 __pProgressbarLabel->Invalidate(false);
5415         }
5416
5417         r = canvas.Construct(Rectangle(0, 0, w, h));
5418
5419         if (r != E_SUCCESS)
5420         {
5421                 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5422                 return;
5423         }
5424
5425         canvas.Clear();
5426         Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5427
5428         if (pBgBmp != null)
5429         {
5430                 pBgBmp->Scale(Dimension(w, h));
5431                 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5432                 delete pBgBmp;
5433         }
5434
5435         progressWidth = (double) (w) * __progressPercentage / 100;
5436         AppLogDebug("progressWidth: %d", progressWidth);
5437         Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5438
5439         if (pProgressBmp != null)
5440         {
5441                 pProgressBmp->Scale(Dimension(progressWidth, h));
5442                 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5443                 delete pProgressBmp;
5444         }
5445
5446         pRetBitmap = new (std::nothrow) Bitmap();
5447
5448         if (pRetBitmap == null)
5449         {
5450                 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5451                 return;
5452         }
5453
5454         pRetBitmap->Construct(canvas, canvas.GetBounds());
5455
5456         if (__pProgressbarLabel != null && pRetBitmap != null)
5457         {
5458                 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5459                 __pProgressbarLabel->Invalidate(false);
5460         }
5461
5462         if (pRetBitmap != null)
5463         {
5464                 delete pRetBitmap;
5465                 pRetBitmap = null;
5466         }
5467         return;
5468 }
5469
5470 void
5471 MainForm::ReaderClicked()
5472 {
5473         result r = E_SUCCESS;
5474         ArrayList* pArgList = new(std::nothrow) ArrayList();
5475         if (pArgList != null)
5476         {
5477                 r = pArgList->Construct();
5478                 if (IsFailed(r))
5479                 {
5480                         delete pArgList;
5481                         return;
5482                 }
5483
5484                 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5485                 if (IsFailed(r))
5486                 {
5487                         delete pArgList;
5488                         return;
5489                 }
5490
5491                 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5492                 if (IsFailed(r))
5493                 {
5494                         delete pArgList;
5495                         return;
5496                 }
5497
5498                 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5499                 if (IsFailed(r))
5500                 {
5501                         delete pArgList;
5502                         return;
5503                 }
5504         }
5505
5506         SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5507         return;
5508
5509
5510 }
5511
5512 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5513 {
5514         AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5515
5516         __currentAddMode = addMode;
5517
5518         switch(addMode)
5519         {
5520         case ADDRESSBAR_MODE_INVALID:
5521         {
5522                 // do nothing
5523         }
5524         break;
5525         case ADDRESSBAR_MODE_READER:
5526         {
5527                 __pStopBtn->SetShowState(false);
5528                 __pRefreshBtn->SetShowState(false);
5529                 __pClearBtn->SetShowState(false);
5530                 __pReaderBtn->SetShowState(false);
5531         }
5532         break;
5533         case ADDRESSBAR_MODE_LOADING:
5534         {
5535                 __pRefreshBtn->SetShowState(false);
5536                 __pStopBtn->SetShowState(true);
5537                 __pClearBtn->SetShowState(false);
5538                 __pReaderBtn->SetShowState(false);
5539         }
5540         break;
5541         case ADDRESSBAR_MODE_LOADING_COMPLETE:
5542         {
5543 //              SetUrl(__pAddressbar->GetUrl());
5544
5545                 __pRefreshBtn->SetShowState(true);
5546                 __pStopBtn->SetShowState(false);
5547                 __pClearBtn->SetShowState(false);
5548                 __pReaderBtn->SetShowState(false);
5549         }
5550         break;
5551         case ADDRESSBAR_MODE_EDIT:
5552         {
5553                 __pRefreshBtn->SetShowState(false);
5554                 __pStopBtn->SetShowState(false);
5555                 __pReaderBtn->SetShowState(false);
5556                 __pClearBtn->SetShowState(true);
5557         }
5558         break;
5559         }
5560
5561         Invalidate(true);
5562
5563         OnAddressBarModeChanged();
5564 }
5565
5566 AddressBarMode MainForm::GetAddressbarMode(void)
5567 {
5568         return __currentAddMode;
5569 }
5570
5571 void MainForm::SetUrl(const String& url)
5572 {
5573         __displayUrl = url;
5574         if(__displayUrl.GetLength() > 2048)
5575                 __displayUrl.SubString(0,2048,__displayUrl);
5576
5577         if (__pFooterUrlField != NULL)
5578         {
5579                 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5580                 if (removedHttpUrl.IsEmpty() == false)
5581                 {
5582                         __pFooterUrlField->SetText(removedHttpUrl);
5583                         if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5584                                 __pAddressbar->SetUrl(__displayUrl);
5585                 }
5586                 else
5587                 {
5588                         __pFooterUrlField->SetText(__displayUrl);
5589                         if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5590                                 __pAddressbar->SetUrl(__displayUrl);
5591                 }
5592                 if(__pFooterUrlField)
5593                         __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5594                 __pFooterUrlField->Invalidate(false);
5595                 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5596                         __pAddressbar->Invalidate(true);
5597 //              __pFooterUrlField->SetCursorPosition(0);
5598         }
5599 }
5600
5601 String
5602 MainForm::RemoveHttpTextFromDisplayURL(void)
5603 {
5604         AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5605         int index = -1;
5606 //      bool isHttpText = __displayUrl.Contains(L"http://");
5607         String updatedDisplayUrl;
5608         updatedDisplayUrl.Clear();
5609         if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5610         {
5611                 __displayUrl.SubString(7,updatedDisplayUrl);
5612         }
5613         else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5614         {
5615                 __displayUrl.SubString(8,updatedDisplayUrl);
5616         }
5617         return updatedDisplayUrl;
5618 }
5619
5620 void MainForm::OnSharePopupControlStarted(void)
5621 {
5622         __pWebViewer->AddTouchEventListener(*this);
5623 }
5624
5625 void
5626 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5627 {
5628         if (requestId == BACK_GROUND_APP_EVENT)
5629         {
5630                 if(__pWebViewer != null)
5631                 {
5632                         __pWebViewer->Pause();
5633                 }
5634                 if(__pImageMenu)
5635                 {
5636                         __pImageMenu->SetShowState(false);
5637                 }
5638                 if(__pAddressbar != null)
5639                 {
5640                         __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5641                 }
5642         }
5643         else if(requestId == FORE_GROUND_APP_EVENT)
5644         {
5645                 if(__pWebViewer != null)
5646                 {
5647                         __pWebViewer->Resume();
5648                 }
5649                 if(__pAddressbar != null)
5650                 {
5651                         __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5652                 }
5653         }
5654 }
5655
5656 void
5657 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5658 {
5659         AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5660         result r = E_SUCCESS;
5661
5662         if (__pAddressbar)
5663                 __pAddressbar->SetShowState(false);
5664
5665         AppLog("akjshdasd 5");
5666         __pFooterPanel->SetShowState(true);
5667
5668         if(__pWebViewer)
5669                 __pWebViewer->SetFocus();
5670         else if(__pMostVisitedListView)
5671                 __pMostVisitedListView->SetFocus();
5672         else if(__pMultiWindowButton)
5673                 __pMultiWindowButton->SetFocus();
5674         else if(__pMoreButton)
5675                 __pMoreButton->SetFocus();
5676
5677         __pAddressbar->SetShowState(false);
5678
5679         RelayoutControls(false);
5680 }
5681
5682 void
5683 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5684 {
5685         AppLog("MainForm::OnFormMenuRequested called");
5686         InitOptionMenu();
5687         if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
5688         {
5689                 int bookmarkCount=0;
5690                 bool exist = false;
5691                 String url=L"";
5692                 url=__pWindowInfo->pageUrl;
5693                 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5694                 result r = E_SUCCESS;
5695                 Bitmap* pBitmap = null;
5696                 String lastChar = L"";
5697 //              if(url.SubString(url.GetLength()-1,lastChar));
5698 //              if(lastChar == L"/")
5699 //              {
5700 //                      bool exist1 = false;
5701 //                      bool exist2 = false;
5702 //                      r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5703 //                      url.SubString(0,url.GetLength() - 1,url);
5704 //                      r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5705 //                      exist = exist1 | exist2;
5706 //              }
5707 //              else
5708 //              {
5709                         r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5710                         if (IsFailed(r))
5711                         {
5712                                 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5713                                 return;
5714                         }
5715 //              }
5716                 if ( exist == true)
5717                 {
5718                         pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5719                 }
5720                 else
5721                 {
5722                         pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5723                 }
5724                 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5725
5726                 if (__pOptionMenu->GetItemCount() == 9)
5727                 {
5728                         r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5729                 }
5730                 else
5731                 {
5732                         r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5733                 }
5734
5735                 if (IsFailed(r))
5736                 {
5737                         AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5738                         delete pBitmap;
5739                         return ;
5740                 }
5741                 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5742                 if (__pOptionMenu->GetItemCount() != 9)
5743                 {
5744                         __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5745                         __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5746 //                              __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5747                         __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5748                         __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5749                         __pOptionMenu->SetMaxVisibleItemsCount(6);
5750                 }
5751                 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
5752                 {
5753                         AppLog(" Orientation landscape");
5754                         __pOptionMenu->SetMaxVisibleItemsCount(5);
5755                 }
5756                 else
5757                 {
5758                         AppLog(" Orientation potrait");
5759                         __pOptionMenu->SetMaxVisibleItemsCount(6);
5760                 }
5761
5762                 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5763                 delete pBitmap;
5764         }
5765         AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5766         if(__pAddressbar)
5767                 __pAddressbar->SetShowState(false);
5768         SetFocus();
5769         __pFooterPanel->SetShowState(true);
5770         result r = __pOptionMenu->SetShowState(true);
5771         AppLog("ajsghd %s",GetErrorMessage(r));
5772         RelayoutControls(false);
5773         __pOptionMenu->Invalidate(true);
5774         __pOptionMenu->Show();
5775
5776 }