Esempio 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;
}
// ---------------------------------------------------------------------------
// 
// ---------------------------------------------------------------------------
//
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 "));
        }
    }