1 /* |
|
2 * Copyright (c) 2010 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 * Private implementation of Wrapper for CM Manager Symbian interface. |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 |
|
20 #include <QList> |
|
21 #include <e32base.h> |
|
22 #include <cmdestination.h> |
|
23 #include <cmdestination_shim.h> |
|
24 #include <cmconnectionmethod_shim.h> |
|
25 |
|
26 // User includes |
|
27 |
|
28 #include "cmmanager_shim_s60_p.h" |
|
29 #include "OstTraceDefinitions.h" |
|
30 #ifdef OST_TRACE_COMPILER_IN_USE |
|
31 #include "cmmanager_shim_s60Traces.h" |
|
32 #endif |
|
33 |
|
34 |
|
35 /*! |
|
36 \class CmManagerShimPrivate |
|
37 \brief Private implementation class for CM Manager Shim. |
|
38 |
|
39 Wrapper for CM Manager Symbian interface. Symbian leaves are converted to |
|
40 standard C++ exceptions. |
|
41 |
|
42 Wrapper functions are identical to those in CmManagerShim class, so |
|
43 refer to cmdestination_shim.h for descriptions. Private functions in this |
|
44 class are just leaving versions of the same wrapper functions. |
|
45 */ |
|
46 |
|
47 // External function prototypes |
|
48 |
|
49 // Local constants |
|
50 |
|
51 // ======== LOCAL FUNCTIONS ======== |
|
52 |
|
53 // ======== MEMBER FUNCTIONS ======== |
|
54 |
|
55 /*! |
|
56 * Constructor. |
|
57 */ |
|
58 |
|
59 CmManagerShimPrivate::CmManagerShimPrivate() |
|
60 { |
|
61 OstTraceFunctionEntry0(CMMANAGERSHIMPRIVATE_CMMANAGERSHIMPRIVATE_ENTRY); |
|
62 |
|
63 TRAPD(error, iCmManager.OpenL()); |
|
64 TraceIfError(error); |
|
65 qt_symbian_throwIfError(error); |
|
66 |
|
67 OstTraceFunctionExit0(CMMANAGERSHIMPRIVATE_CMMANAGERSHIMPRIVATE_EXIT); |
|
68 } |
|
69 |
|
70 /*! |
|
71 * Destructor. |
|
72 */ |
|
73 |
|
74 CmManagerShimPrivate::~CmManagerShimPrivate() |
|
75 { |
|
76 OstTraceFunctionEntry0(DUP1_CMMANAGERSHIMPRIVATE_CMMANAGERSHIMPRIVATE_ENTRY); |
|
77 |
|
78 iCmManager.Close(); |
|
79 |
|
80 OstTraceFunctionExit0(DUP1_CMMANAGERSHIMPRIVATE_CMMANAGERSHIMPRIVATE_EXIT); |
|
81 } |
|
82 |
|
83 CmDestinationShim *CmManagerShimPrivate::CreateDestination(QString name) |
|
84 { |
|
85 OstTraceFunctionEntry0(CMMANAGERSHIMPRIVATE_CREATEDESTINATION_ENTRY); |
|
86 |
|
87 RCmDestination dest; |
|
88 TRAPD( |
|
89 error, |
|
90 TPtrC16 namePtr(reinterpret_cast<const TUint16*>(name.utf16())); |
|
91 dest = iCmManager.CreateDestinationL(namePtr); |
|
92 dest.UpdateL()); |
|
93 TraceIfError(error); |
|
94 qt_symbian_throwIfError(error); |
|
95 |
|
96 OstTraceFunctionExit0(CMMANAGERSHIMPRIVATE_CREATEDESTINATION_EXIT); |
|
97 return new CmDestinationShim(dest); |
|
98 } |
|
99 |
|
100 CmConnectionMethodShim *CmManagerShimPrivate::CreateConnectionMethod( |
|
101 uint bearerType) |
|
102 { |
|
103 OstTraceFunctionEntry0(CMMANAGERSHIMPRIVATE_CREATECONNECTIONMETHOD_ENTRY); |
|
104 |
|
105 RCmConnectionMethod connectionMethod; |
|
106 TRAPD(error, connectionMethod = iCmManager.CreateConnectionMethodL(bearerType)); |
|
107 TraceIfError(error); |
|
108 qt_symbian_throwIfError(error); |
|
109 |
|
110 OstTraceFunctionExit0(CMMANAGERSHIMPRIVATE_CREATECONNECTIONMETHOD_EXIT); |
|
111 return new CmConnectionMethodShim(connectionMethod); |
|
112 } |
|
113 |
|
114 CmConnectionMethodShim *CmManagerShimPrivate::ConnectionMethod( |
|
115 uint connectionMethodId) const |
|
116 { |
|
117 OstTraceFunctionEntry0(CMMANAGERSHIMPRIVATE_CONNECTIONMETHOD_ENTRY); |
|
118 |
|
119 RCmConnectionMethod connectionMethod; |
|
120 TRAPD(error, connectionMethod = iCmManager.ConnectionMethodL(connectionMethodId)); |
|
121 TraceIfError(error); |
|
122 qt_symbian_throwIfError(error); |
|
123 |
|
124 OstTraceFunctionExit0(CMMANAGERSHIMPRIVATE_CONNECTIONMETHOD_EXIT); |
|
125 return new CmConnectionMethodShim(connectionMethod); |
|
126 } |
|
127 |
|
128 void CmManagerShimPrivate::ConnectionMethod( |
|
129 QList<uint> &cmArray, |
|
130 bool legacyOnly) const |
|
131 { |
|
132 OstTraceFunctionEntry0(DUP1_CMMANAGERSHIMPRIVATE_CONNECTIONMETHOD_ENTRY); |
|
133 |
|
134 TRAPD(error, ConnectionMethodL(cmArray, legacyOnly)); |
|
135 TraceIfError(error); |
|
136 qt_symbian_throwIfError(error); |
|
137 |
|
138 OstTraceFunctionExit0(DUP1_CMMANAGERSHIMPRIVATE_CONNECTIONMETHOD_EXIT); |
|
139 } |
|
140 |
|
141 CmDestinationShim *CmManagerShimPrivate::Destination( |
|
142 uint destinationId) const |
|
143 { |
|
144 OstTraceFunctionEntry0(CMMANAGERSHIMPRIVATE_DESTINATION_ENTRY); |
|
145 |
|
146 RCmDestination dest; |
|
147 TRAPD(error, dest = iCmManager.DestinationL(destinationId)); |
|
148 TraceIfError(error); |
|
149 qt_symbian_throwIfError(error); |
|
150 |
|
151 OstTraceFunctionExit0(CMMANAGERSHIMPRIVATE_DESTINATION_EXIT); |
|
152 return new CmDestinationShim(dest); |
|
153 } |
|
154 |
|
155 void CmManagerShimPrivate::AllDestinations(QList<uint> &destArray) const |
|
156 { |
|
157 OstTraceFunctionEntry0(CMMANAGERSHIMPRIVATE_ALLDESTINATIONS_ENTRY); |
|
158 |
|
159 TRAPD(error, AllDestinationsL(destArray)); |
|
160 TraceIfError(error); |
|
161 qt_symbian_throwIfError(error); |
|
162 |
|
163 OstTraceFunctionExit0(CMMANAGERSHIMPRIVATE_ALLDESTINATIONS_EXIT); |
|
164 } |
|
165 |
|
166 QString CmManagerShimPrivate::GetUncategorizedIcon() const |
|
167 { |
|
168 OstTraceFunctionEntry0(CMMANAGERSHIMPRIVATE_GETUNCATEGORIZEDICON_ENTRY); |
|
169 |
|
170 QString icon; |
|
171 TRAPD(error, GetUncategorizedIconL(icon)); |
|
172 TraceIfError(error); |
|
173 qt_symbian_throwIfError(error); |
|
174 |
|
175 OstTraceFunctionExit0(CMMANAGERSHIMPRIVATE_GETUNCATEGORIZEDICON_EXIT); |
|
176 return icon; |
|
177 } |
|
178 |
|
179 void CmManagerShimPrivate::ConnectionMethodL( |
|
180 QList<uint> &cmArray, |
|
181 bool legacyOnly) const |
|
182 { |
|
183 RArray<TUint32> array; |
|
184 iCmManager.ConnectionMethodL( |
|
185 array, |
|
186 true, // Check bearer type |
|
187 legacyOnly, |
|
188 false); // No Easy WLAN |
|
189 for (TInt i = 0; i < array.Count(); i++) { |
|
190 cmArray.append(array[i]); |
|
191 } |
|
192 // Free memory |
|
193 array.Reset(); |
|
194 } |
|
195 |
|
196 void CmManagerShimPrivate::AllDestinationsL(QList<uint> &destArray) const |
|
197 { |
|
198 destArray.clear(); |
|
199 RArray<TUint32> destinationIdArray; |
|
200 |
|
201 destinationIdArray.Reset(); |
|
202 iCmManager.AllDestinationsL(destinationIdArray); |
|
203 |
|
204 for (TInt i = 0; i < destinationIdArray.Count(); i++) { |
|
205 destArray.append(destinationIdArray[i]); |
|
206 } |
|
207 // Free memory |
|
208 destinationIdArray.Reset(); |
|
209 } |
|
210 |
|
211 void CmManagerShimPrivate::GetUncategorizedIconL(QString &icon) const |
|
212 { |
|
213 HBufC* iconName = iCmManager.GetUncategorizedIconL(); |
|
214 icon = QString::fromUtf16(iconName->Ptr(), iconName->Length()); |
|
215 delete iconName; |
|
216 } |
|
217 |
|
218 /*! |
|
219 * Traces given error code if it is not KErrNone. |
|
220 * |
|
221 * @param[in] error Symbian error code. |
|
222 */ |
|
223 |
|
224 void CmManagerShimPrivate::TraceIfError(TInt error) const |
|
225 { |
|
226 if (error != KErrNone) { |
|
227 OstTrace1( |
|
228 TRACE_WARNING, |
|
229 CMMANAGERSHIMPRIVATE_TRACEIFERROR, |
|
230 "CmManagerShimPrivate::TraceIfError;Error code=%d", |
|
231 error); |
|
232 } |
|
233 } |
|