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