Refactoring WidgetView 49/251049/15 accepted/tizen/unified/20210609.140403 accepted/tizen/unified/20210615.120311 accepted/tizen/unified/20210713.124142 accepted/tizen/unified/20210720.123553 submit/tizen/20210609.012218 submit/tizen/20210609.063802 submit/tizen/20210614.101611 submit/tizen/20210713.070142 submit/tizen/20210719.090525
authorSunghyun Kim <scholb.kim@samsung.com>
Thu, 7 Jan 2021 07:33:07 +0000 (16:33 +0900)
committerSunghyun Kim <scholb.kim@samsung.com>
Wed, 2 Jun 2021 07:37:50 +0000 (16:37 +0900)
1.Add RemoveWidget() for WidgetViewManager
2.Apply Singleton to WidgetViewManager
  (https://github.com/Samsung/TizenFX/pull/2521)
3.Set RetryState When widget creation fails
4.Add Document

Change-Id: I946b672109c827fa04d47d97f98c4608364749e7

widget_viewer_dali/internal/widget_view/widget_view_impl.cpp
widget_viewer_dali/internal/widget_view/widget_view_impl.h
widget_viewer_dali/internal/widget_view_manager/widget_view_manager_impl.cpp
widget_viewer_dali/internal/widget_view_manager/widget_view_manager_impl.h
widget_viewer_dali/public_api/widget_view/widget_view.h
widget_viewer_dali/public_api/widget_view_manager/widget_view_manager.cpp
widget_viewer_dali/public_api/widget_view_manager/widget_view_manager.h

index c11d7a5d0f1116e057c551ca183943c45a630788..efa90c14d7317fafef2fbcd28ec5361047a0c2fd 100644 (file)
@@ -192,6 +192,12 @@ static bool GetKeyCode( std::string keyName, int32_t& keyCode )
   Ecore_Wl2_Input* ecoreWlInput = NULL;
 
   Ecore_Wl2_Display *wl2_display = ecore_wl2_connected_display_get(NULL);
+  if( !wl2_display )
+  {
+    DALI_LOG_ERROR( "Failed to get Ecore_Wl2_Display in WidgetView\n" );
+    return false;
+  }
+
   ecoreWlInput = ecore_wl2_input_default_input_get(wl2_display);
   if( !ecoreWlInput )
   {
@@ -288,12 +294,9 @@ WidgetView::WidgetView()
   mTitle(),
   mWidth( 0 ),
   mHeight( 0 ),
-  mPid( 0 ),
+  mPid( -1 ),
   mUpdatePeriod( 0.0 ),
-  mPreviewVisible( true ),
-  mLoadingTextVisible( true ),
   mLoadingTextString(),
-  mRetryTextVisible( true ),
   mRetryTextString(),
   mRetryState( false ),
   mPermanentDelete( false ),
@@ -316,12 +319,9 @@ WidgetView::WidgetView( const std::string& widgetId, const std::string& contentI
   mTitle(),
   mWidth( width ),
   mHeight( height ),
-  mPid( 0 ),
+  mPid( -1 ),
   mUpdatePeriod( updatePeriod ),
-  mPreviewVisible( true ),
-  mLoadingTextVisible( true ),
   mLoadingTextString(),
-  mRetryTextVisible( true ),
   mRetryTextString(),
   mRetryState( false ),
   mPermanentDelete( false ),
@@ -365,6 +365,11 @@ bool WidgetView::PauseWidgetInternally()
   {
     tizen_remote_surface_transfer_visibility( mRemoteSurface, TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_INVISIBLE);
   }
+  else
+  {
+     DALI_LOG_ERROR("WidgetView::PauseWidget: RemoteSurface is NULL (%s, %s) [%d]\n", mWidgetId.c_str(), mInstanceId.c_str(), ret );
+     return false;
+  }
 
   DALI_LOG_RELEASE_INFO("WidgetView::PauseWidget: Widget is paused (%s, %s)\n", mWidgetId.c_str(), mInstanceId.c_str() );
 
@@ -384,6 +389,11 @@ bool WidgetView::ResumeWidgetInternally()
   {
      tizen_remote_surface_transfer_visibility( mRemoteSurface, TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE);
   }
+  else
+  {
+     DALI_LOG_ERROR("WidgetView::ResumeWidget: RemoteSurface is NULL (%s, %s) [%d]\n", mWidgetId.c_str(), mInstanceId.c_str(), ret );
+     return false;
+  }
 
   DALI_LOG_RELEASE_INFO("WidgetView::ResumeWidget: Widget is resumed (%s, %s)\n", mWidgetId.c_str(), mInstanceId.c_str() );
 
@@ -434,20 +444,20 @@ const std::string& WidgetView::GetContentInfo()
 
   if( mWidgetId.empty() || mInstanceId.empty() )
   {
-    DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::GetContentInfo: Widget id (%s) or instance id (%s) is invalid.\n", mWidgetId.c_str(), mInstanceId.c_str() );
+    DALI_LOG_ERROR("WidgetView::GetContentInfo: Widget id (%s) or instance id (%s) is invalid.\n", mWidgetId.c_str(), mInstanceId.c_str() );
     return mContentInfo;
   }
 
   instance = widget_instance_get_instance( mWidgetId.c_str(), mInstanceId.c_str() );
   if( !instance )
   {
-    DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::GetContentInfo: widget_instance_get_instance is failed. [%s]\n", mInstanceId.c_str() );
+    DALI_LOG_ERROR("WidgetView::GetContentInfo: widget_instance_get_instance is failed. [%s]\n", mInstanceId.c_str() );
     return mContentInfo;
   }
 
   if( widget_instance_get_content( instance, &contentInfo ) < 0 )
   {
-    DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::GetContentInfo: Failed to get content of widget. [%s]\n", mInstanceId.c_str() );
+    DALI_LOG_ERROR("WidgetView::GetContentInfo: Failed to get content of widget. [%s]\n", mInstanceId.c_str() );
     widget_instance_unref( instance );
     return mContentInfo;
   }
@@ -483,29 +493,27 @@ bool WidgetView::CancelTouchEvent()
     return true;
   }
 
+  DALI_LOG_ERROR("WidgetView::CancelTouchEvent: RemoteSurface is NULL \n");
   return false;
 }
 
 void WidgetView::SetPreviewVisible( bool visible )
 {
-  if( mPreviewImage && mPreviewVisible != visible )
+  if( mPreviewImage && IsPreviewVisible() != visible )
   {
-    mPreviewVisible = visible;
     mPreviewImage.SetProperty( Actor::Property::VISIBLE, visible );
   }
 }
 
 bool WidgetView::IsPreviewVisible()
 {
-  return mPreviewVisible;
+  return mPreviewImage.GetProperty<bool>( Actor::Property::VISIBLE );
 }
 
 void WidgetView::SetLoadingTextVisible( bool visible )
 {
-  if( mLoadingText && mLoadingTextVisible != visible )
+  if( mLoadingText && IsLoadingTextVisible() != visible )
   {
-    mLoadingTextVisible = visible;
-
     if( visible )
     {
       mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT,
@@ -515,12 +523,15 @@ void WidgetView::SetLoadingTextVisible( bool visible )
   }
 }
 
+bool WidgetView::IsLoadingTextVisible()
+{
+  return mLoadingText.GetProperty<bool>( Actor::Property::VISIBLE );
+}
+
 void WidgetView::SetRetryTextVisible( bool visible )
 {
-  if( mRetryText && mRetryTextVisible != visible )
+  if( mRetryText && IsRetryTextVisible() != visible )
   {
-    mRetryTextVisible = visible;
-
     if( visible )
     {
       mRetryText.SetProperty( Toolkit::TextLabel::Property::TEXT,
@@ -530,14 +541,9 @@ void WidgetView::SetRetryTextVisible( bool visible )
   }
 }
 
-bool WidgetView::IsLoadingTextVisible()
-{
-  return mLoadingTextVisible;
-}
-
 bool WidgetView::IsRetryTextVisible()
 {
-  return mRetryTextVisible;
+  return mRetryText.GetProperty<bool>( Actor::Property::VISIBLE );
 }
 
 void WidgetView::ActivateFaultedWidget()
@@ -548,28 +554,8 @@ void WidgetView::ActivateFaultedWidget()
     ShowRetryState( false );
     ShowLoadingState( true );
 
-    // launch widget again
-    mPid = widget_instance_launch( mInstanceId.c_str(), (char *)mContentInfo.c_str(), mWidth, mHeight );
-    if( mPid < 0)
-    {
-      DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::ActivateFaultedWidget: widget_instance_launch is failed. [%s]\n", mWidgetId.c_str() );
-
-      ShowLoadingState( false );
-      ShowRetryState( true );
-
-      // Emit signal
-      Dali::WidgetView::WidgetView handle( GetOwner() );
-      mWidgetCreationAbortedSignal.Emit( handle );
-
-      return;
-    }
-
-    screen_connector_toolkit_ops ops;
-    ops.updated_cb = OnBufferUpdated;
-    ops.removed_cb = OnSurfaceRemoved;
-    ops.added_cb = OnBufferAdded;
-    mWatcherHandle = screen_connector_toolkit_add(&ops, (char *)mInstanceId.c_str(), static_cast<screen_connector_screen_type_e>(static_cast<screen_connector_screen_type_e>(SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET | SCREEN_CONNECTOR_SCREEN_TYPE_COMPONENT_BASED)), this);
-    DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::ActivateFaultedWidget: widget_instance_launch is called. [%s, mPid = %d]\n", mWidgetId.c_str(), mPid );
+    // launch widget
+    LaunchWidget();
   }
 }
 
@@ -633,18 +619,37 @@ void WidgetView::RemoveWidgetRenderer()
 }
 
 bool WidgetView::TerminateWidget()
+{
+  DALI_LOG_WARNING("TerminateWidget() will be depreceated. Please use RemoveWidget() in WidgetViewManager instead.\n");
+  return RemoveWidget();
+}
+
+bool WidgetView::RemoveWidget()
 {
   if( !mWidgetId.empty() && !mInstanceId.empty() )
   {
     int ret = 0;
 
-    // Destroy widget instance because it will be not used anymore.
-    ret = widget_instance_destroy( mInstanceId.c_str() );
-    if( ret < 0 )
+    if( !mCreated )
+    {
+      // If it is not created, it skips creation.
+      ret = widget_instance_terminate_app( mInstanceId.c_str() );
+      if( ret < 0 )
+      {
+        DALI_LOG_ERROR("widget_instance_terminate_app() is failed. ret:%d, id:%s \n",ret, mInstanceId.c_str());
+      }
+    }
+    else
     {
-      DALI_LOG_ERROR("widget_instance_destroy() is failed. ret:%d, id:%s \n",ret, mInstanceId.c_str());
+      // Destroy widget instance because it will be not used anymore.
+      ret = widget_instance_destroy( mInstanceId.c_str() );
+      if( ret < 0  )
+      {
+        DALI_LOG_ERROR("widget_instance_destroy() is failed. ret:%d, id:%s \n",ret, mInstanceId.c_str());
+      }
     }
 
+    // To do : These signals will be deleted after removing TerminateWidget()
     Dali::WidgetView::WidgetView handle( GetOwner() );
     mWidgetTerminatedSignal.Emit( handle );
     mWidgetDeletedSignal.Emit( handle );
@@ -718,6 +723,11 @@ void WidgetView::SendWidgetEvent( int event )
     }
     case WIDGET_INSTANCE_EVENT_CREATE_ABORTED:
     {
+      // Set RetryState
+      DALI_LOG_ERROR("widget aborted. please re-run widget.");
+      ShowLoadingState( false );
+      ShowRetryState( true );
+      CloseRemoteSurface();
       mWidgetCreationAbortedSignal.Emit( handle );
       break;
     }
@@ -994,16 +1004,15 @@ void WidgetView::OnInitialize()
   char* previewPath = NULL;
   std::string previewImage;
   widget_size_type_e sizeType;
-  screen_connector_toolkit_ops ops;
 
   int ret = widget_instance_create( mWidgetId.c_str(), &instanceId );
   if( ret < 0 || !instanceId )
   {
-    DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::OnInitialize: widget_instance_create is failed [%s].\n", mWidgetId.c_str() );
+    DALI_LOG_ERROR("WidgetView::OnInitialize: widget_instance_create is failed [%s].\n", mWidgetId.c_str() );
     return;
   }
 
-  DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::OnInitialize: widget_instance_create is called. [widget id = %s, instance id = %s]\n",
+  DALI_LOG_RELEASE_INFO("WidgetView::OnInitialize: widget_instance_create is called. [widget id = %s, instance id = %s]\n",
                  mWidgetId.c_str(), instanceId );
 
   mInstanceId = instanceId;
@@ -1014,14 +1023,14 @@ void WidgetView::OnInitialize()
     widget_instance_h instance = widget_instance_get_instance( mWidgetId.c_str(), mInstanceId.c_str() );
     if( !instance )
     {
-      DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::OnInitialize: widget_instance_get_instance is failed. [%s]\n", mInstanceId.c_str() );
+      DALI_LOG_ERROR("WidgetView::OnInitialize: widget_instance_get_instance is failed. [%s]\n", mInstanceId.c_str() );
       return;
     }
     ret = widget_instance_set_period( instance, mUpdatePeriod );
     widget_instance_unref(instance);
     if( ret < 0 )
     {
-      DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::OnInitialize: widget_instance_set_period is failed [%s].\n", mWidgetId.c_str() );
+      DALI_LOG_ERROR("WidgetView::OnInitialize: widget_instance_set_period is failed [%s].\n", mWidgetId.c_str() );
       return;
     }
   }
@@ -1091,28 +1100,11 @@ void WidgetView::OnInitialize()
   mRetryText.SetProperty( Actor::Property::VISIBLE, false );
 
   // launch widget
-  mPid = widget_instance_launch( instanceId, (char *)mContentInfo.c_str(), mWidth, mHeight );
-  if( mPid < 0)
-  {
-
-    ShowLoadingState( false );
-    ShowRetryState( true );
-
-    DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::OnInitialize: widget_instance_launch is failed. [%s]\n", mWidgetId.c_str() );
-
-    // Emit signal
-    Dali::WidgetView::WidgetView handle( GetOwner() );
-    mWidgetCreationAbortedSignal.Emit( handle );
-
-    return;
-  }
-
-  ops.updated_cb = OnBufferUpdated;
-  ops.removed_cb = OnSurfaceRemoved;
-  ops.added_cb = OnBufferAdded;
-  mWatcherHandle = screen_connector_toolkit_add(&ops, (char *)instanceId, static_cast<screen_connector_screen_type_e>(SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET | SCREEN_CONNECTOR_SCREEN_TYPE_COMPONENT_BASED), this);
-  DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::OnInitialize: widget_instance_launch is called. [%s, mPid = %d]\n", mWidgetId.c_str(), mPid );
+  LaunchWidget();
+  Self().TouchedSignal().Connect( this, &WidgetView::OnTouch );
+  Self().WheelEventSignal().Connect( this, &WidgetView::OnWheelEvent );
 
+  // Add Accessibility
   Toolkit::DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
     return std::unique_ptr<Dali::Accessibility::Accessible>(
       new Toolkit::DevelControl::AccessibleImpl(actor, Dali::Accessibility::Role::EMBEDDED));
@@ -1166,7 +1158,7 @@ void WidgetView::OnWindowVisibilityChanged( Window window, bool visible )
   if( mPausedManually )
   {
     mPaused = ( needPaused || !mWindowVisible );
-    DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "Do not resume widget, because widget is paued manually \n");
+    DALI_LOG_RELEASE_INFO("Do not resume widget, because widget is paued manually \n");
     return;
   }
 
