widgets/widgetapp/src/WidgetUiObserver.cpp
changeset 13 10e98eab6f85
parent 8 7c90e6132015
child 16 a359256acfc6
equal deleted inserted replaced
8:7c90e6132015 13:10e98eab6f85
   188             iWindow->WindowManager().View()->CbaGroup()->IsVisible())
   188             iWindow->WindowManager().View()->CbaGroup()->IsVisible())
   189         {
   189         {
   190         TBrCtlDefs::TBrCtlElementType elementtype =
   190         TBrCtlDefs::TBrCtlElementType elementtype =
   191                       iWindow->WindowManager().ActiveWindow()->Engine()->FocusedElementType();
   191                       iWindow->WindowManager().ActiveWindow()->Engine()->FocusedElementType();
   192         // Check if focused element type is editing type
   192         // Check if focused element type is editing type
   193         if ((elementtype != TBrCtlDefs::EElementActivatedInputBox) &&
   193         if ((elementtype == TBrCtlDefs::EElementActivatedInputBox) ||
   194                        (elementtype != TBrCtlDefs::EElementActivatedObjectBox))
   194                        (elementtype == TBrCtlDefs::EElementActivatedObjectBox))
       
   195             {
       
   196             iWindow->WindowManager().View()->ShowActivatedObject( ETrue );
       
   197             }
       
   198         else 
   195             {
   199             {
   196             iWindow->WindowManager().View()->ShowActivatedObject( EFalse );
   200             iWindow->WindowManager().View()->ShowActivatedObject( EFalse );
   197             }        
   201             }        
   198         }
   202         }
   199     }
   203     }
   457 HBufC* CWidgetUiObserver::RecognizeLC( const TDesC& aFileName, const TDesC8& aData )
   461 HBufC* CWidgetUiObserver::RecognizeLC( const TDesC& aFileName, const TDesC8& aData )
   458     {
   462     {
   459     TDataRecognitionResult dataType;
   463     TDataRecognitionResult dataType;
   460     RApaLsSession apaSession;
   464     RApaLsSession apaSession;
   461     TInt ret;
   465     TInt ret;
   462     HBufC* contentTypeString = KNullDesC().AllocL();
       
   463 
   466 
   464     CleanupClosePushL(apaSession);
   467     CleanupClosePushL(apaSession);
   465     User::LeaveIfError( apaSession.Connect() );
   468     User::LeaveIfError( apaSession.Connect() );
   466 
   469 
   467     // Ask the application architecture to find the file type
   470     // Ask the application architecture to find the file type
   468     ret = apaSession.RecognizeData( aFileName, aData, dataType );
   471     ret = apaSession.RecognizeData( aFileName, aData, dataType );
   469     apaSession.Close();
   472     apaSession.Close();
   470     CleanupStack::PopAndDestroy(1, &apaSession);
   473     CleanupStack::PopAndDestroy(1, &apaSession);
   471     
   474     
       
   475     TPtrC8 mimeTypePtr = dataType.iDataType.Des8();
       
   476     TInt len = mimeTypePtr.Length() + 1;
       
   477     HBufC* contentTypeString = HBufC::NewLC( len );;
       
   478 
   472     if ( ret == KErrNone &&
   479     if ( ret == KErrNone &&
   473         ( dataType.iConfidence == CApaDataRecognizerType::ECertain ) ||
   480         ( dataType.iConfidence == CApaDataRecognizerType::ECertain ) ||
   474         ( dataType.iConfidence == CApaDataRecognizerType::EProbable ) )
   481         ( dataType.iConfidence == CApaDataRecognizerType::EProbable ) )
   475         {
   482         {
   476         // If the file type was found, try to match it to a known file type
   483         // If the file type was found, try to match it to a known file type
   477         TPtrC8 mimeTypePtr = dataType.iDataType.Des8();
       
   478         TInt len = mimeTypePtr.Length() + 1;
       
   479         contentTypeString = HBufC::NewL( len );
       
   480         contentTypeString->Des().Copy( mimeTypePtr );
   484         contentTypeString->Des().Copy( mimeTypePtr );
   481         contentTypeString->Des().ZeroTerminate();
   485         contentTypeString->Des().ZeroTerminate();
   482         }
   486         }
   483 
       
   484     CleanupStack::PushL( contentTypeString );
       
   485 
   487 
   486     return contentTypeString;
   488     return contentTypeString;
   487     }
   489     }
   488 
   490 
   489 // -----------------------------------------------------------------------------
   491 // -----------------------------------------------------------------------------