|
1 /* |
|
2 * Copyright (c) 2009 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 #include "e32property.h" |
|
19 #include "mussessionproperties.h" |
|
20 #include "mussesseioninformationapi.h" |
|
21 #include <e32cmn.h> |
|
22 |
|
23 static RArray<TUint> iIntProperty; |
|
24 static TInt iErrorCode = KErrNone; |
|
25 static RProperty::TPropertyCalledFunctions iCalledFunction = RProperty::ENone; |
|
26 // Large enough to store maximum length descriptor for RProperty |
|
27 static TBuf<RProperty::KMaxPropertySize> iString = KNullDesC(); |
|
28 static TBuf<RProperty::KMaxPropertySize> iVideoCodecList = KNullDesC(); |
|
29 static TBuf<RProperty::KMaxPropertySize> iSessionRecipient = KNullDesC(); |
|
30 static TBuf<RProperty::KMaxPropertySize> iEngineName = KNullDesC(); |
|
31 static TInt iValue = KErrNotFound; |
|
32 |
|
33 |
|
34 _LIT( KMusTestPropertyReadDesc, "TEST" ); |
|
35 |
|
36 // Function definitions |
|
37 |
|
38 TInt RProperty::Define( TUid /*aCategory*/, TUint /*aKey*/, TInt /*aAttr*/,TInt /*aPreallocate=0*/ ) |
|
39 { |
|
40 iCalledFunction = RProperty::EDefine; |
|
41 return iErrorCode; |
|
42 } |
|
43 |
|
44 TInt RProperty::Delete( TUid /*aCategory*/, TUint aKey) |
|
45 { |
|
46 for(TInt i=0;i<iIntProperty.Count();i=i+2) |
|
47 { |
|
48 if( aKey == iIntProperty[i] ) |
|
49 { |
|
50 iIntProperty.Remove( i ); |
|
51 iIntProperty.Remove( i ); |
|
52 return KErrNone; |
|
53 } |
|
54 } |
|
55 |
|
56 return iErrorCode; |
|
57 } |
|
58 |
|
59 |
|
60 TInt RProperty::Get( TUid /*aCategory*/, TUint aKey, TInt& aVal) |
|
61 { |
|
62 if ( !iErrorCode ) |
|
63 { |
|
64 // if errorcode not set , then try to get value from array. |
|
65 TInt error = Get(aKey,aVal); |
|
66 if ( error != KErrNone ) |
|
67 { |
|
68 aVal = iValue; |
|
69 error = iValue == KErrNotFound ? error : KErrNone; |
|
70 } |
|
71 return error; |
|
72 } |
|
73 else |
|
74 { |
|
75 // if error code is set value doesnt matter. |
|
76 return iErrorCode; |
|
77 } |
|
78 } |
|
79 |
|
80 TInt RProperty::Get( TInt& aValue) |
|
81 { |
|
82 TInt error = iErrorCode; |
|
83 aValue = iPValue; |
|
84 return error; |
|
85 } |
|
86 |
|
87 |
|
88 TInt RProperty::Get( TUid /*aCategory*/, TUint /*aKey*/, TDes8& aValue) |
|
89 { |
|
90 // This is not widely used in Mush , so who cares in stub. |
|
91 aValue.Append( KMusTestPropertyReadDesc ); |
|
92 return iErrorCode; |
|
93 } |
|
94 |
|
95 |
|
96 TInt RProperty::Get( TUid /*aCategory*/, TUint aKey, TDes16& aValue ) |
|
97 { |
|
98 if ( aKey == NMusSessionInformationApi::KMUSCallProvider ) |
|
99 { |
|
100 aValue = iEngineName; |
|
101 } |
|
102 else if ( aKey == NMusSessionApi::KVideoCodecs ) |
|
103 { |
|
104 aValue = iVideoCodecList; |
|
105 } |
|
106 else if ( aKey == NMusSessionApi::KRemoteSipAddress ) |
|
107 { |
|
108 aValue = iSessionRecipient; |
|
109 } |
|
110 else |
|
111 { |
|
112 aValue = iString; |
|
113 } |
|
114 |
|
115 return iErrorCode; |
|
116 } |
|
117 |
|
118 TInt RProperty::Set( TUid /*aCategory*/, TUint aKey, TInt aValue) |
|
119 { |
|
120 for(TInt i=0;i<iIntProperty.Count();i=i+2) |
|
121 { |
|
122 if( aKey == iIntProperty[i] ) |
|
123 { |
|
124 iIntProperty[i+1] = aValue; |
|
125 return KErrNone; |
|
126 } |
|
127 } |
|
128 |
|
129 TInt error = KErrNone; |
|
130 error = iIntProperty.Append(aKey); |
|
131 if (!error) |
|
132 { |
|
133 error = iIntProperty.Append(aValue); |
|
134 } |
|
135 return iErrorCode ? iErrorCode : error; |
|
136 } |
|
137 |
|
138 TInt RProperty::Set( TUid /*aCategory*/, TUint /*aKey*/, const TDesC8& /*aValue*/) |
|
139 { |
|
140 // This is not widely used in Mush , so who cares in stub. |
|
141 return iErrorCode; |
|
142 } |
|
143 |
|
144 |
|
145 TInt RProperty::Set( TUid /*aCategory*/, TUint aKey, const TDesC& aValue ) |
|
146 { |
|
147 |
|
148 if ( aKey == NMusSessionInformationApi::KMUSCallProvider ) |
|
149 { |
|
150 iEngineName = aValue; |
|
151 } |
|
152 |
|
153 else if ( aKey == NMusSessionApi::KVideoCodecs ) |
|
154 { |
|
155 iVideoCodecList = aValue; |
|
156 } |
|
157 else if ( aKey == NMusSessionApi::KRemoteSipAddress ) |
|
158 { |
|
159 iSessionRecipient = aValue; |
|
160 } |
|
161 else |
|
162 { |
|
163 iString = aValue; |
|
164 } |
|
165 return iErrorCode; |
|
166 } |
|
167 |
|
168 |
|
169 TInt RProperty::Attach( TUid /*aCategory*/, TUint /*aKey*/) |
|
170 { |
|
171 return iErrorCode; |
|
172 } |
|
173 |
|
174 |
|
175 void RProperty::Cancel() |
|
176 { |
|
177 iCalledFunction = RProperty::ECancel; |
|
178 if ( iRequestStatus ) |
|
179 { |
|
180 User::RequestComplete( iRequestStatus, KErrCancel ); |
|
181 } |
|
182 iRequestStatus = NULL; |
|
183 } |
|
184 |
|
185 TInt RProperty::Set(TInt aValue) // Non-Static |
|
186 { |
|
187 iPValue = aValue; |
|
188 return iErrorCode; |
|
189 } |
|
190 |
|
191 |
|
192 void RProperty::Subscribe(TRequestStatus& aRequest) |
|
193 { |
|
194 aRequest = KRequestPending; |
|
195 iRequestStatus = &aRequest; |
|
196 |
|
197 } |
|
198 |
|
199 TInt RProperty::Get(TUint& aKey,TInt& aVal) |
|
200 { |
|
201 for(TInt i=0;i<iIntProperty.Count();i=i+2) |
|
202 { |
|
203 if( aKey == iIntProperty[i] ) |
|
204 { |
|
205 aVal = iIntProperty[i+1]; |
|
206 return KErrNone; |
|
207 } |
|
208 } |
|
209 return KErrNotFound; |
|
210 } |
|
211 |
|
212 /* |
|
213 * Stub helper function to set error codes |
|
214 */ |
|
215 void PropertyHelper::SetErrorCode(TInt aVal) |
|
216 { |
|
217 iErrorCode = aVal; |
|
218 } |
|
219 |
|
220 RProperty::TPropertyCalledFunctions PropertyHelper::GetCalledFunction() |
|
221 { |
|
222 return iCalledFunction; |
|
223 } |
|
224 |
|
225 void RProperty::Close() |
|
226 { |
|
227 Cancel(); |
|
228 } |
|
229 |
|
230 void PropertyHelper::Close() |
|
231 { |
|
232 iIntProperty.Close(); |
|
233 iErrorCode = KErrNone; |
|
234 iCalledFunction = RProperty::ENone; |
|
235 iString = KNullDesC(); |
|
236 iEngineName = KNullDesC(); |
|
237 iValue = KErrNotFound; |
|
238 } |
|
239 |