1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/imagingandcamerafws/camerafw/source/EcamPluginSupport.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,132 @@
1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <ecam/ecamplugin.h>
1.20 +#include <ecam/ecaminfoplugin.h>
1.21 +
1.22 +#include <ecom/ecom.h>
1.23 +#include <mm/mmpluginutils.h>
1.24 +
1.25 +#include <ecamuids.hrh>
1.26 +
1.27 +//
1.28 +// CCameraPlugin
1.29 +//
1.30 +
1.31 +EXPORT_C TInt CCameraPlugin::CamerasAvailable()
1.32 + {
1.33 + CCameraInfoPlugin* info = NULL;
1.34 + TRAPD(error, info = CCameraInfoPlugin::NewL());
1.35 + if (error!=KErrNone)
1.36 + {
1.37 + // error during open, default to 0
1.38 + // TODO - can we return an error here?
1.39 + return 0;
1.40 + }
1.41 + TInt result = info->CamerasAvailable();
1.42 + delete info;
1.43 + REComSession::FinalClose(); // don't have to do this here, but might as well tidy up
1.44 + return result;
1.45 + }
1.46 +
1.47 +CCameraPlugin* CCameraPlugin::NewL(TInt aCameraVersion)
1.48 + {
1.49 + TUid interfaceUid = {KUidOnboardCameraPlugin};
1.50 + TUid dtor;
1.51 +
1.52 +#ifdef _DEBUG
1.53 + CCameraPlugin* self =
1.54 + static_cast<CCameraPlugin*>
1.55 + (MmPluginUtils::CreateImplementationL(interfaceUid, dtor, KECamPluginMatchString));
1.56 +#else
1.57 + CCameraPlugin* self =
1.58 + static_cast<CCameraPlugin*>
1.59 + (MmPluginUtils::CreateImplementationL(interfaceUid, dtor, KECamPluginMatchString, KRomOnlyResolverUid));
1.60 +#endif
1.61 +
1.62 + //create CCameraStructure here
1.63 + self->iCameraStructure = new CCameraStructure();
1.64 + if (!self->iCameraStructure)
1.65 + {
1.66 + delete self;
1.67 + REComSession::DestroyedImplementation(dtor);
1.68 + User::Leave(KErrNoMemory);
1.69 + }
1.70 + else
1.71 + {
1.72 + self->iCameraStructure->iCameraVersion = aCameraVersion;
1.73 + self->iCameraStructure->iDestructorKey = dtor;
1.74 + }
1.75 + return self;
1.76 + }
1.77 +
1.78 +CCameraPlugin* CCameraPlugin::NewLC(TInt aCameraVersion)
1.79 + {
1.80 + CCameraPlugin* self = NewL(aCameraVersion);
1.81 + CleanupStack::PushL(self);
1.82 + return self;
1.83 + }
1.84 +
1.85 +EXPORT_C CCameraPlugin* CCameraPlugin::NewL(MCameraObserver2& aObserver,TInt aCameraIndex,TInt aPriority,TInt aCameraVersion)
1.86 + {
1.87 + CCameraPlugin* self = NewLC(aCameraVersion);
1.88 + self->Construct2L(aObserver, aCameraIndex, aPriority);
1.89 + CleanupStack::Pop(self);
1.90 + return self;
1.91 + }
1.92 +
1.93 +EXPORT_C CCameraPlugin* CCameraPlugin::NewDuplicateL(MCameraObserver2& aObserver,TInt aCameraHandle,TInt aCameraVersion)
1.94 + {
1.95 + CCameraPlugin* self = NewLC(aCameraVersion);
1.96 + self->Construct2DupL(aObserver, aCameraHandle);
1.97 + CleanupStack::Pop(self);
1.98 + return self;
1.99 + }
1.100 +
1.101 +
1.102 +EXPORT_C CCameraPlugin* CCameraPlugin::NewL(MCameraObserver& aObserver,TInt aCameraIndex,TInt aCameraVersion)
1.103 + {
1.104 + CCameraPlugin* self = NewLC(aCameraVersion);
1.105 + self->Construct2L(aObserver, aCameraIndex);
1.106 + CleanupStack::Pop(self);
1.107 + return self;
1.108 + }
1.109 +
1.110 +EXPORT_C CCameraPlugin* CCameraPlugin::NewDuplicateL(MCameraObserver& aObserver,TInt aCameraHandle,TInt aCameraVersion)
1.111 + {
1.112 + CCameraPlugin* self = NewLC(aCameraVersion);
1.113 + self->Construct2DupL(aObserver, aCameraHandle);
1.114 + CleanupStack::Pop(self);
1.115 + return self;
1.116 + }
1.117 +
1.118 +EXPORT_C CCameraPlugin::~CCameraPlugin()
1.119 + {
1.120 + if (iCameraStructure)
1.121 + {
1.122 + REComSession::DestroyedImplementation(iCameraStructure->iDestructorKey);
1.123 + }
1.124 + delete iCameraStructure;
1.125 + }
1.126 +
1.127 +EXPORT_C CCameraPlugin::CCameraPlugin()
1.128 + {
1.129 + }
1.130 +
1.131 +EXPORT_C TInt CCameraPlugin::CameraVersion()
1.132 + {
1.133 + return iCameraStructure->iCameraVersion;
1.134 + }
1.135 +