30 |
30 |
31 // ============================ MEMBER FUNCTIONS ============================= |
31 // ============================ MEMBER FUNCTIONS ============================= |
32 |
32 |
33 |
33 |
34 // --------------------------------------------------------------------------- |
34 // --------------------------------------------------------------------------- |
35 // Safe constructor. Initializes refrerece to the Meta Data Model in which |
35 // Safe constructor. Initializes refrerece to the Meta Data Model in which |
36 // the event-to-action mappings are stored. |
36 // the event-to-action mappings are stored. |
37 // --------------------------------------------------------------------------- |
37 // --------------------------------------------------------------------------- |
38 // |
38 // |
39 CHnEventHandler::CHnEventHandler( MHnMdModelEventObserver& aModelObserver, |
39 CHnEventHandler::CHnEventHandler( MHnMdModelEventObserver& aModelObserver, |
40 MHnControllerInterface& aController ): |
40 MHnControllerInterface& aController ): |
41 iEventObserver( aModelObserver), iControllerInterface( aController ) |
41 iEventObserver( aModelObserver), iControllerInterface( aController ) |
42 { |
42 { |
43 } |
43 } |
44 |
44 |
45 // --------------------------------------------------------------------------- |
45 // --------------------------------------------------------------------------- |
46 // |
46 // |
47 // --------------------------------------------------------------------------- |
47 // --------------------------------------------------------------------------- |
48 // |
48 // |
49 CHnEventHandler::~CHnEventHandler() |
49 CHnEventHandler::~CHnEventHandler() |
50 { |
50 { |
51 delete iServiceHandler; |
51 delete iServiceHandler; |
52 } |
52 } |
53 |
53 |
54 // --------------------------------------------------------------------------- |
54 // --------------------------------------------------------------------------- |
55 // |
55 // |
56 // --------------------------------------------------------------------------- |
56 // --------------------------------------------------------------------------- |
57 // |
57 // |
58 CHnEventHandler* CHnEventHandler::NewLC( |
58 CHnEventHandler* CHnEventHandler::NewLC( |
59 MHnMdModelEventObserver& aModelObserver, |
59 MHnMdModelEventObserver& aModelObserver, |
60 MHnControllerInterface& aController ) |
60 MHnControllerInterface& aController ) |
61 { |
61 { |
62 CHnEventHandler* self = |
62 CHnEventHandler* self = |
63 new (ELeave)CHnEventHandler( aModelObserver, aController ); |
63 new (ELeave)CHnEventHandler( aModelObserver, aController ); |
65 self->ConstructL(); |
65 self->ConstructL(); |
66 return self; |
66 return self; |
67 } |
67 } |
68 |
68 |
69 // --------------------------------------------------------------------------- |
69 // --------------------------------------------------------------------------- |
70 // |
70 // |
71 // --------------------------------------------------------------------------- |
71 // --------------------------------------------------------------------------- |
72 // |
72 // |
73 CHnEventHandler* CHnEventHandler::NewL( |
73 CHnEventHandler* CHnEventHandler::NewL( |
74 MHnMdModelEventObserver& aModelObserver, |
74 MHnMdModelEventObserver& aModelObserver, |
75 MHnControllerInterface& aController ) |
75 MHnControllerInterface& aController ) |
76 { |
76 { |
77 CHnEventHandler* self=CHnEventHandler::NewLC( aModelObserver, |
77 CHnEventHandler* self=CHnEventHandler::NewLC( aModelObserver, |
78 aController ); |
78 aController ); |
79 CleanupStack::Pop(self); |
79 CleanupStack::Pop(self); |
80 return self; |
80 return self; |
81 } |
81 } |
82 |
82 |
83 // --------------------------------------------------------------------------- |
83 // --------------------------------------------------------------------------- |
84 // |
84 // |
85 // --------------------------------------------------------------------------- |
85 // --------------------------------------------------------------------------- |
86 // |
86 // |
87 void CHnEventHandler::ConstructL() |
87 void CHnEventHandler::ConstructL() |
88 { |
88 { |
89 } |
89 } |
90 |
90 |
91 // --------------------------------------------------------------------------- |
91 // --------------------------------------------------------------------------- |
92 // |
92 // |
93 // --------------------------------------------------------------------------- |
93 // --------------------------------------------------------------------------- |
94 // |
94 // |
95 |
|
96 TInt CHnEventHandler::ExecuteStandardActionL( CHnActionModel* aActionModel ) |
95 TInt CHnEventHandler::ExecuteStandardActionL( CHnActionModel* aActionModel ) |
97 { |
96 { |
98 delete iServiceHandler; |
97 const TDesC8& service = aActionModel->Service(); |
99 iServiceHandler = NULL; |
98 const TDesC8& interface = aActionModel->Interface(); |
100 iServiceHandler = CHnServiceHandler::NewL( |
99 const TDesC8& commandName = aActionModel->CommandName(); |
101 aActionModel->Service(), |
100 const TServiceMode mode = aActionModel->ServiceMode(); |
102 aActionModel->Interface(), |
101 CLiwGenericParamList* constructor = aActionModel->ConstructorLC(); |
103 aActionModel->CommandName(), |
102 CLiwGenericParamList* serviceCommand = aActionModel->CommandLC(); |
104 aActionModel->ServiceMode(), |
103 |
105 aActionModel->ConstructorLC(), |
104 if ( iServiceHandler && ( iIsExecutingStandardAsyncAction |
106 aActionModel->CommandLC() ); |
105 || !iServiceHandler->ServiceHandlerMatchesModel( |
107 |
106 service, interface, constructor ) ) ) |
108 CleanupStack::Pop( 2 ); |
107 { |
109 TInt res = iServiceHandler->ExecuteL( this, 0 ); |
108 delete iServiceHandler; // this will cancel async. action execution |
|
109 iServiceHandler = NULL; |
|
110 iIsExecutingStandardAsyncAction = EFalse; |
|
111 } |
|
112 |
|
113 if ( !iServiceHandler ) |
|
114 { |
|
115 iServiceHandler = CHnServiceHandler::NewL( service, interface, |
|
116 commandName, mode, constructor, serviceCommand ); |
|
117 CleanupStack::Pop( serviceCommand ); |
|
118 CleanupStack::Pop( constructor ); |
|
119 } |
|
120 else |
|
121 { |
|
122 iServiceHandler->PrepareForNextExecutionL( |
|
123 commandName, mode, serviceCommand ); |
|
124 CleanupStack::Pop( serviceCommand ); |
|
125 CleanupStack::PopAndDestroy( constructor ); |
|
126 constructor = NULL; |
|
127 } |
|
128 |
|
129 __ASSERT_DEBUG( !iIsExecutingStandardAsyncAction, User::Invariant() ); |
|
130 if ( mode == EServiceModeAsynchronous ) |
|
131 { |
|
132 iIsExecutingStandardAsyncAction = ETrue; |
|
133 } |
|
134 TInt res = iServiceHandler->ExecuteL( this, 0 ); |
110 return res; |
135 return res; |
111 } |
136 } |
112 |
137 |
113 // --------------------------------------------------------------------------- |
138 // --------------------------------------------------------------------------- |
114 // |
139 // |
115 // --------------------------------------------------------------------------- |
140 // --------------------------------------------------------------------------- |
116 // |
141 // |
117 TInt CHnEventHandler::ExtractUidFromActionL( const TDesC8& aInterface, |
142 TInt CHnEventHandler::ExtractUidFromActionL( const TDesC8& aInterface, |
118 TUid& aUid ) |
143 TUid& aUid ) |
119 { |
144 { |
120 DEBUG16(("_MM_: CHnEventHandler::ExtractUidFromActionL UIext - uid %S", |
145 DEBUG16(("_MM_: CHnEventHandler::ExtractUidFromActionL UIext - uid %S", |
121 &aInterface )); |
146 &aInterface )); |
122 |
147 |
123 TLex8 lex( aInterface ); |
148 TLex8 lex( aInterface ); |
124 lex.Inc( 2 ); |
149 lex.Inc( 2 ); |
125 return lex.Val( (TUint32 &) aUid.iUid, EHex ); |
150 return lex.Val( (TUint32 &) aUid.iUid, EHex ); |
126 } |
151 } |
127 |
152 |
128 |
153 |
129 // --------------------------------------------------------------------------- |
154 // --------------------------------------------------------------------------- |
130 // |
155 // |
131 // --------------------------------------------------------------------------- |
156 // --------------------------------------------------------------------------- |
132 // |
157 // |
133 TInt CHnEventHandler::ExecuteInternalActionL( CHnActionModel* aActionModel ) |
158 TInt CHnEventHandler::ExecuteInternalActionL( CHnActionModel* aActionModel ) |
134 { |
159 { |
135 TInt ret(KErrNotFound); |
160 TInt ret(KErrNotFound); |
136 CLiwGenericParamList* params = aActionModel->CommandLC(); |
161 CLiwGenericParamList* params = aActionModel->CommandLC(); |
137 if ( aActionModel->CommandName() == KServiceOpenSuite ) |
162 if ( aActionModel->CommandName() == KServiceOpenSuite ) |
138 { |
163 { |
139 ret = iEventObserver.HandleModelEventL( KNewSuiteLoadedMdEvent(), |
164 ret = iEventObserver.HandleModelEventL( KNewSuiteLoadedMdEvent(), |
140 *params ); |
165 *params ); |
141 } |
166 } |
142 else if ( aActionModel->CommandName() == KServiceSwitchWidget ) |
167 else if ( aActionModel->CommandName() == KServiceSwitchWidget ) |
143 { |
168 { |
144 ret = iEventObserver.HandleModelEventL( KSwitchWidgetMdEvent(), |
169 ret = iEventObserver.HandleModelEventL( KSwitchWidgetMdEvent(), |
145 *params ); |
170 *params ); |
146 } |
171 } |
147 else if ( aActionModel->CommandName() == KServiceStartEditMode ) |
172 else if ( aActionModel->CommandName() == KServiceStartEditMode ) |
148 { |
173 { |
149 ret = iEventObserver.HandleModelEventL( KStartEditModeMdEvent(), |
174 ret = iEventObserver.HandleModelEventL( KStartEditModeMdEvent(), |
150 *params ); |
175 *params ); |
151 } |
176 } |
152 else if ( aActionModel->CommandName() == KServiceStopEditMode ) |
177 else if ( aActionModel->CommandName() == KServiceStopEditMode ) |
153 { |
178 { |
154 ret = iEventObserver.HandleModelEventL( KStopEditModeMdEvent(), |
179 ret = iEventObserver.HandleModelEventL( KStopEditModeMdEvent(), |
155 *params ); |
180 *params ); |
156 } |
181 } |
157 else if ( aActionModel->CommandName() == KServiceBack ) |
182 else if ( aActionModel->CommandName() == KServiceBack ) |
158 { |
183 { |
159 ret = iEventObserver.HandleModelEventL( KBackMdEvent(), |
184 ret = iEventObserver.HandleModelEventL( KBackMdEvent(), |
160 *params ); |
185 *params ); |
161 } |
186 } |
162 else if ( aActionModel->CommandName() == KSetFocus ) |
187 else if ( aActionModel->CommandName() == KSetFocus ) |
163 { |
188 { |
164 ret = iEventObserver.HandleModelEventL( KSetFocusEvent(), |
189 ret = iEventObserver.HandleModelEventL( KSetFocusEvent(), |
165 *params ); |
190 *params ); |
166 } |
191 } |
167 |
192 |
168 CleanupStack::PopAndDestroy( params ); |
193 CleanupStack::PopAndDestroy( params ); |
169 return ret; |
194 return ret; |
170 } |
195 } |
171 |
196 |
172 // --------------------------------------------------------------------------- |
197 // --------------------------------------------------------------------------- |
173 // |
198 // |
174 // --------------------------------------------------------------------------- |
199 // --------------------------------------------------------------------------- |
175 // |
200 // |
176 TInt CHnEventHandler::ExecuteExtensionManagerActionL( |
201 TInt CHnEventHandler::ExecuteExtensionManagerActionL( |
177 CHnActionModel* aActionModel ) |
202 CHnActionModel* aActionModel ) |
178 { |
203 { |
179 TUid uid; |
204 TUid uid; |
180 TInt err = ExtractUidFromActionL( aActionModel->Interface(), uid ); |
205 TInt err = ExtractUidFromActionL( aActionModel->Interface(), uid ); |
181 |
206 |
182 if ( KErrNone == err ) |
207 if ( KErrNone == err ) |
183 { |
208 { |
184 HBufC* cmd = HnConvUtils::Str8ToStrFastLC( aActionModel->CommandName() ); |
209 HBufC* cmd = HnConvUtils::Str8ToStrFastLC( aActionModel->CommandName() ); |
185 CLiwGenericParamList* command = aActionModel->CommandLC(); |
210 CLiwGenericParamList* command = aActionModel->CommandLC(); |
186 err = iControllerInterface.ExecuteExtensionActionL( uid, *cmd, command ); |
211 err = iControllerInterface.ExecuteExtensionActionL( uid, *cmd, command ); |
187 CleanupStack::PopAndDestroy( command ); |
212 CleanupStack::PopAndDestroy( command ); |
188 CleanupStack::PopAndDestroy( cmd ); |
213 CleanupStack::PopAndDestroy( cmd ); |
189 } |
214 } |
190 |
215 |
191 return err; |
216 return err; |
192 } |
217 } |
193 |
218 |
194 // --------------------------------------------------------------------------- |
219 // --------------------------------------------------------------------------- |
195 // |
220 // |
196 // --------------------------------------------------------------------------- |
221 // --------------------------------------------------------------------------- |
197 // |
222 // |
198 EXPORT_C TInt CHnEventHandler::ExecuteActionL( CHnActionModel* aActionModel ) |
223 EXPORT_C TInt CHnEventHandler::ExecuteActionL( CHnActionModel* aActionModel ) |
199 { |
224 { |
200 ASSERT( aActionModel ); |
225 ASSERT( aActionModel ); |
201 TInt err( KErrNone ); |
226 TInt err( KErrNone ); |
202 |
227 |
203 if( aActionModel->Service() == KServiceMultimediaMenu ) |
228 if( aActionModel->Service() == KServiceMultimediaMenu ) |
204 { |
229 { |
205 if ( aActionModel->Interface().Length() == 0 ) |
230 if ( aActionModel->Interface().Length() == 0 ) |
206 { |
231 { |
207 err = ExecuteInternalActionL( aActionModel ); |
232 err = ExecuteInternalActionL( aActionModel ); |