Modified creation aborted and faulted signal
authortaeyoon0.lee <taeyoon0.lee@samsung.com>
Thu, 16 Feb 2017 04:38:53 +0000 (13:38 +0900)
committertaeyoon0.lee <taeyoon0.lee@samsung.com>
Thu, 1 Jun 2017 04:39:38 +0000 (13:39 +0900)
 - When Faulted, internal pid should be changed
 - When touched after aborted/faulted, re-launch widget app

Change-Id: I2971a36ea6e7c4197c925ee78c3ebbec58eefe81

internal/widget_view/widget_view_impl.cpp
internal/widget_view/widget_view_impl.h

index 2158c97..da1764d 100644 (file)
@@ -138,7 +138,7 @@ static void OnSurfaceRemoved( const char *appid, const char *instance_id, const
 {
   Dali::WidgetView::Internal::WidgetView* widgetView = static_cast< Dali::WidgetView::Internal::WidgetView* >( data );
 
-  if( widgetView && !widgetView->GetInstanceId().empty() )
+  if( widgetView && !widgetView->IsWidgetFaulted() )
   {
     widgetView->CloseRemoteSurface();
     widgetView->RemoveWidgetImage();
@@ -174,7 +174,8 @@ WidgetView::WidgetView()
   mUpdatePeriod( 0.0 ),
   mPreviewVisible( true ),
   mLoadingTextVisible( true ),
-  mTapTextVisible( true ),
+  mRetryTextVisible( true ),
+  mRetryState( false ),
   mPermanentDelete( false ),
   mWatcherHandle( NULL ),
   mRemoteSurface( NULL )
@@ -193,7 +194,8 @@ WidgetView::WidgetView( const std::string& widgetId, const std::string& contentI
   mUpdatePeriod( updatePeriod ),
   mPreviewVisible( true ),
   mLoadingTextVisible( true ),
-  mTapTextVisible( true ),
+  mRetryTextVisible( true ),
+  mRetryState( false ),
   mPermanentDelete( false ),
   mWatcherHandle( NULL ),
   mRemoteSurface( NULL )
@@ -319,15 +321,15 @@ bool WidgetView::IsPreviewVisible()
 
 void WidgetView::SetLoadingTextVisible( bool visible )
 {
-  if( mStateText && mLoadingTextVisible != visible )
+  if( mLoadingText && mLoadingTextVisible != visible )
   {
     mLoadingTextVisible = visible;
 
     if( visible )
     {
-      mStateText.SetProperty( Toolkit::TextLabel::Property::TEXT, GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) );
+      mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT, GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) );
     }
-    mStateText.SetVisible( visible );
+    mLoadingText.SetVisible( visible );
   }
 }
 
@@ -341,7 +343,7 @@ void WidgetView::ActivateFaultedWidget()
   if( mPid < 0 )
   {
     // Enable preview and loading text
-    ShowTapWidgetState( false );
+    ShowRetryState( false );
     ShowLoadingState( true );
 
     // launch widget again
@@ -351,7 +353,7 @@ void WidgetView::ActivateFaultedWidget()
       DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::ActivateFaultedWidget: widget_instance_launch is failed. [%s]\n", mWidgetId.c_str() );
 
       ShowLoadingState( false );
-      ShowTapWidgetState( true );
+      ShowRetryState( true );
 
       // Emit signal
       Dali::WidgetView::WidgetView handle( GetOwner() );
@@ -360,6 +362,12 @@ void WidgetView::ActivateFaultedWidget()
       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(), SCREEN_CONNECTOR_SCREEEN_TYPE_WIDGET, this);
+
     DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::ActivateFaultedWidget: widget_instance_launch is called. [%s, mPid = %d]\n", mWidgetId.c_str(), mPid );
   }
 }
@@ -464,6 +472,8 @@ void WidgetView::SendWidgetEvent( int event )
     }
     case WIDGET_INSTANCE_EVENT_FAULT:
     {
+      mPid = -1;
+      ShowRetryState( true );
       mWidgetFaultedSignal.Emit( handle );
       break;
     }
