|
1 /* |
|
2 * Copyright (c) 2005-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 "T_DataSdpAttrValueUint.h" |
|
19 |
|
20 |
|
21 /*@{*/ |
|
22 //Parameters |
|
23 _LIT(KInputInt, "inputInt"); |
|
24 _LIT(KSdpIntBufObj, "sdpintbufobj"); |
|
25 |
|
26 //Commands |
|
27 _LIT(KCmdNewUintL, "NewUintL"); |
|
28 _LIT(KCmdDestructor, "~"); |
|
29 /*@}*/ |
|
30 |
|
31 // const TInt KInterval = 10000; |
|
32 ////////////////////////////////////////////////////////////////////// |
|
33 // Construction/Destruction |
|
34 ////////////////////////////////////////////////////////////////////// |
|
35 |
|
36 CT_DataSdpAttrValueUint* CT_DataSdpAttrValueUint::NewL() |
|
37 { |
|
38 CT_DataSdpAttrValueUint* ret=new (ELeave) CT_DataSdpAttrValueUint(); |
|
39 CleanupStack::PushL(ret); |
|
40 ret->ConstructL(); |
|
41 CleanupStack::Pop(ret); |
|
42 return ret; |
|
43 } |
|
44 |
|
45 CT_DataSdpAttrValueUint::CT_DataSdpAttrValueUint() |
|
46 : iAttrValUint(NULL) |
|
47 { |
|
48 } |
|
49 |
|
50 void CT_DataSdpAttrValueUint::ConstructL() |
|
51 { |
|
52 } |
|
53 |
|
54 CSdpAttrValue* CT_DataSdpAttrValueUint::GetSdpAttrValue() const |
|
55 { |
|
56 return iAttrValUint; |
|
57 } |
|
58 |
|
59 CT_DataSdpAttrValueUint::~CT_DataSdpAttrValueUint() |
|
60 { |
|
61 DestroyData(); |
|
62 } |
|
63 |
|
64 void CT_DataSdpAttrValueUint::SetObjectL(TAny* aAny) |
|
65 { |
|
66 DestroyData(); |
|
67 iAttrValUint = static_cast<CSdpAttrValueUint*> (aAny); |
|
68 } |
|
69 |
|
70 void CT_DataSdpAttrValueUint::DisownObjectL() |
|
71 { |
|
72 iAttrValUint = NULL; |
|
73 } |
|
74 |
|
75 void CT_DataSdpAttrValueUint::DestroyData() |
|
76 { |
|
77 delete iAttrValUint; |
|
78 iAttrValUint=NULL; |
|
79 } |
|
80 |
|
81 inline TCleanupOperation CT_DataSdpAttrValueUint::CleanupOperation() |
|
82 { |
|
83 return CleanupOperation; |
|
84 } |
|
85 |
|
86 void CT_DataSdpAttrValueUint::CleanupOperation(TAny* aAny) |
|
87 { |
|
88 CSdpAttrValueUint* arg=static_cast<CSdpAttrValueUint*>(aAny); |
|
89 delete arg; |
|
90 } |
|
91 |
|
92 /** |
|
93 * Process a command read from the ini file |
|
94 * |
|
95 * @param aCommand The command to process |
|
96 * @param aSection The section in the ini containing data for the command |
|
97 * @param aAsyncErrorIndex Command index for async calls to return errors to |
|
98 * |
|
99 * @return ETrue if the command is processed |
|
100 * |
|
101 * @leave System wide error |
|
102 */ |
|
103 TBool CT_DataSdpAttrValueUint::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
104 { |
|
105 TBool ret=ETrue; |
|
106 |
|
107 if ( aCommand==KCmdNewUintL ) |
|
108 { |
|
109 DoCmdNewUintL(aSection); |
|
110 } |
|
111 else if ( aCommand==KCmdDestructor ) |
|
112 { |
|
113 DoCmdDestructor(); |
|
114 } |
|
115 else |
|
116 { |
|
117 ret=CT_DataSdpAttrValue::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
118 } |
|
119 |
|
120 return ret; |
|
121 } |
|
122 |
|
123 void CT_DataSdpAttrValueUint::DoCmdNewUintL(const TDesC& aSection) |
|
124 { |
|
125 |
|
126 DestroyData(); |
|
127 TPtrC theString; |
|
128 TPtrC sdpIntBufName; |
|
129 TBool foundParameter=EFalse; |
|
130 if ( GetStringFromConfig(aSection, KInputInt(), theString) ) |
|
131 { |
|
132 foundParameter=ETrue; |
|
133 HBufC8* string8 = HBufC8::NewLC(theString.Length()); |
|
134 string8->Des().Copy(theString); |
|
135 TPtrC8 stringPtr = string8->Des(); |
|
136 TRAPD(err, iAttrValUint = CSdpAttrValueUint::NewUintL(stringPtr)); |
|
137 if ( err!=KErrNone ) |
|
138 { |
|
139 ERR_PRINTF2(_L("CSdpAttrValueUint::NewUintL failed with error %d"), err); |
|
140 SetError(err); |
|
141 } |
|
142 CleanupStack::PopAndDestroy(string8); |
|
143 } |
|
144 |
|
145 if ( GetStringFromConfig(aSection, KSdpIntBufObj(), sdpIntBufName) ) |
|
146 { |
|
147 foundParameter=ETrue; |
|
148 TAny* object=GetDataObjectL(sdpIntBufName); |
|
149 TSdpIntBuf<TUint8>* sdpIntBuf = static_cast<TSdpIntBuf<TUint8>*>(object); |
|
150 TSdpIntBuf<TUint8> sdpIntObj = *sdpIntBuf; |
|
151 const TUint8 *tmp=&sdpIntObj[0]; |
|
152 TPtrC8 bufferPtr(tmp, sdpIntObj.Length()); |
|
153 TRAPD(err, iAttrValUint = CSdpAttrValueUint::NewUintL(bufferPtr)); |
|
154 if ( err!=KErrNone ) |
|
155 { |
|
156 ERR_PRINTF2(_L("CSdpAttrValueInt::NewUintL failed with error %d"), err); |
|
157 SetError(err); |
|
158 } |
|
159 } |
|
160 |
|
161 if (!foundParameter) |
|
162 { |
|
163 ERR_PRINTF2(_L("Missing parameter %S"), &KSdpIntBufObj()); |
|
164 SetBlockResult(EFail); |
|
165 } |
|
166 } |
|
167 |
|
168 void CT_DataSdpAttrValueUint::DoCmdDestructor() |
|
169 { |
|
170 DestroyData(); |
|
171 } |