|
1 /* |
|
2 * Copyright (c) 2007-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 the License "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: This Class provides the interface for |
|
15 * calling the functionality to Media Management SAPI. |
|
16 * Interface |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #include <ecom/implementationproxy.h> |
|
22 #include <utf.h> |
|
23 |
|
24 #include "mgservicehandler.h" |
|
25 #include "mginterface.h" |
|
26 #include "serviceerrno.h" |
|
27 |
|
28 //Input Keys |
|
29 _LIT8(KDataSource, "IDataSource"); |
|
30 |
|
31 //Output Keys/arguments |
|
32 _LIT8(KErrorCode,"ErrorCode"); |
|
33 _LIT8(KErrorMessage,"ErrorMessage"); |
|
34 _LIT8(KCommand, "cmd"); |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CMgServiceHandler::NewL |
|
38 // Returns the instance of CMgServiceHandler |
|
39 // ----------------------------------------------------------------------------- |
|
40 |
|
41 CMgServiceHandler* CMgServiceHandler::NewL() |
|
42 { |
|
43 return new ( ELeave ) CMgServiceHandler(); |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CMgServiceHandler::~CMgServiceHandler |
|
48 // Class destructor |
|
49 // ----------------------------------------------------------------------------- |
|
50 |
|
51 CMgServiceHandler::~CMgServiceHandler() |
|
52 { |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CMgServiceHandler::InitialiseL |
|
57 // Initialises provider with necessary information |
|
58 // ----------------------------------------------------------------------------- |
|
59 |
|
60 void CMgServiceHandler::InitialiseL(MLiwNotifyCallback& /*aFrameworkCallback*/, |
|
61 const RCriteriaArray& /*aInterest*/) |
|
62 { |
|
63 |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CMgServiceHandler::HandleServiceCmdL |
|
68 // Executes generic service commands included in criteria. |
|
69 // ----------------------------------------------------------------------------- |
|
70 void CMgServiceHandler::HandleServiceCmdL(const TInt& aCmdId, |
|
71 const CLiwGenericParamList& aInParamList, |
|
72 CLiwGenericParamList& aOutParamList, |
|
73 TUint aCmdOptions, |
|
74 const MLiwNotifyCallback* aCallback) |
|
75 { |
|
76 TPtrC errmsg(KNullDesC); |
|
77 if( ( aCallback ) || ( 0 != aCmdOptions ) ) |
|
78 { |
|
79 errmsg.Set(_L("MediaMgmt:Command not supported")); |
|
80 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage,TLiwVariant(errmsg))); |
|
81 |
|
82 // report error if request is anything other than synchronous |
|
83 //or user sends a callback parameter |
|
84 aOutParamList.AppendL(TLiwGenericParam( KErrorCode , TLiwVariant( TInt32( SErrServiceNotSupported ) ) ) ); |
|
85 // return from function |
|
86 return; |
|
87 } |
|
88 |
|
89 TPtrC8 cmdName; |
|
90 const TLiwGenericParam* cmd = NULL; |
|
91 |
|
92 if ( aCmdId == KLiwCmdAsStr ) |
|
93 { |
|
94 TInt pos = 0; |
|
95 cmd = aInParamList.FindFirst( pos, KCommand ); |
|
96 if ( NULL != cmd ) |
|
97 { |
|
98 cmdName.Set( cmd->Value().AsData() ); |
|
99 } |
|
100 else |
|
101 { |
|
102 errmsg.Set(_L("MediaMgmt:Interface name missing")); |
|
103 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage,TLiwVariant(errmsg))); |
|
104 aOutParamList.AppendL( |
|
105 TLiwGenericParam( KErrorCode, TLiwVariant( TInt32( SErrServiceNotSupported ) ) ) ); |
|
106 } |
|
107 } |
|
108 else |
|
109 { |
|
110 errmsg.Set(_L("MediaMgmt:Command not supported")); |
|
111 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage,TLiwVariant(errmsg))); |
|
112 aOutParamList.AppendL( |
|
113 TLiwGenericParam(KErrorCode, TLiwVariant( TInt32( SErrServiceNotSupported ) ) ) ); |
|
114 } |
|
115 |
|
116 |
|
117 if( 0 == cmdName.CompareF( KDataSource ) ) |
|
118 { |
|
119 |
|
120 //Create interface pointer and return the output param |
|
121 CMgInterface* ifp =CMgInterface::NewL(); |
|
122 CleanupClosePushL( *ifp ); |
|
123 aOutParamList.AppendL( TLiwGenericParam(KDataSource, TLiwVariant( ifp ) ) ); |
|
124 CleanupStack::Pop( ifp ); |
|
125 return; |
|
126 } |
|
127 else |
|
128 { |
|
129 errmsg.Set(_L("MediaMgmt:Requested interface not supported by the provider")); |
|
130 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage,TLiwVariant(errmsg))); |
|
131 |
|
132 aOutParamList.AppendL( |
|
133 TLiwGenericParam( KErrorCode, TLiwVariant( TInt32( SErrServiceNotSupported ) ) ) ); |
|
134 |
|
135 } |
|
136 } |
|
137 |
|
138 // |
|
139 // Rest of the file is for ECom initialization. |
|
140 // |
|
141 |
|
142 // Map the interface UIDs to implementation factory functions |
|
143 const TImplementationProxy ImplementationTable[] = |
|
144 { |
|
145 IMPLEMENTATION_PROXY_ENTRY(0x10282CF8, CMgServiceHandler::NewL) |
|
146 }; |
|
147 |
|
148 // --------------------------------------------------------- |
|
149 // Exported proxy for instantiation method resolution |
|
150 // --------------------------------------------------------- |
|
151 // |
|
152 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
153 { |
|
154 aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); |
|
155 return ImplementationTable; |
|
156 } |