@@ -755,25 +765,39 @@ void WidgetView::OnInitialize()
   mStateTextActor.SetAnchorPoint( AnchorPoint::CENTER );
   mStateTextActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
 
-  // State text
-  mStateText = Toolkit::TextLabel::New( GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) );
-  mStateText.SetParentOrigin( ParentOrigin::CENTER );
-  mStateText.SetAnchorPoint( AnchorPoint::CENTER );
-  mStateText.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
-  mStateText.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
-  mStateText.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Dali::Color::WHITE );
-  mStateText.SetProperty( Toolkit::TextLabel::Property::FONT_STYLE, "Bold" );
-  mStateText.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, TextPixelToPointSize( DEFAULT_FONT_PIXEL_SIZE ) );
+  // Loading text
+  mLoadingText = Toolkit::TextLabel::New( GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) );
+  mLoadingText.SetParentOrigin( ParentOrigin::CENTER );
+  mLoadingText.SetAnchorPoint( AnchorPoint::CENTER );
+  mLoadingText.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+  mLoadingText.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
+  mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Dali::Color::WHITE );
+  mLoadingText.SetProperty( Toolkit::TextLabel::Property::FONT_STYLE, "Bold" );
+  mLoadingText.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, TextPixelToPointSize( DEFAULT_FONT_PIXEL_SIZE ) );
 
   mPreviewActor.Add( mStateTextActor );
-  mStateTextActor.Add( mStateText );
+  mStateTextActor.Add( mLoadingText );
+
+  // Retry text
+  mRetryText = Toolkit::TextLabel::New( GET_LOCALE_TEXT( "IDS_HS_BODY_UNABLE_TO_LOAD_DATA_TAP_TO_RETRY" ) );
+  mRetryText.SetParentOrigin( ParentOrigin::CENTER );
+  mRetryText.SetAnchorPoint( AnchorPoint::CENTER );
+  mRetryText.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+  mRetryText.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
+  mRetryText.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Dali::Color::WHITE );
+  mRetryText.SetProperty( Toolkit::TextLabel::Property::FONT_STYLE, "Bold" );
+  mRetryText.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, TextPixelToPointSize( DEFAULT_FONT_PIXEL_SIZE ) );
+
+  mStateTextActor.Add( mRetryText );
+  mRetryText.SetVisible( false );
 
   // launch widget
   mPid = widget_instance_launch( instanceId, (char *)mContentInfo.c_str(), mWidth, mHeight );
   if( mPid < 0)
   {
 
-    ShowTapWidgetState( true );
+    ShowLoadingState( false );
+    ShowRetryState( true );
 
     DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::OnInitialize: widget_instance_launch is failed. [%s]\n", mWidgetId.c_str() );
 
@@ -837,7 +861,7 @@ bool WidgetView::OnTouch( Dali::Actor actor, const Dali::TouchData& event )
 {
   tizen_remote_surface_event_type type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_NONE;
 
-  if( event.GetPointCount() == 0 || mRemoteSurface == NULL )
+  if( event.GetPointCount() == 0 )
   {
     return false;
   }
@@ -847,6 +871,13 @@ bool WidgetView::OnTouch( Dali::Actor actor, const Dali::TouchData& event )
     case Dali::PointState::UP:
     {
       type = TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_UP;
+
+      if( mRetryState )
+      {
+        ActivateFaultedWidget();
+        return false;
+      }
+
       break;
     }
     case Dali::PointState::DOWN:
@@ -865,6 +896,11 @@ bool WidgetView::OnTouch( Dali::Actor actor, const Dali::TouchData& event )
     }
   }
 
+  if( mRemoteSurface == NULL )
+  {
+    return false;
+  }
+
   int button = 1;
 
   if( type == TIZEN_REMOTE_SURFACE_EVENT_TYPE_MOUSE_MOVE )
@@ -953,8 +989,13 @@ float WidgetView::GetWidthForHeight( float height )
 
 void WidgetView::CloseRemoteSurface()
 {
-  screen_connector_toolkit_remove( mWatcherHandle );
+  if( mWatcherHandle != NULL )
+  {
+    screen_connector_toolkit_remove( mWatcherHandle );
+    mWatcherHandle = NULL;
+  }
   mRemoteSurface = NULL;
+  mPid = -1;
 }
 
 void WidgetView::ShowLoadingState( bool show )
