|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Haptics packetizer plugin factory class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <ecom/ecom.h> |
|
19 #include <centralrepository.h> |
|
20 #include <hwrmhapticspacketizer.h> |
|
21 |
|
22 #include "hwrmhapticsinternalcrkeys.h" |
|
23 |
|
24 // --------------------------------------------------------------------------- |
|
25 // Factory method for creating a packetizer plugin. |
|
26 // --------------------------------------------------------------------------- |
|
27 // |
|
28 EXPORT_C CHWRMHapticsPacketizer* CHWRMHapticsPacketizer::NewL( |
|
29 THWRMLogicalActuators aLogicalActuator ) |
|
30 { |
|
31 // map actuator type to cenrep id |
|
32 TInt cenrepId( 0 ); |
|
33 switch( aLogicalActuator ) |
|
34 { |
|
35 case EHWRMLogicalActuatorAny: |
|
36 { |
|
37 cenrepId = KHWRMHapticsPluginAnyPacketizer; |
|
38 break; |
|
39 } |
|
40 case EHWRMLogicalActuatorDevice: |
|
41 { |
|
42 cenrepId = KHWRMHapticsPluginDevicePacketizer; |
|
43 break; |
|
44 } |
|
45 case EHWRMLogicalActuatorPrimaryDisplay: |
|
46 { |
|
47 cenrepId = KHWRMHapticsPluginPrimaryDisplayPacketizer; |
|
48 break; |
|
49 } |
|
50 case EHWRMLogicalActuatorSecondaryDisplay: |
|
51 { |
|
52 cenrepId = KHWRMHapticsPluginSecondaryDisplayPacketizer; |
|
53 break; |
|
54 } |
|
55 case EHWRMLogicalActuatorGame: |
|
56 { |
|
57 cenrepId = KHWRMHapticsPluginGamePacketizer; |
|
58 break; |
|
59 } |
|
60 case EHWRMLogicalActuatorGameLeft: |
|
61 { |
|
62 cenrepId = KHWRMHapticsPluginGameLeftPacketizer; |
|
63 break; |
|
64 } |
|
65 case EHWRMLogicalActuatorGameRight: |
|
66 { |
|
67 cenrepId = KHWRMHapticsPluginGameRightPacketizer; |
|
68 break; |
|
69 } |
|
70 case EHWRMLogicalActuatorExternalVibra: |
|
71 { |
|
72 cenrepId = KHWRMHapticsPluginExternalVibraPacketizer; |
|
73 break; |
|
74 } |
|
75 default: |
|
76 cenrepId = KHWRMHapticsPluginAnyPacketizer; |
|
77 break; |
|
78 } |
|
79 |
|
80 // create cenrep instance |
|
81 CRepository* repository = CRepository::NewLC( KCRUidHWRMHapticsPlugins ); |
|
82 |
|
83 // get the packetizer plugin UID |
|
84 TInt pluginUid( 0 ); |
|
85 User::LeaveIfError( repository->Get( cenrepId, pluginUid ) ); |
|
86 |
|
87 // delete cenrep instance |
|
88 CleanupStack::PopAndDestroy( repository ); |
|
89 |
|
90 TInt err = KErrNone; |
|
91 |
|
92 // create plugin, if found uid |
|
93 TAny* interface = NULL; |
|
94 if ( pluginUid != 0 ) |
|
95 { |
|
96 TRAP( err, interface = REComSession::CreateImplementationL( |
|
97 TUid::Uid( pluginUid ), |
|
98 _FOFF( CHWRMHapticsPacketizer, iDtor_ID_Key ) ) ); |
|
99 |
|
100 if ( err != KErrNone || !interface ) |
|
101 { |
|
102 err = KErrNotSupported; |
|
103 } |
|
104 } |
|
105 else |
|
106 { |
|
107 err = KErrNotSupported; |
|
108 } |
|
109 |
|
110 User::LeaveIfError( err ); |
|
111 |
|
112 return static_cast<CHWRMHapticsPacketizer*>( interface ); |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // Destructor. |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 EXPORT_C CHWRMHapticsPacketizer::~CHWRMHapticsPacketizer() |
|
120 { |
|
121 REComSession::DestroyedImplementation( iDtor_ID_Key ); |
|
122 } |
|
123 |
|
124 // End of file |
|
125 |