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 test (adaptation) plugin idle responder |
|
15 * implementation. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "hwrmhapticsstubplugin.h" |
|
21 #include "hwrmhapticsstubpluginidleresponder.h" |
|
22 |
|
23 // --------------------------------------------------------------------------- |
|
24 // Static instantiation method. |
|
25 // --------------------------------------------------------------------------- |
|
26 // |
|
27 CHWRMHapticsStubPluginIdleResponder* |
|
28 CHWRMHapticsStubPluginIdleResponder::NewL( |
|
29 CHWRMHapticsStubPlugin* aPlugin, |
|
30 TUint8 aTransId, |
|
31 TUint8* aDataPacket) |
|
32 { |
|
33 CHWRMHapticsStubPluginIdleResponder* self = |
|
34 new ( ELeave ) CHWRMHapticsStubPluginIdleResponder( aPlugin, |
|
35 aTransId, |
|
36 aDataPacket ); |
|
37 |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // Destructor |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CHWRMHapticsStubPluginIdleResponder::~CHWRMHapticsStubPluginIdleResponder() |
|
50 { |
|
51 if ( iIdle ) |
|
52 { |
|
53 iIdle->Cancel(); |
|
54 delete iIdle; |
|
55 } |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // Method for starting response generation from CIdle callback |
|
60 // This is used as TCallBack object in CIdle AO. |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 TInt CHWRMHapticsStubPluginIdleResponder::GenerateResponse( TAny* aSelf ) |
|
64 { |
|
65 CHWRMHapticsStubPluginIdleResponder* self = |
|
66 reinterpret_cast<CHWRMHapticsStubPluginIdleResponder*>( aSelf ); |
|
67 if ( self ) |
|
68 { |
|
69 TRAP_IGNORE( self->GenerateResponseL() ); |
|
70 } |
|
71 return KErrNone; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // Method that does the actual response generation towards the issuer of |
|
76 // command i.e., the HapticsPluginManager |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 void CHWRMHapticsStubPluginIdleResponder::GenerateResponseL() |
|
80 { |
|
81 if ( iPlugin ) |
|
82 { |
|
83 iPlugin->GenerateResponseL( iTransId, iDataPacket ); |
|
84 } |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // Getter for iTransId |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 TUint8 CHWRMHapticsStubPluginIdleResponder::TransId() const |
|
92 { |
|
93 return iTransId; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // Method for enquiring whether the contained CIdle AO is active or not |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 TBool CHWRMHapticsStubPluginIdleResponder::Active() const |
|
101 { |
|
102 return ( iIdle && iIdle->IsActive() ); |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // Constructor |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 CHWRMHapticsStubPluginIdleResponder::CHWRMHapticsStubPluginIdleResponder( |
|
110 CHWRMHapticsStubPlugin* aPlugin, |
|
111 TUint8 aTransId, |
|
112 TUint8* aDataPacket ) |
|
113 : iPlugin( aPlugin ), |
|
114 iTransId ( aTransId ), |
|
115 iDataPacket ( aDataPacket ) |
|
116 { |
|
117 // empty |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // Two-phase construction ConstructL |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 void CHWRMHapticsStubPluginIdleResponder::ConstructL() |
|
125 { |
|
126 // Create and start the CIdle AO |
|
127 iIdle = CIdle::NewL( CActive::EPriorityLow ); |
|
128 iIdle->Start( TCallBack( GenerateResponse, this ) ); |
|
129 } |
|
130 |
|
131 // end of file |
|
132 |
|