fix lock up issue for download
authorSeongjun Yim <se201.yim@samsung.com>
Thu, 18 Jul 2013 12:32:16 +0000 (21:32 +0900)
committerSeongjun Yim <se201.yim@samsung.com>
Thu, 18 Jul 2013 13:32:08 +0000 (22:32 +0900)
Change-Id: Ibe768a34c7da07999225a582f7d359db9d0e733c
Signed-off-by: Seongjun Yim <se201.yim@samsung.com>
inc/FWebCtrlWeb.h
src/FWeb_WebBookmarkImpl.cpp
src/controls/FWebCtrl_AppControlListener.cpp
src/controls/FWebCtrl_SelectBox.cpp
src/controls/FWebCtrl_SelectBox.h
src/controls/FWebCtrl_WebImpl.cpp

index fa22d82..e2ff11e 100755 (executable)
@@ -72,7 +72,7 @@ namespace Tizen { namespace Web { namespace Controls
  *
  * The following example demonstrates how to use the %Web class.
  *     @code
-// Sample code for WebSample.h
+// Sample code using Form for WebSample.h
 #include <FUi.h>
 #include <FWeb.h>
 
@@ -93,7 +93,7 @@ public:
     virtual result OnInitializing(void);
 };
 
-// Sample code for WebSample.cpp
+// Sample code using Form for WebSample.cpp
 #include "WebSample.h"
 
 using namespace Tizen::Ui;
@@ -105,9 +105,13 @@ WebSample::OnInitializing(void)
 {
     result r = E_SUCCESS;
 
+    // Constucts a Form
+    ...
+
     __pWeb = new Web();
     __pWeb->Construct(GetClientAreaBounds());
     AddControl(__pWeb);
+
     LoadUrl();
 
     return r;
@@ -123,6 +127,67 @@ WebSample::LoadUrl(void)
 }
  *     @endcode
  *
+ *     @code
+// Sample code using Window for WebSample.h
+#include <FApp.h>
+#include <FUi.h>
+#include <FWeb.h>
+
+class WebSample :
+    public Tizen::Ui::Window
+{
+public:
+    WebSample(void) {};
+    virtual ~WebSample(void) {};
+
+protected:
+    void LoadUrl(void);
+
+private:
+    Tizen::Web::Controls::Web *__pWeb;
+
+public:
+    virtual result OnInitializing(void);
+};
+
+// Sample code using Window for WebSample.cpp
+#include "WebSample.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Web::Controls;
+
+result
+WebSample::OnInitializing(void)
+{
+    result r = E_SUCCESS;
+
+    // Constucts a Window
+    ...
+
+    Frame *pFrame = UiApp::GetInstance()->GetAppFrame()->GetFrame();
+    SetOwner(pFrame->GetCurrentForm());
+
+    __pWeb = new Web();
+    __pWeb->Construct(GetClientAreaBounds());
+    AddControl(__pWeb);
+
+    Show();
+    LoadUrl();
+
+    return r;
+}
+
+// Calls LoadUrl() with the URL of the Web content to display it on the Web control
+void
+WebSample::LoadUrl(void)
+{
+    Tizen::Base::String url(L"http://www.tizen.org");
+
+    __pWeb->LoadUrl(url);
+}
+ *     @endcode
  */
 class _OSP_EXPORT_ Web
        : public Tizen::Ui::Container
index caed0aa..7af48da 100755 (executable)
@@ -153,7 +153,7 @@ _WebBookmarkImpl::SetFavicon(RecordId bookmarkId, const Bitmap& favicon)
 
        Evas_Object* pIcon = null;
 
-       Bitmap& temp = const_cast< Bitmap& >(favicon);;
+       Bitmap& temp = const_cast< Bitmap& >(favicon);
 
        Evas* pEvas = _Utility::GetEvasFromUiApp(pFrame);
        SysTryCatch(NID_WEB, pEvas, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
index 995f0ca..5b2929e 100755 (executable)
@@ -122,12 +122,12 @@ _MediaSelectionListener::~_MediaSelectionListener(void)
 void
 _MediaSelectionListener::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& providerId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pAppData)
 {
-       SysTryReturnVoidResult(NID_WEB_CTRL, pAppData, E_INVALID_ARG, "[E_INVALID_ARG] Invalid arguments to _MediaSelectionListener::OnAppControlCompleted");
-
        Eina_List* pSelectedFileNames = null;
+       ArrayList* pSelectedFiles = null;
        int fileCount = 0;
 
-       ArrayList *pSelectedFiles = dynamic_cast< ArrayList* >(const_cast< Object* >(pAppData->GetValue(String("http://tizen.org/appcontrol/data/selected"))));
+       SysTryCatch(NID_WEB_CTRL, pAppData, , E_INVALID_ARG, "[E_INVALID_ARG] Invalid arguments to _MediaSelectionListener::OnAppControlCompleted");
+       pSelectedFiles = dynamic_cast< ArrayList* >(const_cast< Object* >(pAppData->GetValue(String("http://tizen.org/appcontrol/data/selected"))));
        SysTryCatch(NID_WEB_CTRL, pSelectedFiles, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
        fileCount = pSelectedFiles->GetCount();
index 8a23a30..7b420ec 100755 (executable)
@@ -26,6 +26,7 @@
 #include <unique_ptr.h>
 #include <FBaseColAllElementsDeleter.h>
 #include <FBaseSysLog.h>
+#include <FCntDownloadRequest.h>
 #include <FGrpDimension.h>
 #include <FGrpRectangle.h>
 #include <FUiCtrlButton.h>
@@ -37,6 +38,7 @@
 #include <FUiIActionEventListener.h>
 #include <FUiKeyEventInfo.h>
 #include <FUiVerticalBoxLayout.h>
+#include <FCnt_DownloadManagerImpl.h>
 #include <FSys_SystemResource.h>
 #include <FUi_ResourceManager.h>
 #include "FWebCtrl_SelectBox.h"
@@ -44,6 +46,7 @@
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
+using namespace Tizen::Content;
 using namespace Tizen::Graphics;
 using namespace Tizen::System;
 using namespace Tizen::Ui;
@@ -147,6 +150,7 @@ _SelectBox::_SelectBox(void)
        , __orientation(_CONTROL_ORIENTATION_PORTRAIT)
        , __pWebView(null)
        , __pToggledArray(null)
+       , __url(L"")
 {
 }
 
@@ -164,7 +168,7 @@ _SelectBox::~_SelectBox(void)
 
 
 result
-_SelectBox::Construct(bool isMultiSelect, const String& title, int listCount, Evas_Object* pWebView)
+_SelectBox::Construct(bool isMultiSelect, const String& title, int listCount, Evas_Object* pWebView, const String& url)
 {
        result r = E_SUCCESS;
        Rectangle rect;
@@ -174,6 +178,7 @@ _SelectBox::Construct(bool isMultiSelect, const String& title, int listCount, Ev
        int listViewHeight = 0;
 
        __pWebView = pWebView;
+       __url = const_cast< String& >(url);
 
        GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, __orientation, listItemHeight);
 
@@ -420,14 +425,30 @@ _SelectBox::OnListViewItemStateChanged(ListView& listView, int index, int elemen
        else
        {
                //In case of single selection ... update the index.
-               __SelectedIndex = index;
-               SysLog(NID_WEB_CTRL,"The current value of Update Selected index is %d",index);
-               if (__pWebView)
+               if (__url.GetLength() == 0)
                {
-                       ewk_view_popup_menu_select(__pWebView, __SelectedIndex);
+                       __SelectedIndex = index;
+                       SysLog(NID_WEB_CTRL,"The current value of Update Selected index is %d",index);
+                       if (__pWebView)
+                       {
+                               ewk_view_popup_menu_select(__pWebView, __SelectedIndex);
+                       }
                }
+               else
+               {
+                       result r = E_SUCCESS;
+
+                       RequestId reqId = 0;
+                       DownloadRequest request(__url);
+
+                       _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
+                       SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
-               result r = HidePopup(__SelectedIndex);
+                       r = pManagerImpl->Start(request, reqId);
+                       SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+               }
+
+               result r = HidePopup();
                SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
        }
 }
@@ -443,31 +464,34 @@ _SelectBox::OnListViewItemSwept(ListView& listView, int index, SweepDirection di
 void
 _SelectBox::OnActionPerformed(const Control& source, int actionId)
 {
-       switch (actionId)
-       {
-       case ID_BUTTON_SELECTION:
-       {
-               ewk_view_popup_menu_multiple_select(__pWebView, __pToggledArray);
-               break;
-       }
-       case ID_BUTTON_CANCEL:
+       result r = HidePopup();
+       SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       if (__url.GetLength() == 0)
        {
-               if (__multiSelection)
+               switch (actionId)
+               {
+               case ID_BUTTON_SELECTION:
                {
-                       ewk_view_popup_menu_multiple_select(__pWebView, null);
+                       ewk_view_popup_menu_multiple_select(__pWebView, __pToggledArray);
+                       break;
                }
-               else
+               case ID_BUTTON_CANCEL:
                {
-                       ewk_view_popup_menu_select(__pWebView, __prevIndex);
+                       if (__multiSelection)
+                       {
+                               ewk_view_popup_menu_multiple_select(__pWebView, null);
+                       }
+                       else
+                       {
+                               ewk_view_popup_menu_select(__pWebView, __prevIndex);
+                       }
+                       break;
+               }
+               default:
+                       SysAssertf(false, "Invalid Action ID");
                }
-               break;
-       }
-       default:
-               SysAssertf(false, "Invalid Action ID");
        }
-
-       result r = HidePopup(__SelectedIndex);
-       SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 }
 
 bool
@@ -481,19 +505,23 @@ _SelectBox::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
 {
        if ((keyEventInfo.GetKeyCode() == KEY_ESC || keyEventInfo.GetKeyCode() == KEY_BACK) && source.GetShowState() == true)
        {
-               if (__multiSelection)
-               {
-                       ewk_view_popup_menu_multiple_select(__pWebView, null);
-               }
-               else
-               {
-                       ewk_view_popup_menu_select(__pWebView, __prevIndex);
-               }
-               result r = HidePopup(__SelectedIndex);
+               result r = HidePopup();
                if (IsFailed(r))
                {
                        SysLogException(NID_WEB_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
                }
+
+               if (__url.GetLength() == 0)
+               {
+                       if (__multiSelection)
+                       {
+                               ewk_view_popup_menu_multiple_select(__pWebView, null);
+                       }
+                       else
+                       {
+                               ewk_view_popup_menu_select(__pWebView, __prevIndex);
+                       }
+               }               
        }
 
        return false;
index ff85090..1b2f59c 100755 (executable)
@@ -60,7 +60,6 @@ enum _ButtonFormat
        ID_BUTTON_CANCEL
 };
 
-
 class _SelectBox
        : public _WebPopup
        , public Tizen::Ui::Controls::IListViewItemEventListener
@@ -78,7 +77,7 @@ public:
         */
        virtual ~_SelectBox(void);
 
-       result Construct(bool isMultiSelect, const Tizen::Base::String& title, int listItemCnt, Evas_Object* pWebView = null);
+       result Construct(bool isMultiSelect, const Tizen::Base::String& title, int listItemCnt, Evas_Object* pWebView = null, const Tizen::Base::String& url = L"");
        Tizen::Base::Collection::IList* GetSelectedListN(void) const;
 
        //IListViewItemProvider
@@ -132,6 +131,7 @@ private:
        Tizen::Ui::_ControlOrientation __orientation;
        Evas_Object* __pWebView;
        Eina_Inarray* __pToggledArray;
+       Tizen::Base::String __url;
 }; // _SelectBox
 
 }}} //Tizen::Web::Controls
index 47a7e1e..96c8b32 100755 (executable)
@@ -362,7 +362,6 @@ OnScriptConfirmRequested(Evas_Object* pView, const char* pMessage, void* pUserDa
        SysLog(NID_WEB_CTRL, "The current value of message is %s", pMessage);
 
        result r = E_SUCCESS;
-       _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData);
        String msg(pMessage);
 
        MessageBox messageBox;
@@ -1130,8 +1129,6 @@ OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
                {
                        ewk_policy_decision_ignore(pPolicy);
 
-                       _SelectBox selectBox;
-                       int selectedIndex = 0;
                        String operationId(L"http://tizen.org/appcontrol/operation/view");
 
                        r = _AppControlImpl::FindAndStart(operationId, &url, &mime, null, null, null);
@@ -1139,24 +1136,15 @@ OnWebDataReceived(void* pUserData, Evas_Object* pView, void* pEventInfo)
        
                        if (r == E_OBJ_NOT_FOUND)
                        {
-                               r = selectBox.Construct(false, L"Select application", 1); //+1 for Downloader
-                               SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+                               _SelectBox* pSelectBox = new (std::nothrow) _SelectBox;
+                               SysTryReturnVoidResult(NID_WEB_CTRL, pSelectBox, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-                               selectBox.AddListItem(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_BR_BODY_DOWNLOAD"), _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
-                               r = selectBox.ShowAndWait(selectedIndex);
+                               r = pSelectBox->Construct(false, L"Select application", 1, null, url);
                                SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
-                               if (selectedIndex == 0) //download
-                               {
-                                       RequestId reqId = 0;
-                                       DownloadRequest request(pUrl);
-
-                                       _DownloadManagerImpl* pManagerImpl = _DownloadManagerImpl::GetInstance();
-                                       SysTryReturnVoidResult(NID_WEB_CTRL, pManagerImpl, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
-
-                                       r = pManagerImpl->Start(request, reqId);
-                                       SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
-                               }
+                               pSelectBox->AddListItem(pSysResource->GetString(_RESOURCE_DOMAIN_ID_OSP, "IDS_BR_BODY_DOWNLOAD"), _SelectBox::LIST_ITEM_TYPE_NORMAL, false);
+                               r = pSelectBox->ShowPopup();
+                               SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
                        }
 
                        return;