Exemplo n.º 1
0
QString Camera::symbianCapture(int width, int height)
{
    CNewFileServiceClient* fileClient = NewFileServiceFactory::NewClientL();
    CleanupStack::PushL(fileClient);

    CDesCArray* fileNames = new (ELeave) CDesCArrayFlat(1);
    CleanupStack::PushL(fileNames);

    CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC();

    TSize resolution = TSize(width, height);
    TPckgBuf<TSize> buffer( resolution );
    TAiwVariant resolutionVariant( buffer );
    TAiwGenericParam param( EGenericParamResolution, resolutionVariant );
    paramList->AppendL( param );

    const TUid KUidCamera = { 0x101F857A }; // Camera UID for S60 5th edition

    TBool result = fileClient->NewFileL( KUidCamera, *fileNames, paramList,
                               ENewFileServiceImage, EFalse );

    QString ret;

    if (result) {
        TPtrC fileName=fileNames->MdcaPoint(0);
        ret = QString((QChar*) fileName.Ptr(), fileName.Length());
    }
     qDebug() << ret;
    CleanupStack::PopAndDestroy(3);

    return ret;
}
Exemplo n.º 2
0
// ---------------------------------------------------------------------------
// 
// ---------------------------------------------------------------------------
//
TBool CAiwImagePrintIf::IsPrintingSupported( const CAiwGenericParamList& aInParamList )
    {  
    TInt index(0);
    FLOG(_L("[CAiwImagePrintIf]  IsPrintingSupported "));
    const TAiwGenericParam* param = aInParamList.FindFirst( index, EGenericParamMIMEType );
	TBool printable( EFalse );
	
    if ( index == KErrNotFound )	
        {    
        index = 0;
   	    const TAiwGenericParam* param = aInParamList.FindFirst(index, EGenericParamFile, EVariantTypeDesC);

        //Check if there is any printable images available. At least image must be
        //JPEG and it also must be unprotected to be printable.
        while ( index != KErrNotFound && !printable)
            {
            FLOG(_L("[CAiwImagePrintIf]  IsPrintingSupported 3"));
            TRAP_IGNORE( printable = IsPrintingSupportedL( param->Value().AsDes() ));
   	        param = aInParamList.FindNext(index, EGenericParamFile, EVariantTypeDesC);        
            }
        FTRACE(FPrint(_L("[CAiwImagePrintIf] IsPrintingSupported  printable is  %d"), printable ));     
        return printable;    
        }
	
	while ( index != KErrNotFound && !printable )
		{
	   	if ( param->Value().TypeId() == EVariantTypeDesC &&
			 param->Value().AsDes() == KJpegFileType16 )
	    	{
	    	// MIME-type parameter follows filename parameter in parameter list.
	    	// Because of that previous item in list is used.
	    	if (index > 0)
	    	    {   
	    	    FLOG(_L("[CAiwImagePrintIf]  IsPrintingSupported 5")); 	    
    	      	printable = !IsProtected( aInParamList[index-1].Value().AsDes() );
	    	    }
	    	}

	    if ( !printable )
	        {        
    	   	param = aInParamList.FindNext(index, EGenericParamMIMEType);
	        }
       	}    
	FTRACE(FPrint(_L("[CAiwImagePrintIf] IsPrintingSupported 2 printable is  %d"), printable ));     
    return printable;	 
    }
// -----------------------------------------------------------------------------
// Implements getting a AIW parameter as descriptor
// -----------------------------------------------------------------------------
//
TPtrC CAknsWallpaperPlugin::GetAiwParamAsDescriptor(
        const CAiwGenericParamList& aParamList,
        TGenericParamId aParamType)
    {
    TInt index = 0;
    const TAiwGenericParam* genericParam = NULL;
    genericParam = aParamList.FindFirst(
        index,
        aParamType,
        EVariantTypeDesC);

    if (index >= 0 && genericParam)
        {
        // Get the data
        return genericParam->Value().AsDes();
        }
    else
        {
        return KNullDesC();
        }
    }
