camerauis/cameraapp/generic/src/CamNewFileService.cpp
changeset 0 1ddebce53859
child 27 53c8aa5d97a3
equal deleted inserted replaced
-1:000000000000 0:1ddebce53859
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Class for file server service.
       
    15 *
       
    16 *  Copyright © 2007 Nokia.  All rights reserved.
       
    17 *  This material, including documentation and any related computer
       
    18 *  programs, is protected by copyright controlled by Nokia.  All
       
    19 *  rights are reserved.  Copying, including reproducing, storing,
       
    20 *  adapting or translating, any or all of this material requires the
       
    21 *  prior written consent of Nokia.  This material also contains
       
    22 *  confidential information which may not be disclosed to others
       
    23 *  without the prior written consent of Nokia.
       
    24 
       
    25 *
       
    26 *
       
    27 *
       
    28 */
       
    29 
       
    30 
       
    31 // INCLUDE FILES
       
    32 #include "CamNewFileService.h"
       
    33 #include "CNewFileServiceBase.h"
       
    34 
       
    35 #include "CamSettingsModel.h"
       
    36 #include <f32file.h>
       
    37 #include <eikenv.h>
       
    38 #include <eikappui.h>
       
    39 #include <eikapp.h>
       
    40 #include <AiwGenericParam.h>
       
    41 
       
    42 #include "CamAppUi.h"
       
    43 
       
    44 #include "CamUtility.h"
       
    45 #include "CamAppController.h"
       
    46 
       
    47 // FORWARD DECLARATIONS
       
    48 
       
    49 // ========================= MEMBER FUNCTIONS ================================
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CCamNewFileService::NewL
       
    53 // Constructor
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CCamNewFileService* CCamNewFileService::NewL()
       
    57     {
       
    58 	return new( ELeave ) CCamNewFileService;
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // CCamNewFileService::~CCamNewFileService
       
    63 // Destructor
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CCamNewFileService::~CCamNewFileService()
       
    67   {
       
    68   PRINT( _L("Camera => ~CCamNewFileService") );
       
    69   if ( !iCompleted && iObserver )
       
    70     {	    
       
    71     TRAP_IGNORE( iObserver->HandleCompletedNewServiceL( EFalse ) );
       
    72     }
       
    73   PRINT( _L("Camera <= ~CCamNewFileService") );
       
    74   }
       
    75     
       
    76 // ---------------------------------------------------------------------------
       
    77 // CCamNewFileService::HandleNewFileL
       
    78 // Receive message from service to record new files
       
    79 // ---------------------------------------------------------------------------
       
    80 //   
       
    81 void CCamNewFileService::HandleNewFileL( MNewFileServiceObserver* /*aObserver*/,
       
    82         							  RFile& /*aFile*/,
       
    83         							  TNewServiceFileType /*aType*/ )
       
    84     {    
       
    85   
       
    86    
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // CCamNewFileService::HandleNewFileL
       
    91 // Receive message from service to record new files
       
    92 // ---------------------------------------------------------------------------
       
    93 // 
       
    94 void CCamNewFileService::HandleNewFileL( MNewFileServiceObserver* aObserver,
       
    95         							  CDesCArray& aFilenameArray,
       
    96         							  TNewServiceFileType aType,
       
    97         							  TBool /*aMultipleFiles*/ )
       
    98   {
       
    99   PRINT( _L("Camera: CCamNewFileService::HandleNewFileL()") );
       
   100   
       
   101   iCompleted = EFalse;
       
   102   
       
   103   if( aType != ENewFileServiceImage && aType != ENewFileServiceVideo )
       
   104 		{
       
   105 		aObserver->HandleCompletedNewServiceL( EFalse );
       
   106 		return;
       
   107 		}
       
   108 		
       
   109 	iObserver = aObserver;
       
   110   
       
   111 
       
   112   TInt mode = KErrNone;
       
   113   
       
   114   switch ( aType )
       
   115     {
       
   116     case ENewFileServiceImage:
       
   117      	mode = ECamControllerImage;
       
   118       break;
       
   119     case ENewFileServiceVideo:
       
   120     	mode = ECamControllerVideo;               
       
   121       break;
       
   122     default:
       
   123       break;
       
   124     }   
       
   125         
       
   126   iCamFilenameArray = &aFilenameArray;
       
   127   
       
   128   CAiwGenericParamList* ParamList = GenericParams();
       
   129   TInt resolutionsAvailable = ParamList->Count(EGenericParamResolution);
       
   130   // set the default requested resolution as 0*0, which is later on
       
   131   // interpreted as the default embedded quality.
       
   132   TSize requestedResolution(0,0);
       
   133   if ( resolutionsAvailable > 0 ) 
       
   134   	{
       
   135   	TInt index = 0;
       
   136   	const TAiwGenericParam* firstReso = ParamList->FindFirst( index, EGenericParamResolution );
       
   137   	if ( KErrNotFound != index )
       
   138   		{
       
   139   		TPtrC8 resData = firstReso->Value().AsData();//&firstReso->Value().AsData();
       
   140   		TBuf8<sizeof(TSize)> bufRes;
       
   141   		if ( resData.Length() > sizeof(TSize) ) User::Leave( KErrArgument );
       
   142   		bufRes.Copy(resData);
       
   143   		TDes8& rText = bufRes;
       
   144   		TPckgBuf<TSize>* ptr = 
       
   145             static_cast<TPckgBuf<TSize>*>( &rText );
       
   146         if( !ptr ) User::Leave( KErrNotSupported );
       
   147         TSize& params( (*ptr)() );
       
   148         requestedResolution.SetSize( params.iWidth, params.iHeight );
       
   149         PRINT2( _L("Camera: CCamNewFileService::HandleNewFileL() - Requested resolution: %d * %d"), requestedResolution.iWidth, requestedResolution.iHeight );
       
   150   		}
       
   151   	}
       
   152 
       
   153   CCamAppUi * appUi =
       
   154       static_cast< CCamAppUi* >( CEikonEnv::Static()->EikAppUi() );
       
   155   appUi->SetRequestedNewFileResolution(requestedResolution);
       
   156   appUi->StartAsServerAppL( this, mode );          
       
   157   }
       
   158     	
       
   159 // ---------------------------------------------------------------------------
       
   160 // CCamNewFileService::ServiceCompleteL
       
   161 // Receive message from service that file service has completed
       
   162 // and can be closed
       
   163 // ---------------------------------------------------------------------------
       
   164 // 
       
   165 void CCamNewFileService::ServiceCompleteL()
       
   166 	{
       
   167 	PRINT( _L("Camcorder: CCamNewFileService::ServiceCompleteL()") );
       
   168 	iCompleted = ETrue;	
       
   169 
       
   170   	CEikonEnv::Static()->EikAppUi()->HandleCommandL( EEikCmdExit );
       
   171 	}
       
   172 	
       
   173 // ---------------------------------------------------------------------------
       
   174 // CCamNewFileService::FileCompleteL
       
   175 // Receive command from application that file named aName has been captured.
       
   176 // (image or video)
       
   177 // ---------------------------------------------------------------------------
       
   178 // 
       
   179 void
       
   180 CCamNewFileService::FileCompleteL( const TDesC& aName )
       
   181 	{
       
   182     PRINT( _L("Camcorder: CCamNewFileService::FileCompleteL()") );	
       
   183 	if( iCamFilenameArray != NULL )
       
   184 		{
       
   185 		iCamFilenameArray->AppendL( aName );
       
   186 		}
       
   187 
       
   188 	iCompleted = ETrue;
       
   189 	iObserver->HandleCompletedNewServiceL( ETrue );	
       
   190 	
       
   191 	
       
   192 	}
       
   193 // ---------------------------------------------------------------------------
       
   194 // CCamNewFileService::AbortL
       
   195 // Receive command from application that file service must be aborted
       
   196 // ---------------------------------------------------------------------------
       
   197 // 
       
   198 void CCamNewFileService::AbortL()
       
   199 	{
       
   200 	PRINT( _L("Camcorder => CCamNewFileService::AbortL()") );
       
   201 	if( !iCompleted )
       
   202 		{
       
   203 		iCompleted = ETrue;
       
   204 		iObserver->HandleCompletedNewServiceL( EFalse );
       
   205 		}
       
   206     PRINT( _L("Camcorder <= CCamNewFileService::AbortL()") );
       
   207 	}
       
   208 	
       
   209 // End of File