@@ -1190,7 +1182,7 @@ void WidgetView::OnUpdateArea( Dali::PropertyNotification& source )
   if( mPausedManually )
   {
     mPaused = needPaused;
-    DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "Do not resume widget, because widget is paued manually \n");
+    DALI_LOG_RELEASE_INFO("Do not resume widget, because widget is paued manually \n");
     return;
   }
 
@@ -1230,17 +1222,6 @@ void WidgetView::UpdateImageSource( tbm_surface_h source )
   }
 }
 
-void WidgetView::ConnectSignal( tizen_remote_surface* surface )
-{
-  if( mRenderer && surface )
-  {
-    mRemoteSurface = surface;
-
-    Self().TouchedSignal().Connect( this, &WidgetView::OnTouch );
-    Self().WheelEventSignal().Connect( this, &WidgetView::OnWheelEvent );
-  }
-}
-
 bool WidgetView::OnTouch( Dali::Actor actor, const Dali::TouchEvent& event )
 {
   if( event.GetPointCount() == 0 )
@@ -1248,11 +1229,6 @@ bool WidgetView::OnTouch( Dali::Actor actor, const Dali::TouchEvent& event )
     return false;
   }
 
-  if( mRemoteSurface == NULL )
-  {
-    return false;
-  }
-
   Device::Class::Type deviceType = event.GetDeviceClass( 0 );
   if( deviceType == Device::Class::MOUSE )
   {
@@ -1270,6 +1246,7 @@ bool WidgetView::OnWheelEvent( Dali::Actor actor, const Dali::WheelEvent& event
 {
   if( mRemoteSurface == NULL )
   {
+    DALI_LOG_ERROR("There is no RemoteSurface so it can not use WheelEvent");
     return false;
   }
   //ToDo: We should check TIZEN_INPUT_DEVICE_CLAS_MOUSE
@@ -1288,6 +1265,7 @@ bool WidgetView::OnKeyEvent( const Dali::KeyEvent& event )
 {
   if( mRemoteSurface == NULL )
   {
+    DALI_LOG_ERROR("There is no RemoteSurface so it can not use KeyEvent");
     return false;
   }
 
@@ -1389,12 +1367,12 @@ void WidgetView::CloseRemoteSurface()
 
 void WidgetView::ShowLoadingState( bool show )
 {
-  if( mPreviewImage && mPreviewVisible )
+  if( mPreviewImage && IsPreviewVisible() )
   {
     mPreviewImage.SetProperty( Actor::Property::VISIBLE, show );
   }
 
-  if( mLoadingText && mLoadingTextVisible )
+  if( mLoadingText && IsLoadingTextVisible() )
   {
     mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT,
                               ( mLoadingTextString.empty() )? GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) : mLoadingTextString );
@@ -1404,12 +1382,12 @@ void WidgetView::ShowLoadingState( bool show )
 
 void WidgetView::ShowRetryState( bool show )
 {
-  if( mPreviewImage && mPreviewVisible )
+  if( mPreviewImage && IsPreviewVisible() )
   {
     mPreviewImage.SetProperty( Actor::Property::VISIBLE, false );
   }
 
-  if( mRetryText && mRetryTextVisible )
+  if( mRetryText && IsRetryTextVisible() )
   {
     mRetryText.SetProperty( Toolkit::TextLabel::Property::TEXT,
                             ( mRetryTextString.empty() )? GET_LOCALE_TEXT( "IDS_HS_BODY_UNABLE_TO_LOAD_DATA_TAP_TO_RETRY" ) : mRetryTextString );
@@ -1535,8 +1513,9 @@ float WidgetView::TextPixelToPointSize( int pixelSize )
 void WidgetView::MouseIn( const Dali::TouchEvent& event )
 {
   Vector2 localPos = event.GetLocalPosition( 0 );
-
-  tizen_remote_surface_transfer_mouse_event( mRemoteSurface,
+  if( mRemoteSurface )
+  {
+    tizen_remote_surface_transfer_mouse_event( mRemoteSurface,
                                              TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_IN,
                                              0,
                                              0,
@@ -1551,11 +1530,14 @@ void WidgetView::MouseIn( const Dali::TouchEvent& event )
                                              "",
                                              event.GetTime()
                                            );
+  }
 }
 
 void WidgetView::MouseOut( const Dali::TouchEvent& event )
 {
-  tizen_remote_surface_transfer_mouse_event( mRemoteSurface,
+  if( mRemoteSurface )
+  {
+    tizen_remote_surface_transfer_mouse_event( mRemoteSurface,
                                              TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_OUT,
                                              0,
                                              0,
@@ -1570,6 +1552,8 @@ void WidgetView::MouseOut( const Dali::TouchEvent& event )
                                              "",
                                              event.GetTime()
                                            );
+
+  }
 }
 
 bool WidgetView::MouseEvent( const Dali::TouchEvent& event )
@@ -1610,6 +1594,12 @@ bool WidgetView::MouseEvent( const Dali::TouchEvent& event )
     }
   }
 
+  if( mRemoteSurface == NULL )
+  {
+    DALI_LOG_ERROR("There is no RemoteSurface so it can not use MouseEvent");
+    return false;
+  }
+
   Vector2 localPos = event.GetLocalPosition( 0 );
 
   tizen_remote_surface_transfer_mouse_event( mRemoteSurface,
@@ -1679,6 +1669,12 @@ bool WidgetView::TouchEvent( const Dali::TouchEvent& event )
     }
   }
 
+  if( mRemoteSurface == NULL )
+  {
+    DALI_LOG_ERROR("There is no RemoteSurface so it can not use TouchEvent");
+    return false;
+  }
+
   Vector2 localPos = event.GetLocalPosition( 0 );
 
   tizen_remote_surface_transfer_touch_event( mRemoteSurface,
@@ -1706,7 +1702,6 @@ void WidgetView::UpdateBuffer( struct tizen_remote_surface *surface, struct wl_b
     tizen_remote_surface_transfer_visibility( surface, TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE);
 
     CreateWidgetRenderer();
-    ConnectSignal( surface );
   }
 
   if( !buffer )
@@ -1740,23 +1735,37 @@ void WidgetView::UpdateBuffer( struct tizen_remote_surface *surface, struct wl_b
   mBuffer = buffer;
 }
 
+bool WidgetView::LaunchWidget()
+{
+  screen_connector_toolkit_ops ops;
+  ops.updated_cb = OnBufferUpdated;
+  ops.removed_cb = OnSurfaceRemoved;
+  ops.added_cb = OnBufferAdded;
+  mWatcherHandle = screen_connector_toolkit_add(&ops, (char *)mInstanceId.c_str(), static_cast<screen_connector_screen_type_e>(SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET | SCREEN_CONNECTOR_SCREEN_TYPE_COMPONENT_BASED), this);
+
+  mPid = widget_instance_launch( mInstanceId.c_str(), (char *)mContentInfo.c_str(), mWidth, mHeight );
+  if( mPid < 0)
+  {
+    ShowLoadingState( false );
+    ShowRetryState( true );
+
+    // Emit signal
+    Dali::WidgetView::WidgetView handle( GetOwner() );
+    mWidgetCreationAbortedSignal.Emit( handle );
+    DALI_LOG_RELEASE_INFO("WidgetView::LaunchWidget: widget_instance_launch is failed. [%s]\n", mWidgetId.c_str() );
+    return false;
+  }
+  return true;
+}
+
 void WidgetView::ReloadWidget()
 {
   std::string text;
   text = GetContentInfo();
   if( text == mContentInfo )
   {
-    screen_connector_toolkit_ops ops;
-    ops.updated_cb = OnBufferUpdated;
-    ops.removed_cb = OnSurfaceRemoved;
-    ops.added_cb = OnBufferAdded;
-    mWatcherHandle = screen_connector_toolkit_add(&ops, (char *)mInstanceId.c_str(), static_cast<screen_connector_screen_type_e>(SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET | SCREEN_CONNECTOR_SCREEN_TYPE_COMPONENT_BASED), this);
-
-    // launch widget again
-    mPid = widget_instance_launch( mInstanceId.c_str(), (char *)mContentInfo.c_str(), mWidth, mHeight );
-    if( mPid < 0)
+    if(!LaunchWidget())
     {
-      DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::ActivateFaultedWidget: widget_instance_launch is failed. [%s]\n", mWidgetId.c_str() );
       ActivateFaultedWidget();
     }
   }
index 641c23b0be593bda6767d4537b7a08012fd4ce9d..72de2a26a13ca03b9b29b0e0c53573d2b1416a64 100644 (file)
@@ -72,8 +72,6 @@ public:
    */
   void ActivateFaultedWidget();
 
-  void SendWidgetEvent( int event );
-
 public: // Internal API
 
   /**
@@ -104,64 +102,153 @@ public: // Internal API
    */
   static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
 
+  /**
+   * @brief Connects a callback function with the object's signals.
+   * @param[in] object The object providing the signal.
+   * @param[in] tracker Used to disconnect the signal.
+   * @param[in] signalName The signal to connect to.
+   * @param[in] functor A newly allocated FunctorDelegate.
+   * @return True if the signal was connected.
+   * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
+   */
   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
 
+  /**
+   * @brief Gets the Widget Id
+   */
   const std::string& GetWidgetId() const;
 
+  /**
+   * @brief Gets the Instance Id
+   */
   const std::string& GetInstanceId() const;
 
+  /**
+   * @brief Gets the ContentInfo
+   */
   const std::string& GetContentInfo();
 
+  /**
+   * @brief Gets the Title
+   */
   const std::string& GetTitle();
 
+  /**
+   * @brief Gets the update interval of the widget
+   */
   float GetUpdatePeriod() const;
 
+  /**
+   * @brief Sets the preview image is visible or not
+   */
   void SetPreviewVisible( bool visible );
 
+  /**
+   * @brief Returns the preview visible status
+   */
   bool IsPreviewVisible();
 
+  /**
+   * @brief Sets the Loading Text is visible or not
+   */
   void SetLoadingTextVisible( bool visible );
 
-  void SetRetryTextVisible( bool visible );
-
+  /**
+   * @brief Returns the LoadingText visible status
+   */
   bool IsLoadingTextVisible();
 
+  /**
+   * @brief Sets the RetryText is visible status
+   */
+  void SetRetryTextVisible( bool visible );
+
+  /**
+   * @brief Returns the RetryText visible status
+   */
   bool IsRetryTextVisible();
 
+  /**
+   * @brief Returns the status of widget is faulted
+   */
   bool IsWidgetFaulted();
 
-  void SetPermanentDelete( bool permanentDelete );
+  /**
+   * @brief Creates a Widget Renderer
+   */
+  void CreateWidgetRenderer();
 
+  /**
+   * @brief Removes a Widget Renderer
+   */
   void RemoveWidgetRenderer();
 
+  /**
+   * @brief Sets the flag to permanently delete the widget
+   * @DEPRECATED It will be deprecated.
+   */
+  void SetPermanentDelete( bool permanentDelete );
+
+  /**
+   * @brief Returns the flag about permanently delete the widget
+   * @DEPRECATED It will be deprecated.
+   */
   bool IsPermanentDelete();
 
+  /**
+   * @brief Checks Widget Renderer exist
+   */
   bool IsWidgetRenderer();
 
+  /**
+   * @brief Updates image source when buffer is updated
+   */
   void UpdateImageSource( tbm_surface_h source );
 
-  void CreateWidgetRenderer();
-
-  void ConnectSignal( tizen_remote_surface* surface );
-
+  /**
+   * @brief Callback for touch event
+   */
   bool OnTouch( Dali::Actor actor, const Dali::TouchEvent& event );
 
+  /**
+   * @brief Callback for wheel event
+   */
   bool OnWheelEvent( Dali::Actor actor, const Dali::WheelEvent& event );
 
+  /**
+   * @brief Close remote surface and release related resources
+   */
   void CloseRemoteSurface();
 
-  void SetReloadFlag( bool reload );
-
+  /**
+   * @brief Sets the Loading Text Property Map
+   */
   void SetLoadingTextPropertyMap( Dali::Property::Map map );
 
+  /**
+   * @brief Sets the Retry Text Property Map
+   */
   void SetRetryTextPropertyMap( Dali::Property::Map map );
 
+  /**
+   * @brief Sets the Effect Property Map
+   */
   void SetEffectPropertyMap( Dali::Property::Map map );
 
+  /**
+   * @brief Sets the Loading status
+   */
   void ShowLoadingState( bool show );
 
+  /**
+   * @brief Sets the Retry status
+   */
   void ShowRetryState( bool show );
 
+  /**
+   * @brief Terminate a widget
+   * @DEPRECATED it will be deprecated. plase instead RemoveWidget()
+   */
   bool TerminateWidget();
 
   void MouseIn( const Dali::TouchEvent& event );
@@ -172,10 +259,30 @@ public: // Internal API
 
   bool TouchEvent( const Dali::TouchEvent& event );
 
+  /**
+   * @brief Update Buffer for rendering. this api is called when surface is updated from widget
+   */
   void UpdateBuffer( struct tizen_remote_surface *surface, struct wl_buffer *buffer, int32_t fd);
 
+public: // Internal API for WidgetViewManager
+
+  /**
+   * @brief Send a event from WidgetViewManager to WidgetView
+   *
+   * @param[in] event The event for widget
+   */
+  void SendWidgetEvent( int event );
+
+  /**
+   * @brief Reload the Widget when widget instance is dead
+   */
   void ReloadWidget();
 
+  /**
+   * @brief Remove the Widget from WidgetViewManager
+   */
+  bool RemoveWidget();
+
 public: //Signals
 
   /**
@@ -299,10 +406,15 @@ private:
   bool ResumeWidgetInternally();
 
   /**
-   * @brief check WidgetView is out of screen.
+   * @brief check WidgetView is out of screen
    */
   bool IsOutOfScreen();
 
+  /**
+   * @brief Call a widget_instance_launch and add it to screen connector
+   */
+  bool LaunchWidget();
+
   /**
    * @brief Callback when the visibility of the window is changed.
    */
@@ -321,14 +433,6 @@ private:
 
 private:
 
-  Toolkit::ImageView mPreviewImage;   ///< Preview image
-  Toolkit::TextLabel mLoadingText;      ///< Loading text
-  Toolkit::TextLabel mRetryText;      ///< Retry text
-  Dali::Actor mPreviewActor;
-  Dali::Actor mStateTextActor;
-  Dali::NativeImageSourcePtr mImageSource;
-  Dali::Texture mNativeTexture;
-  Dali::TextureSet mTextureSet;
   Dali::Renderer mRenderer;
 
   std::string mWidgetId;
@@ -341,26 +445,29 @@ private:
   int mPid;
   float mUpdatePeriod;
 
-  bool mPreviewVisible;
-
-  bool mLoadingTextVisible;
-  std::string mLoadingTextString;
-
-  bool mRetryTextVisible;
-  std::string mRetryTextString;
-  bool mRetryState;
-
-  bool mPermanentDelete;
-  screen_connector_toolkit_h mWatcherHandle;
-  tizen_remote_surface* mRemoteSurface;
-  wl_buffer* mBuffer;
-  bool mCreated;
-  bool mResizeRequired;
-  bool mPaused;
-  bool mPausedManually;
-  bool mWindowVisible;
-
-  Dali::Property::Map mEffectPropertyMap;
+  Toolkit::ImageView mPreviewImage;          ///< Preview image
+  Toolkit::TextLabel mLoadingText;           ///< Loading text
+  Toolkit::TextLabel mRetryText;             ///< Retry text
+  Dali::Actor mPreviewActor;                 ///< Preview Actor
+  Dali::Actor mStateTextActor;               ///< StateText Actor
+  std::string mLoadingTextString;            ///< Loading text
+  std::string mRetryTextString;              ///< Retry text
+  bool mRetryState;                          ///< Status requiring re-launch
+
+  Dali::NativeImageSourcePtr mImageSource;   ///< ImageSource for rendenerer
+  bool mPermanentDelete;                     ///< Check whether widget is deleted permanently.
+  screen_connector_toolkit_h mWatcherHandle; ///< Handle for screen connector
+  tizen_remote_surface* mRemoteSurface;      ///< RemoteSurface for controlling events and visibillity
+  wl_buffer* mBuffer;                        ///< Buffer for screen_connector. WidgetView need to release previous buffer
+  bool mCreated;                             ///< Check whether widget instance is created or not
+  bool mResizeRequired;                      ///< Check whether widget instance need to resize.
+  bool mPaused;                              ///< Check whether widget is paused or not
+  bool mPausedManually;                      ///< Check whether widget is paused or not by application
+  bool mWindowVisible;                       ///< Check whether window is visible or not
+
+  Dali::Property::Map mEffectPropertyMap;    ///< Shader for effect
+
+  // Notification for property change confirmation
   Dali::PropertyNotification mPositionUpdateNotification;
   Dali::PropertyNotification mSizeUpdateNotification;
   Dali::PropertyNotification mScaleUpdateNotification;
index 77ae3015b68c238d5d97138c031823b6851e4e80..6be28eb04c56e846e85b97121527887f69c413aa 100644 (file)
@@ -133,7 +133,7 @@ WidgetViewManagerPtr WidgetViewManager::New( Application application, const std:
   // Second-phase init of the implementation
   if( impl->Initialize( application, name ) != WIDGET_ERROR_NONE )
   {
-    DALI_LOG_INFO( gWidgetViewManagerLogging, Debug::Verbose, "WidgetViewManager::New: Fail to create WidgetViewManager.\n" );
+    DALI_LOG_ERROR("WidgetViewManager::New: Fail to create WidgetViewManager.\n" );
     return NULL;
   }
 
@@ -211,6 +211,38 @@ Dali::WidgetView::WidgetView WidgetViewManager::AddWidget( const std::string& wi
   return widgetView;
 }
 
+bool WidgetViewManager::RemoveWidget( Dali::WidgetView::WidgetView widgetView )
+{
+  bool ret = true;
+  std::string instanceId;
+  Dali::Property::Value value = widgetView.GetProperty( Dali::WidgetView::WidgetView::Property::INSTANCE_ID );
+
+  if( value.Get( instanceId ) && !instanceId.empty() && mWidgetViewContainer.size() > 0 )
+  {
+    WidgetViewIter iter = mWidgetViewContainer.find( instanceId );
+    if( iter != mWidgetViewContainer.end() )
+    {
+      Dali::WidgetView::WidgetView widgetView = iter->second;
+      mWidgetViewContainer.erase( iter );
+      ret = Dali::WidgetView::GetImplementation( widgetView ).RemoveWidget();
+    }
+
+    // Delete WidgetInstance
+    auto widgetInstance = std::find_if( mInstanceIdContainer.begin(),
+                                        mInstanceIdContainer.end(),
+                                        [instanceId]( const InstanceIdPair &pair )
+                                        { return (pair.second == instanceId); } );
+
+    if(widgetInstance != mInstanceIdContainer.end())
+    {
+      mInstanceIdContainer.erase(widgetInstance);
+    }
+  }
+
+  return ret;
+
+}
+
 void WidgetViewManager::OnTerminatedWidget( Dali::WidgetView::WidgetView widgetView )
 {
   std::string instanceId;
@@ -235,7 +267,6 @@ void WidgetViewManager::OnTerminatedWidget( Dali::WidgetView::WidgetView widgetV
       mInstanceIdContainer.erase(widgetInstance);
     }
   }
-
   DALI_LOG_INFO( gWidgetViewManagerLogging, Debug::Verbose, "WidgetViewManager::OnTerminatedWidget: Widget is deleted!\n" );
 }
 
@@ -271,7 +302,7 @@ int WidgetViewManager::WidgetLifeCycleCallback(const char *appid, widget_lifecyc
     {
       if( ((instanceIter).first).compare(appid) == 0)
       {
-        DALI_LOG_INFO( gWidgetViewManagerLogging, Debug::Verbose, "WidgetViewManager::WidgetLifeCycleCallback: Call ReloadWidget [%s, %s]\n",appid, instanceIter.second);
+        DALI_LOG_RELEASE_INFO("WidgetViewManager::WidgetLifeCycleCallback: Call ReloadWidget [%s, %s]\n",appid, instanceIter.second);
         WidgetViewIter iter = widgetViewManager->mWidgetViewContainer.find( std::string((instanceIter).second ) );
         Dali::WidgetView::WidgetView widgetView = iter->second;
         Dali::WidgetView::GetImplementation( widgetView ).ReloadWidget();
index aa7b8179f1ea6ca3cbc7df066c8e78af6af383d4..160e9d59eda61a8a263630ade446acc112bee42a 100644 (file)
@@ -54,6 +54,11 @@ public:
    */
   Dali::WidgetView::WidgetView AddWidget( const std::string& widgetId, const std::string& contentInfo, int width, int height, float updatePeriod );
 
+  /**
+   * @copydoc Dali::WidgetView::WidgetViewManager::RemoveWidget()
+   */
+  bool RemoveWidget( Dali::WidgetView::WidgetView widgetView );
+
 private:
 
   /**
index 283009e21ae68ec5942e5cbbb49da1ec9ae0c838..53d6f6fa36a2bd7c912d2e718fd375c65c0e09d8 100644 (file)
@@ -135,6 +135,7 @@ public:
 
       /**
        * @brief name "permanentDelete", type boolean
+       * @DEPRECATED It will be deprecated.
        * @since_tizen 3.0
        */
       PERMANENT_DELETE,
index 26ed61e241ab2105aa287715a86974ec437ad25a..e89a3b2af7abbdc59b4017e3391456b9c88b4126 100644 (file)
@@ -70,6 +70,11 @@ WidgetView WidgetViewManager::AddWidget( const std::string& widgetId, const std:
   return GetImplementation(*this).AddWidget( widgetId, contentInfo, width, height, updatePeriod );
 }
 
+bool WidgetViewManager::RemoveWidget( WidgetView widgetView )
+{
+  return GetImplementation(*this).RemoveWidget( widgetView );
+}
+
 } // namespace WidgetView
 
 } // namespace Dali
index b99dbdd54e36ee7cd942f0e428d05e39def0bb70..1c614510577a9f6248a099619410e7400f2eaf23 100644 (file)
@@ -123,6 +123,17 @@ public:
    */
   WidgetView AddWidget( const std::string& widgetId, const std::string& contentInfo, int width, int height, float updatePeriod );
 
+  /**
+   * @brief Removes the widget view object
+   *
+   * @since_tizen 6.5
+   * @privlevel public
+   * @privilege %http://tizen.org/privilege/widget.viewer
+   * @param[in] widgetView The widget view.
+   * @return true on success, false otherwise.
+   */
+  bool RemoveWidget( WidgetView widgetView );
+
 public: // Not intended for application developers
 
   /**