www.pudn.com > MyP990Camera.zip > MyP990CameraAppUi.cpp


/*****************************************************************************  
COPYRIGHT All rights reserved Sony Ericsson Mobile Communications AB 2006.  
The software is the copyrighted work of Sony Ericsson Mobile Communications AB.  
The use of the software is subject to the terms of use or of the end-user license  
agreement which accompanies or is included with the software. The software is  
provided "as is" and Sony Ericsson specifically disclaim any warranty or  
condition whatsoever regarding merchantability or fitness for a specific  
purpose, title or non-infringement. No warranty of any kind is made in  
relation to the condition, suitability, availability, accuracy, reliability,  
merchantability and/or non-infringement of the software provided herein.  
*****************************************************************************/ 
 
// MyP990CameraAppUi.cpp 
 
#include "MyP990CameraAppUi.h" 
#include "MyP990CameraBaseView.h" 
#include "MyFileHandler.h" 
#include "MyCameraHandler.h" 
#include "MyP990Camera.hrh" 
 
#include      // CQikCommand 
#include         // TApaTaskList 
 
_LIT(KCaptureScreen, "Capture"); 
 
_LIT(KCaptured1, "Screen captured"); 
_LIT(KCaptured2, "Saved to file"); 
_LIT(KNotifBut1, "Ok"); 
 
 
void CMyP990CameraAppUi::ConstructL() 
  { 
  CQikAppUi::ConstructL(); 
 
  iFileHandler = CMyFileHandler::NewLC(); 
  CleanupStack::Pop(iFileHandler); 
 
  iCameraHandler = CMyCameraHandler::NewLC(); 
  CleanupStack::Pop(iCameraHandler); 
 
  iBaseView = CMyP990CameraBaseView::NewLC(*this, 
                                           *iFileHandler, 
                                           *iCameraHandler); 
  AddViewL(*iBaseView); 
  CleanupStack::Pop(iBaseView); 
 
  // remove button bar 
  SetViewMode(EFalse); 
 
  // enable observing memory stick 
  iDiskNotifier = CQikMediaFolderChangeNotifier::NewL(*this, *iEikonEnv,  EDriveD, KNullDesC, ENotifyDisk);  
  iDiskNotifier->Start();  
  } 
 
CMyP990CameraAppUi::~CMyP990CameraAppUi() 
  { 
  if(iFileHandler) 
    { 
    delete iFileHandler; 
    iFileHandler = NULL; 
    } 
  if(iCameraHandler ) 
    { 
    delete iCameraHandler ; 
    iCameraHandler = NULL; 
    } 
  if(iDiskNotifier) 
    { 
    delete iDiskNotifier; 
    iDiskNotifier = NULL; 
    } 
  } 
 
void CMyP990CameraAppUi::HandleCommandL(CQikCommand &aCommand) 
  { 
  switch(aCommand.Id()) 
    { 
    case EMyCmdSaveDriveUseC : 
      iFileHandler->SetSaveDriveL(ETrue); 
      break; 
 
    case EMyCmdSaveDriveUseD : 
      { 
      TBool res = iFileHandler->SetSaveDriveL(EFalse); 
      if(res) // no D drive, use C - set command back to 'C' 
        { 
        CQikCommandManager::Static().SetChecked(*iBaseView, EMyCmdSaveDriveUseC, ETrue); 
        User::InfoPrint(_L("Drive D not ready")); 
        } 
      } 
      break; 
 
    case EMyCmdViewfinderOn : 
      { 
      SetViewMode(ETrue); 
      iCameraHandler->StartCamera(iBaseView->DrawableWindow()); 
      } 
      break; 
 
    case EMyCmdViewfinderOff : 
      SetViewMode(EFalse); 
      iCameraHandler->StopCamera(); 
      break; 
 
    case EMyCmdListCameraFormats : 
      iCameraHandler->ListSupportedFormats(); 
      break; 
 
    default :  
      CQikAppUi::HandleCommandL(aCommand); 
      break; 
    } 
  } 
 
void CMyP990CameraAppUi::SetViewMode(TBool aFullScreen) 
  { 
  TQikViewMode viewMode; 
  if(aFullScreen) 
    viewMode.SetFullscreen(); 
  else 
    { 
    viewMode.SetNormal(); 
    } 
  iBaseView->MySetViewMode(viewMode); 
  } 
 
TBool CMyP990CameraAppUi::NewDiskStateL(const TDriveNumber& aDrive) 
  { 
  if(aDrive == EDriveD) 
    { 
    User::InfoPrint(_L("MemStick insert/remove")); 
    iFileHandler->SetSaveDriveL(ETrue); 
    CQikCommandManager::Static().SetChecked(*iBaseView, EMyCmdSaveDriveUseC, ETrue); 
    } 
  return ETrue; 
  } 
 
TBool CMyP990CameraAppUi::StructureChangedL(const TDriveNumber& /*aDrive*/, TDesC& /*aMimeType*/) 
  { 
  return ETrue; 
  }