imagingandcamerafws/camerafw/source/EcamPluginSupport.cpp
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <ecam/ecamplugin.h>
       
    17 #include <ecam/ecaminfoplugin.h>
       
    18 
       
    19 #include <ecom/ecom.h>
       
    20 #include <mm/mmpluginutils.h>
       
    21 
       
    22 #include <ecamuids.hrh>
       
    23 
       
    24 //
       
    25 // CCameraPlugin
       
    26 //
       
    27 
       
    28 EXPORT_C TInt CCameraPlugin::CamerasAvailable()
       
    29 	{
       
    30 	CCameraInfoPlugin* info = NULL;
       
    31 	TRAPD(error, info = CCameraInfoPlugin::NewL());
       
    32 	if (error!=KErrNone)
       
    33 		{
       
    34 		// error during open, default to 0
       
    35 		// TODO - can we return an error here?
       
    36 		return 0;
       
    37 		}
       
    38 	TInt result = info->CamerasAvailable();
       
    39 	delete info;
       
    40 	REComSession::FinalClose(); // don't have to do this here, but might as well tidy up
       
    41 	return result;
       
    42 	}
       
    43 	
       
    44 CCameraPlugin* CCameraPlugin::NewL(TInt aCameraVersion)
       
    45 	{
       
    46 	TUid interfaceUid = {KUidOnboardCameraPlugin};
       
    47 	TUid dtor;
       
    48 
       
    49 #ifdef _DEBUG
       
    50 	CCameraPlugin* self = 
       
    51 		static_cast<CCameraPlugin*>
       
    52 			(MmPluginUtils::CreateImplementationL(interfaceUid, dtor, KECamPluginMatchString));
       
    53 #else
       
    54 	CCameraPlugin* self = 
       
    55 		static_cast<CCameraPlugin*>
       
    56 			(MmPluginUtils::CreateImplementationL(interfaceUid, dtor, KECamPluginMatchString, KRomOnlyResolverUid));
       
    57 #endif
       
    58 
       
    59 	//create CCameraStructure here
       
    60 	self->iCameraStructure = new CCameraStructure();
       
    61 	if (!self->iCameraStructure)
       
    62 		{
       
    63 		delete self;
       
    64 		REComSession::DestroyedImplementation(dtor);
       
    65 		User::Leave(KErrNoMemory);
       
    66 		}
       
    67 	else
       
    68 		{
       
    69 		self->iCameraStructure->iCameraVersion = aCameraVersion;
       
    70 	 	self->iCameraStructure->iDestructorKey = dtor;	
       
    71 		}
       
    72 	return self;
       
    73 	}
       
    74 
       
    75 CCameraPlugin* CCameraPlugin::NewLC(TInt aCameraVersion)
       
    76 	{
       
    77 	CCameraPlugin* self = NewL(aCameraVersion);
       
    78 	CleanupStack::PushL(self);
       
    79 	return self;	
       
    80 	}
       
    81 
       
    82 EXPORT_C CCameraPlugin* CCameraPlugin::NewL(MCameraObserver2& aObserver,TInt aCameraIndex,TInt aPriority,TInt aCameraVersion)
       
    83 	{
       
    84 	CCameraPlugin* self = NewLC(aCameraVersion);
       
    85 	self->Construct2L(aObserver, aCameraIndex, aPriority);
       
    86 	CleanupStack::Pop(self);
       
    87 	return self;
       
    88 	}
       
    89 
       
    90 EXPORT_C CCameraPlugin* CCameraPlugin::NewDuplicateL(MCameraObserver2& aObserver,TInt aCameraHandle,TInt aCameraVersion)
       
    91 	{
       
    92 	CCameraPlugin* self = NewLC(aCameraVersion);
       
    93 	self->Construct2DupL(aObserver, aCameraHandle);
       
    94 	CleanupStack::Pop(self);
       
    95 	return self;
       
    96 	}
       
    97 
       
    98 
       
    99 EXPORT_C CCameraPlugin* CCameraPlugin::NewL(MCameraObserver& aObserver,TInt aCameraIndex,TInt aCameraVersion)
       
   100 	{
       
   101 	CCameraPlugin* self = NewLC(aCameraVersion);
       
   102 	self->Construct2L(aObserver, aCameraIndex);
       
   103 	CleanupStack::Pop(self);
       
   104 	return self;
       
   105 	}
       
   106 
       
   107 EXPORT_C CCameraPlugin* CCameraPlugin::NewDuplicateL(MCameraObserver& aObserver,TInt aCameraHandle,TInt aCameraVersion)
       
   108 	{
       
   109 	CCameraPlugin* self = NewLC(aCameraVersion);
       
   110 	self->Construct2DupL(aObserver, aCameraHandle);
       
   111 	CleanupStack::Pop(self);
       
   112 	return self;
       
   113 	}
       
   114 
       
   115 EXPORT_C CCameraPlugin::~CCameraPlugin()
       
   116 	{
       
   117 	if (iCameraStructure)
       
   118 		{
       
   119 		REComSession::DestroyedImplementation(iCameraStructure->iDestructorKey);
       
   120 		}
       
   121 	delete iCameraStructure;
       
   122 	}
       
   123 	
       
   124 EXPORT_C CCameraPlugin::CCameraPlugin()
       
   125 	{
       
   126 	}
       
   127 	
       
   128 EXPORT_C TInt CCameraPlugin::CameraVersion()
       
   129 	{
       
   130 	return iCameraStructure->iCameraVersion;
       
   131 	}
       
   132