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