diff -r 000000000000 -r f63038272f30 bluetoothengine/bthid/manager/src/session.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bthid/manager/src/session.cpp Mon Jan 18 20:28:57 2010 +0200 @@ -0,0 +1,179 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This is the implementation of application class +* +*/ + + +#include + +#include "layoutmgr.h" +#include "server.h" +#include "session.h" +#include "decode.h" +#include "library.h" +#include "client.h" +#include "debug.h" + +// ---------------------------------------------------------------------- + +CLayoutSession::CLayoutSession() + { + // nothing else to do + } + +CLayoutSession* CLayoutSession::NewL() + { + CLayoutSession* self = CLayoutSession::NewLC(); + CleanupStack::Pop(self); + return self; + } + +CLayoutSession* CLayoutSession::NewLC() + { + CLayoutSession* self = new (ELeave) CLayoutSession; + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +void CLayoutSession::ConstructL() + { + iDecoder = CKeyboardDecoder::NewL(); + } + +CLayoutSession::~CLayoutSession() + { + Server()->SessionClosed(); + + delete iDecoder; + iLayoutLibrary = 0; // no ownership + } + +// ---------------------------------------------------------------------- + +void CLayoutSession::ServiceL(const RMESSAGE& aMessage) + { + TRAPD(err, DispatchMessageL(aMessage)); + aMessage.Complete(err); + } + +void CLayoutSession::DispatchMessageL(const RMESSAGE& aMessage) + { + TRACE_INFO( (_L("[HID]\tCLayoutSession::DispatchMessageL(%d)\r\n"), + aMessage.Function())); + + // Extract the service code from the message + TLayoutManagerService service = + static_cast(aMessage.Function()); + + switch (service) + { + case EKeyEvent: + { + TPckgBuf eventPkg; + aMessage.ReadL(0, eventPkg); + TRACE_INFO( ( + _L("[HID]\tKey event message: 0x%04x, 0x%02x, %d, %d"), + eventPkg().iHidKey, eventPkg().iModifiers.Value(), + eventPkg().iLockKeys.iCapsLock, + eventPkg().iLockKeys.iNumLock)); + + TPckgBuf keyPkg; + iDecoder->Event(eventPkg(), keyPkg()); + aMessage.WriteL(1, keyPkg); + } + break; + + case ESetInitialLayout: + { + TRACE_INFO( (_L("[HID]\tSet initial layout message\r\n"))); + Server()->SetInitialLayoutL(aMessage.Int0(), + aMessage.Int1(), aMessage.Int2()); + } + break; + + case ESetLayout: + { + TRACE_INFO( (_L("[HID]\tSet layout ALL message\r\n"))); + User::LeaveIfError(Server()->SetLayout(aMessage.Int0())); + } + break; + + case EGetInitialLayout: + { + TRACE_INFO( (_L("[HID]\tGet initial layout message\r\n"))); + TPckgBuf idPkg(Server()->InitialLayout()); + aMessage.WriteL(0, idPkg); + } + break; + + case EGetLayout: + { + TRACE_INFO( (_L("[HID]\tGet layout message\r\n"))); + TInt layout = Server()->Layout(); + TRACE_INFO( (_L(" Layout library ID is %d\r\n"), layout)); + TPckgBuf idPkg(layout); + aMessage.WriteL(0, idPkg); + } + break; + + case EResetDecoder: + { + TRACE_INFO( (_L("[HID]\tReset decoder message\r\n"))); + iDecoder->Reset(); + } + break; + + case EGetDeviceInfo: + { + TRACE_INFO( (_L("[HID]\tGet device info message\r\n"))); + TPckgBuf isNokiaSu8Pkg(Server()->IsNokiaSu8()); + aMessage.WriteL(0, isNokiaSu8Pkg); + TPckgBuf foundLayoutPkg(Server()->FoundLayout()); + aMessage.WriteL(1, foundLayoutPkg); + } + break; + + default: + { + TRACE_INFO( (_L("[HID]\tUnknown service request %d\r\n"), service)); + CLayoutServer::PanicClient(aMessage, EBadRequest); + break; + } + } + } + +// ---------------------------------------------------------------------- + +void CLayoutSession::SetLayout(CLayoutLibrary* aLayoutLibrary) + { + TRACE_INFO( (_L("[HID]\tCLayoutSession::SetLayout(0x%08x)\n"), + aLayoutLibrary)); + TRACE_INFO( (_L("[HID]\t Layout ID is %d (0x%x)\n"), + aLayoutLibrary->Id())); + + iLayoutLibrary = aLayoutLibrary; + iDecoder->SetLayout(iLayoutLibrary->Layout()); + } + +// ---------------------------------------------------------------------- + +CLayoutServer* CLayoutSession::Server() + { + return const_cast(static_cast + (CSession2::Server())); + } + +// ----------------------------------------------------------------------