|
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: Implements location service handler (This will be part of |
|
15 * Ecom plugin. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <liwserviceifbase.h> |
|
21 #include <LiwCommon.h> |
|
22 #include <ecom/ImplementationProxy.h> |
|
23 #include "locationservicehandler.h" |
|
24 #include "locationcb.h" |
|
25 #include "locationinterface.h" |
|
26 |
|
27 using namespace LIW; |
|
28 |
|
29 void CLocServiceHandler::InitialiseL(MLiwNotifyCallback& /*aFrameworkCallback*/, |
|
30 const RCriteriaArray& aInterest) |
|
31 { |
|
32 TInt count = aInterest.Count() ; |
|
33 for (TInt i = 0; i < count; i++) |
|
34 { |
|
35 if (aInterest[i]->ContentType() == KLocationContents) |
|
36 { |
|
37 iContentType = KLocationContents; |
|
38 return; |
|
39 } |
|
40 } |
|
41 User::Leave(KErrNotFound); |
|
42 } |
|
43 |
|
44 |
|
45 /** |
|
46 * HandleServiceCmdL |
|
47 */ |
|
48 |
|
49 void CLocServiceHandler :: HandleServiceCmdL(const TInt& aCmdId, |
|
50 const CLiwGenericParamList& aInParamList, |
|
51 CLiwGenericParamList& aOutParamList, |
|
52 TUint aCmdOptions, |
|
53 const MLiwNotifyCallback* aCallback) |
|
54 { |
|
55 TRAPD(error , CmdExecuteL(aCmdId , aInParamList, aOutParamList ,aCmdOptions , aCallback)) ; |
|
56 |
|
57 if ( error ) |
|
58 { |
|
59 TInt sapierror = CLocationInterface::ConvertToSapiError(error); |
|
60 aOutParamList.AppendL(TLiwGenericParam(KErrorCode , TLiwVariant(sapierror))) ; |
|
61 } |
|
62 else |
|
63 { |
|
64 aOutParamList.AppendL(TLiwGenericParam(KErrorCode , TLiwVariant(error))) ; |
|
65 } |
|
66 |
|
67 } |
|
68 |
|
69 /* |
|
70 * class CLocServiceHandler |
|
71 */ |
|
72 |
|
73 CLocServiceHandler* CLocServiceHandler::NewL() |
|
74 { |
|
75 return new (ELeave) CLocServiceHandler(); |
|
76 } |
|
77 |
|
78 /** |
|
79 * CLocServiceHandler::CmdExecuteL, this method is called by CLocServiceHandler::HandleCmdL() |
|
80 * to catch any leaves that might occur during execution of a LiwCommand.This is an private |
|
81 * method of this class. |
|
82 */ |
|
83 |
|
84 void CLocServiceHandler::CmdExecuteL( |
|
85 const TInt& aCmdId, |
|
86 const CLiwGenericParamList& aInParamList, |
|
87 CLiwGenericParamList& aOutParamList, |
|
88 TUint /*aCmdOptions */, |
|
89 const MLiwNotifyCallback* /*aCallback*/) |
|
90 { |
|
91 TLiwGenericParam r; |
|
92 const TLiwGenericParam* p = NULL; |
|
93 CLocationInterface *interfaceLocation ; |
|
94 aOutParamList.Reset() ; |
|
95 |
|
96 if (aCmdId == KLiwCmdAsStr) |
|
97 { |
|
98 TInt pos = 0; |
|
99 p = aInParamList.FindFirst(pos, _L8("cmd")); |
|
100 } |
|
101 |
|
102 if (p && (p->Value().AsData() == KLsInterfaceName)) |
|
103 { |
|
104 |
|
105 if (iContentType == KLocationContents) |
|
106 { |
|
107 interfaceLocation = CLocationInterface :: NewL() ; |
|
108 CleanupStack :: PushL(interfaceLocation) ; |
|
109 aOutParamList.AppendL(TLiwGenericParam(KLsInterfaceName , TLiwVariant(interfaceLocation))) ; |
|
110 |
|
111 }//End of KLocationContents |
|
112 |
|
113 } //End of KLsInterface |
|
114 |
|
115 else |
|
116 { |
|
117 aOutParamList.AppendL(TLiwGenericParam(KErrorCode , TLiwVariant((TInt32)KErrGeneral))); |
|
118 } |
|
119 |
|
120 |
|
121 |
|
122 aOutParamList.AppendL(TLiwGenericParam(KErrorCode , TLiwVariant(KErrNone))) ; |
|
123 CleanupStack :: Pop (interfaceLocation) ; |
|
124 |
|
125 return; |
|
126 |
|
127 } |
|
128 |
|
129 |
|
130 |
|
131 /** |
|
132 * @Default constructor |
|
133 */ |
|
134 |
|
135 CLocServiceHandler :: CLocServiceHandler() |
|
136 { |
|
137 ; |
|
138 } |
|
139 |
|
140 /** |
|
141 * @Default destructor |
|
142 */ |
|
143 |
|
144 CLocServiceHandler :: ~CLocServiceHandler() |
|
145 { |
|
146 ; |
|
147 } |
|
148 |
|
149 // Map the interface UIDs to implementation factory functions |
|
150 const TImplementationProxy ImplementationTable[] = |
|
151 { |
|
152 |
|
153 IMPLEMENTATION_PROXY_ENTRY(0x10282CF7, CLocServiceHandler::NewL) |
|
154 }; |
|
155 |
|
156 // --------------------------------------------------------- |
|
157 // Exported proxy for instantiation method resolution |
|
158 // --------------------------------------------------------- |
|
159 // |
|
160 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
161 { |
|
162 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
163 return ImplementationTable; |
|
164 } |