@@ -964,37 +1005,38 @@ void WidgetView::ShowLoadingState( bool show )
     mPreviewImage.SetVisible( show );
   }
 
-  if( mStateText && mLoadingTextVisible )
+  if( mLoadingText && mLoadingTextVisible )
   {
-    mStateText.SetProperty( Toolkit::TextLabel::Property::TEXT, GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) );
-    mStateText.SetVisible( show );
+    mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT, GET_LOCALE_TEXT( "IDS_ST_POP_LOADING_ING" ) );
+    mLoadingText.SetVisible( show );
   }
 }
 
-void WidgetView::ShowTapWidgetState( bool show )
+void WidgetView::ShowRetryState( bool show )
 {
   if( mPreviewImage && mPreviewVisible )
   {
     mPreviewImage.SetVisible( false );
   }
 
-  if( mStateText && mTapTextVisible )
+  if( mRetryText && mRetryTextVisible )
   {
-    mStateText.SetProperty( Toolkit::TextLabel::Property::TEXT, GET_LOCALE_TEXT( "IDS_HS_BODY_UNABLE_TO_LOAD_DATA_TAP_TO_RETRY" ) );
-    mStateText.SetVisible( show );
+    mRetryText.SetProperty( Toolkit::TextLabel::Property::TEXT, GET_LOCALE_TEXT( "IDS_HS_BODY_UNABLE_TO_LOAD_DATA_TAP_TO_RETRY" ) );
+    mRetryText.SetVisible( show );
+    mRetryState = show;
   }
 }
 
 void WidgetView::SetLoadingTextPropertyMap( Property::Map map )
 {
-  if( mStateText )
+  if( mLoadingText )
   {
     Property::Value* fontStyle = map.Find( FONT_STYLE );
     std::string style;
 
     if( fontStyle && fontStyle->Get( style ) )
     {
-      mStateText.SetProperty( Toolkit::TextLabel::Property::FONT_STYLE, style );
+      mLoadingText.SetProperty( Toolkit::TextLabel::Property::FONT_STYLE, style );
     }
 
     Property::Value* textPointSize = map.Find( TEXT_POINT_SIZE );
@@ -1002,7 +1044,7 @@ void WidgetView::SetLoadingTextPropertyMap( Property::Map map )
 
     if( textPointSize && textPointSize->Get( size ) )
     {
-      mStateText.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, size );
+      mLoadingText.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, size );
     }
 
     Property::Value* textColor = map.Find( TEXT_COLOR );
@@ -1010,7 +1052,7 @@ void WidgetView::SetLoadingTextPropertyMap( Property::Map map )
 
     if( textColor && textColor->Get( color ) )
     {
-      mStateText.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, color );
+      mLoadingText.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, color );
     }
   }
 }
index c43f929..e27786f 100644 (file)
@@ -146,7 +146,7 @@ public: // Internal API
 
   void ShowLoadingState( bool show );
 
-  void ShowTapWidgetState( bool show );
+  void ShowRetryState( bool show );
 
   void TerminateWidget();
 
@@ -252,7 +252,8 @@ private:
 
   Toolkit::ImageView mWidgetImageView;     ///< Widget content
   Toolkit::ImageView mPreviewImage;   ///< Preview image
-  Toolkit::TextLabel mStateText;      ///< State text
+  Toolkit::TextLabel mLoadingText;      ///< Loading text
+  Toolkit::TextLabel mRetryText;      ///< Retry text
   Dali::Actor mPreviewActor;
   Dali::Actor mStateTextActor;
   Dali::NativeImageSourcePtr mImageSource;
@@ -269,7 +270,8 @@ private:
 
   bool mPreviewVisible;
   bool mLoadingTextVisible;
-  bool mTapTextVisible;
+  bool mRetryTextVisible;
+  bool mRetryState;
   bool mPermanentDelete;
   screen_connector_toolkit_h mWatcherHandle;
   tizen_remote_surface* mRemoteSurface;