// ---------------------------------------------------------------------------
// 
// ---------------------------------------------------------------------------
//
void CAiwPrintingProvider::DoHandleCmdL(TInt aMenuCmdId,
                            const CAiwGenericParamList& aInParamList,
                            CAiwGenericParamList& aOutParamList,
                            TUint /*aCmdOptions*/,
                            const MAiwNotifyCallback* aCallback)
    {
    if ( aMenuCmdId == KAiwCmdPrint || aMenuCmdId == KAiwCmdPrintPreview  )
        {
        FLOG(_L("[CAiwPrintingProvider]<<<  DoHandleCmdL"));
        
        CAiwGenericParamList* checkedParams = CAiwGenericParamList::NewL();
        
        iConsumerInParamList = &aInParamList;
        iConsumerOutParamList = &aOutParamList;
        iConsumerCallback = aCallback;
        
        TInt index( 0 );
	    const TAiwGenericParam* param = aInParamList.FindFirst(index,
	            EGenericParamFile,
	            EVariantTypeDesC);
	    while ( index != KErrNotFound )
			{
	        TFileName filename( param->Value().AsDes() );
 	        TInt err = KErrNone;
	        TBool result = EFalse;
	        TRAP( err, result = IsPrintingSupportedL( filename ) );
	        if ( err == KErrNone && result )
	        	{
	            FLOG(_L("[CAiwPrintingProvider] DoHandleCmdL; supported file"));
	        	checkedParams->AppendL(*param);
	        	}
	        else
	        	{
	        	FLOG(_L("[CAiwPrintingProvider] DoHandleCmdL; not supported"));
	        	++iNumberOfUnSuppFiles;
	        	iUnsupportedFiles = ETrue;
	        	}	
	        param = aInParamList.FindNext(index,
	            EGenericParamFile,
	            EVariantTypeDesC);
	        }
   
                
		FTRACE(FPrint(_L("[CAiwPrintingProvider] UnSuppFiles is %d"), iNumberOfUnSuppFiles )); 

		RFileWriteStream stream;
	  	CleanupClosePushL(stream);
		if((stream.Replace(iEikEnv.FsSession(), *iUnsuppFileName ,EFileWrite)) == KErrNone)
			{
			stream.WriteInt16L(iNumberOfUnSuppFiles);
			stream.CommitL();
			}
		CleanupStack::PopAndDestroy(&stream); 
		
        FLOG(_L("[IMAGEPRINTUI]<<< CAiwPrintingProvider;Save iUnsupportedFiles  is done"));
	
        
        RFileWriteStream writeStream;
        User::LeaveIfError( writeStream.Replace(iEikEnv.FsSession(),
        										*iPrintFileName , EFileWrite) );
        writeStream.PushL();
        checkedParams->ExternalizeL(writeStream);
        writeStream.CommitL();
        CleanupStack::PopAndDestroy( &writeStream );
        
        iNumberOfUnSuppFiles = 0;
        delete checkedParams;
        checkedParams = NULL;
        
        LaunchImagePrintApplicationL();
        FLOG(_L("[CAiwPrintingProvider]>>> DoHandleCmdL "));
        }
    }
Exemplo n.º 5
0
// --------------------------------------------------------------------------
// CUPnPLocalPlayer::CopyCompleteL
// Returns from UPnP AV control point when a copy operation has been finished
// --------------------------------------------------------------------------
void CUPnPLocalPlayer::CopyCompleteL( TInt aError,
                                     const TDesC& /*aFilePath*/ )
    {
    __LOG1( "CopyCompleteL %d", aError );

    FinishNote();
    // If copying was successful, play the copied item
    if( KErrNone == aError )
        {
        // iFilePath Contains UTF8 content,we need change
        // to TDesC8 first ,Using Copy don't lost any data,because the 
        //low byte is NULL       
        TBuf8<KMaxFileName> filename;
        filename.Copy( *iFilePath );
        
        HBufC* temp = iFilePath;
        iFilePath = NULL;      
        
        // try transform UTF8 to UniCode
        HBufC* unicodename = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
            filename );       
        CleanupStack::PushL( unicodename );

        // Rename the file
        iFilePath = UPnPCommonUtils::RenameFileL( *unicodename ) ;
        if( iFilePath )
            {
            delete temp; temp = NULL;
            }
        else
            {
            iFilePath = temp;
            }    
        CleanupStack::PopAndDestroy( unicodename );
        unicodename = NULL;
        
        if( iFilePath )
            {
            
            // fix for TSW: ESLX-7L3DMX
            // OpenFileEmbeddedL( aSharableFile,aDataType, aParamList)
            // leaves with KErrInUse which results into immediate close
            // of image viewer.
            
            RFile sharableFile;
            TRAPD( err, iDocumentHandler->OpenTempFileL( 
                    *iFilePath, sharableFile ) );
                    
            if ( err == KErrNone )
                {
                CleanupClosePushL( sharableFile );

                // Create a param list to remove 
                // the "Use image as" sub menu item
                CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC();
                paramList->Reset();
                
//       Append a param into the list to restrict the viewer application from
//       showing the "use image as" sub menu item. Currently there is no
//       AiwGenericParam for this. A CR has been created for AIW to add this
//       constant to "AiwGenericParam.hrh".
//          Example: This is how the "Save" menu item is allowed.
//          paramList->AppendL( EGenericParamAllowSave );
                
                TDataType dataType = TDataType();
                
                __LOG( "Open document now... " );
                            
                TRAP( err, err = iDocumentHandler->OpenFileEmbeddedL(
                            sharableFile, dataType, *paramList ) );

                __LOG1( "err, err = iDocumentHandler->OpenFileEmbeddedL %d",
                        err );
                
                // Cleanup
                CleanupStack::PopAndDestroy( paramList );
                CleanupStack::PopAndDestroy( &sharableFile );
                }
                                                    
            if( KErrNone != err)
                {
                iFs.Delete( *iFilePath );
                iExitReason = err;
                }
            }
        else
            {
            iExitReason = KErrNoMemory;
            }
        }
    else
        {
        iExitReason = aError;
        }

  
    iCommonUI.HandleCommonErrorL( iExitReason, 0 );

    __LOG( "CUPnPLocalPlayer::CopyCompleteL end" );
    }