1 /* |
|
2 * Copyright (c) 2007 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ecom/implementationproxy.h> |
|
20 #include <liwcommon.h> |
|
21 #include <liwserviceifbase.h> |
|
22 |
|
23 #include "ahplugindefs.h" |
|
24 #include "actionhandlerservice.h" |
|
25 #include "serviceerrno.h" |
|
26 |
|
27 #include "actionhandlerinterface.h" |
|
28 |
|
29 const TInt implUid( 0x2000E539); |
|
30 |
|
31 using namespace LIW; |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CActionHandlerService::CActionHandlerService() |
|
38 { |
|
39 |
|
40 } |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CActionHandlerService* CActionHandlerService::NewL() |
|
47 { |
|
48 return new(ELeave) CActionHandlerService(); |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CActionHandlerService::~CActionHandlerService() |
|
56 { |
|
57 |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 void CActionHandlerService::InitialiseL( |
|
65 MLiwNotifyCallback& /*aFrameworkCallback*/, const RCriteriaArray& /*aInterest*/) |
|
66 { |
|
67 |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 void CActionHandlerService::HandleServiceCmdL( const TInt& aCmdId, |
|
75 const CLiwGenericParamList& aInParamList, |
|
76 CLiwGenericParamList& aOutParamList, TUint aCmdOptions, |
|
77 const MLiwNotifyCallback* aCallback ) |
|
78 |
|
79 { |
|
80 TInt errCode( KErrNotSupported ); |
|
81 // Check the command name;Cmd name should be Execute |
|
82 if ( aCmdId == KLiwCmdAsStr && !aCallback && !aCmdOptions ) |
|
83 { |
|
84 TInt pos = 0; |
|
85 TPtrC8 cmdName; |
|
86 const TLiwGenericParam* cmd= NULL; |
|
87 cmd = aInParamList.FindFirst( pos, KCommand ); |
|
88 if ( cmd && pos != KErrNotFound ) |
|
89 { |
|
90 cmdName.Set( cmd->Value().AsData( ) ); |
|
91 if ( !cmdName.CompareF( KActionHandlerInterface ) ) |
|
92 { |
|
93 //Create interface pointer and return the output param |
|
94 CActionHandlerInterface* ifp = |
|
95 CActionHandlerInterface::NewLC( ); |
|
96 aOutParamList.AppendL( TLiwGenericParam( |
|
97 KActionHandlerInterface, TLiwVariant( ifp ) ) ); |
|
98 CleanupStack::Pop( ifp ); |
|
99 errCode = KErrNone; |
|
100 } |
|
101 } |
|
102 else |
|
103 { |
|
104 errCode = KErrArgument; |
|
105 } |
|
106 } |
|
107 if ( errCode != KErrNone ) |
|
108 { |
|
109 aOutParamList.AppendL( TLiwGenericParam( EGenericParamError, |
|
110 TLiwVariant( ErrCodeConversion( errCode ) ) ) ); |
|
111 } |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // ErrCode Conversion |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 TInt32 CActionHandlerService::ErrCodeConversion( TInt code ) |
|
119 { |
|
120 TInt32 err; |
|
121 switch ( code ) |
|
122 { |
|
123 |
|
124 case KErrNotFound: |
|
125 err= SErrNotFound; |
|
126 break; |
|
127 |
|
128 case KErrNoMemory: |
|
129 err = SErrNoMemory; |
|
130 break; |
|
131 |
|
132 case KErrNotSupported: |
|
133 err = SErrServiceNotSupported; |
|
134 break; |
|
135 |
|
136 case KErrArgument: |
|
137 err = SErrInvalidServiceArgument; |
|
138 break; |
|
139 |
|
140 default: |
|
141 err = SErrGeneralError; |
|
142 break; |
|
143 } |
|
144 |
|
145 return err; |
|
146 |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------- |
|
150 // Map the interface UIDs to implementation factory functions |
|
151 // --------------------------------------------------------- |
|
152 // |
|
153 const TImplementationProxy ImplementationTable[] = |
|
154 { |
|
155 IMPLEMENTATION_PROXY_ENTRY( implUid,CActionHandlerService::NewL) |
|
156 }; |
|
157 |
|
158 // --------------------------------------------------------- |
|
159 // Exported proxy for instantiation method resolution |
|
160 // --------------------------------------------------------- |
|
161 // |
|
162 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
163 { |
|
164 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
165 return ImplementationTable; |
|
166 } |
|