|
1 /* |
|
2 * Copyright (c) 2006-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: Loads the contact service |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ecom/ImplementationProxy.h> |
|
20 #include "contactprovider.h" |
|
21 #include "contactinterface.h" |
|
22 #include "../../inc/serviceerrno.h" |
|
23 #include "contacterrormessage.hrh" |
|
24 |
|
25 |
|
26 //Constant for contact servicecommand. |
|
27 _LIT8( KIfaceContact, "IDataSource" ); |
|
28 _LIT8( KCmdId, "cmd" ); |
|
29 |
|
30 using namespace LIW; |
|
31 |
|
32 /* |
|
33 ----------------------------------------------------------------------------- |
|
34 CContactProvider::CContactProvider() |
|
35 Description : Constructor |
|
36 Return value : N/A |
|
37 ----------------------------------------------------------------------------- |
|
38 */ |
|
39 CContactProvider::CContactProvider() |
|
40 { |
|
41 |
|
42 } |
|
43 /* |
|
44 ----------------------------------------------------------------------------- |
|
45 CContactProvider* CContactProvider::NewL() |
|
46 Description : Two-phased constructor. |
|
47 Return value : CContactProvider object pointer |
|
48 ----------------------------------------------------------------------------- |
|
49 */ |
|
50 CContactProvider* CContactProvider::NewL() |
|
51 { |
|
52 return new(ELeave) CContactProvider(); |
|
53 } |
|
54 /* |
|
55 ----------------------------------------------------------------------------- |
|
56 CContactProvider::~CContactProvider() |
|
57 Description : Destructor, free allocated resources |
|
58 Return value : N/A |
|
59 ----------------------------------------------------------------------------- |
|
60 */ |
|
61 CContactProvider::~CContactProvider() |
|
62 { |
|
63 } |
|
64 /* |
|
65 ----------------------------------------------------------------------------- |
|
66 void CContactProvider::InitialiseL() |
|
67 Description : CLiwServiceIfBase Method called by AIW Framework |
|
68 when AttachL is called. |
|
69 Return value : N/A |
|
70 ----------------------------------------------------------------------------- |
|
71 */ |
|
72 void CContactProvider::InitialiseL( MLiwNotifyCallback& /*aFrameworkCallback*/, |
|
73 const RCriteriaArray& /*aInterest*/ ) |
|
74 { |
|
75 // Not needed. |
|
76 } |
|
77 |
|
78 /* |
|
79 ----------------------------------------------------------------------------- |
|
80 void CContactProvider::HandleServiceCmdL() |
|
81 Description : CLiwServiceIfBase Method called by AIW Framework. |
|
82 Executes generic service commands included in criteria. |
|
83 Return value : N/A |
|
84 ----------------------------------------------------------------------------- |
|
85 */ |
|
86 void CContactProvider::HandleServiceCmdL( const TInt& aCmdId, |
|
87 const CLiwGenericParamList& aInParamList, |
|
88 CLiwGenericParamList& aOutParamList, |
|
89 TUint /*aCmdOptions*/, |
|
90 const MLiwNotifyCallback* /*aCallback*/ ) |
|
91 { |
|
92 |
|
93 TPtrC8 lCmdName; |
|
94 TLiwGenericParam result; |
|
95 const TLiwGenericParam* cmd = NULL; |
|
96 MLiwInterface* interface = NULL; |
|
97 |
|
98 if ( aCmdId == KLiwCmdAsStr ) |
|
99 { |
|
100 TInt pos = 0; |
|
101 cmd = aInParamList.FindFirst( pos, KCmdId ); |
|
102 if ( NULL != cmd ) |
|
103 { |
|
104 lCmdName.Set( cmd->Value().AsData() ); |
|
105 } |
|
106 else |
|
107 { |
|
108 aOutParamList.AppendL( |
|
109 TLiwGenericParam( KErrorCode, TLiwVariant( TInt32( SErrServiceNotSupported ) ) ) ); |
|
110 aOutParamList.AppendL(TLiwGenericParam( KErrorMessage, TLiwVariant( KInterfaceNameMissing ) ) ); |
|
111 } |
|
112 |
|
113 } |
|
114 else |
|
115 { |
|
116 aOutParamList.AppendL( |
|
117 TLiwGenericParam(KErrorCode, TLiwVariant( TInt32( SErrServiceNotSupported ) ) ) ); |
|
118 aOutParamList.AppendL(TLiwGenericParam( KErrorMessage, TLiwVariant( KCommandNotSupported ) ) ); |
|
119 } |
|
120 |
|
121 if( lCmdName.CompareF( KIfaceContact ) == 0 ) |
|
122 { |
|
123 //Create interface pointer and return the output param |
|
124 result.SetNameL( KIfaceContact ); |
|
125 interface = CContactInterface::NewL(); |
|
126 CleanupStack::PushL( interface ); |
|
127 result.Value().Set( interface ); |
|
128 } |
|
129 else |
|
130 { |
|
131 result.SetSemanticId( EGenericParamError ); |
|
132 result.Value().Set( (TInt32)SErrNotFound ); |
|
133 } |
|
134 aOutParamList.AppendL( result ); |
|
135 aOutParamList.AppendL( |
|
136 TLiwGenericParam( KErrorCode, TLiwVariant( TInt32( SErrServiceNotSupported ) ) ) ); |
|
137 |
|
138 aOutParamList.AppendL(TLiwGenericParam( KErrorMessage, TLiwVariant( KInterfaceNotSupported ) ) ); |
|
139 |
|
140 if( interface ) |
|
141 { |
|
142 CleanupStack::Pop( interface ); |
|
143 } |
|
144 result.Reset(); |
|
145 return; |
|
146 } |
|
147 |
|
148 // Map the interface UIDs to implementation factory functions |
|
149 const TImplementationProxy ImplementationTable[] = |
|
150 { |
|
151 IMPLEMENTATION_PROXY_ENTRY( 0x10282CF5, CContactProvider::NewL ) |
|
152 }; |
|
153 |
|
154 /* |
|
155 --------------------------------------------------------- |
|
156 Exported proxy for instantiation method resolution |
|
157 --------------------------------------------------------- |
|
158 */ |
|
159 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
160 { |
|
161 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
162 return ImplementationTable; |
|
163 } |
|
164 |
|
165 |