os/mm/mmplugins/cameraplugins/source/mmcameraclientplugin/mmcameraserver/src/mmcameraserver.cpp
Update contrib.
1 // Copyright (c) 2008-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #include "mmcameraserver.h"
22 #include "mmcameraserversession.h"
23 #include "mmcameraservercontroller.h"
24 #include "mmcameraservershutdown.h"
27 CMMCameraServer* CMMCameraServer::NewLC()
29 CMMCameraServer* self = new(ELeave) CMMCameraServer();
30 CleanupStack::PushL(self);
35 CMMCameraServer::CMMCameraServer()
36 : CServer2 (CActive::EPriorityStandard),
38 iCamControllerQ(_FOFF(CMMCameraServerController,iCamCntrlLink))
42 CMMCameraServer::~CMMCameraServer()
49 while (!iCamControllerQ.IsEmpty()) // free the memory on the heap used for controller queues
51 CMMCameraServerController *pCntrl = iCamControllerQ.First();
55 delete iPolicyManager;
59 void CMMCameraServer::ConstructL()
61 iPolicyManager = CMMCameraServerPolicyManager::NewL();
62 StartL(KMMCameraServerName);
64 iShutdown = CMMCameraServerShutdown::NewL();
68 void CMMCameraServer::AddSession()
71 if(iCamSessionCount == 1)
77 void CMMCameraServer::DropSession()
80 if(iCamSessionCount == 0)
82 if (!iShutdown->IsActive())
90 * Provides a Camera controller object for the specified camera index.
92 void CMMCameraServer::GetCameraControllerL(TInt aCameraIndex, CMMCameraServerController*& aCameraController)
94 TDblQueIter<CMMCameraServerController> controllerIterator(iCamControllerQ);
95 controllerIterator.SetToFirst();
96 CMMCameraServerController* pCntrl = controllerIterator;
98 // loop through iterator to find desired camera controller
101 if(aCameraIndex == pCntrl->CameraIndex())
103 // found required controller
104 aCameraController = controllerIterator;
107 controllerIterator++;
108 pCntrl = controllerIterator;
111 // No controllers exist for specified camera index so create new one and append to queue
114 aCameraController = CMMCameraServerController::NewL(aCameraIndex);
115 iCamControllerQ.AddLast(*aCameraController);
119 void CMMCameraServer::GetCameraControllerQueryL(CMMCameraServerControllerQuery*& aCameraControllerQuery)
121 aCameraControllerQuery = CMMCameraServerControllerQuery::NewL();
124 CSession2* CMMCameraServer::NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const
126 // Check that the version is OK
127 TVersion version(KECamServMajorVerNumber, KECamServMinorVerNumber, KECamServBuildVerNumber);
128 if (!User::QueryVersionSupported(version, aVersion))
130 User::Leave(KErrNotSupported);
133 iPolicyManager->OnConnectL(aMessage);
135 return new(ELeave) CMMCameraServerSession();
138 TInt CMMCameraServer::RunError(TInt aError)
140 Message().Complete(aError); //send error back to client
141 // should have :- if(!IsActive())
147 void CMMCameraServer::PanicClient(const RMessage2& aMessage, TServerPanic aPanic)
149 _LIT(KPanic, "MMCameraServer");
150 aMessage.Panic(KPanic, aPanic);