|
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_DataSdpAttrValueBoolean.h" |
|
19 |
|
20 /*@{*/ |
|
21 |
|
22 |
|
23 //Parameters |
|
24 _LIT(KInputBool, "inputbool"); |
|
25 |
|
26 //Commands |
|
27 _LIT(KCmdNewBoolL, "NewBoolL"); |
|
28 _LIT(KCmdDestructor, "~"); |
|
29 /*@}*/ |
|
30 |
|
31 ////////////////////////////////////////////////////////////////////// |
|
32 // Construction/Destruction |
|
33 ////////////////////////////////////////////////////////////////////// |
|
34 |
|
35 CT_DataSdpAttrValueBoolean* CT_DataSdpAttrValueBoolean::NewL() |
|
36 { |
|
37 CT_DataSdpAttrValueBoolean* ret=new (ELeave) CT_DataSdpAttrValueBoolean(); |
|
38 CleanupStack::PushL(ret); |
|
39 ret->ConstructL(); |
|
40 CleanupStack::Pop(ret); |
|
41 return ret; |
|
42 } |
|
43 |
|
44 CT_DataSdpAttrValueBoolean::CT_DataSdpAttrValueBoolean() |
|
45 : iAttrValBool(NULL) |
|
46 { |
|
47 } |
|
48 |
|
49 void CT_DataSdpAttrValueBoolean::ConstructL() |
|
50 { |
|
51 } |
|
52 |
|
53 CT_DataSdpAttrValueBoolean::~CT_DataSdpAttrValueBoolean() |
|
54 { |
|
55 DestroyData(); |
|
56 } |
|
57 |
|
58 CSdpAttrValue* CT_DataSdpAttrValueBoolean::GetSdpAttrValue() const |
|
59 { |
|
60 return iAttrValBool; |
|
61 } |
|
62 |
|
63 void CT_DataSdpAttrValueBoolean::SetObjectL(TAny* aAny) |
|
64 { |
|
65 DestroyData(); |
|
66 iAttrValBool = static_cast<CSdpAttrValueBoolean*> (aAny); |
|
67 } |
|
68 |
|
69 void CT_DataSdpAttrValueBoolean::DisownObjectL() |
|
70 { |
|
71 iAttrValBool = NULL; |
|
72 } |
|
73 |
|
74 void CT_DataSdpAttrValueBoolean::DestroyData() |
|
75 { |
|
76 delete iAttrValBool; |
|
77 iAttrValBool=NULL; |
|
78 } |
|
79 |
|
80 |
|
81 inline TCleanupOperation CT_DataSdpAttrValueBoolean::CleanupOperation() |
|
82 { |
|
83 return CleanupOperation; |
|
84 } |
|
85 |
|
86 void CT_DataSdpAttrValueBoolean::CleanupOperation(TAny* aAny) |
|
87 { |
|
88 CSdpAttrValueBoolean* value=static_cast<CSdpAttrValueBoolean*>(aAny); |
|
89 delete value; |
|
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_DataSdpAttrValueBoolean::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
104 { |
|
105 TBool ret = ETrue; |
|
106 |
|
107 if ( aCommand==KCmdNewBoolL ) |
|
108 { |
|
109 DoCmdNewBool(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_DataSdpAttrValueBoolean::DoCmdNewBool(const TDesC& aSection) |
|
124 { |
|
125 DestroyData(); |
|
126 |
|
127 TBool inputBool = EFalse; |
|
128 if ( GetBoolFromConfig(aSection, KInputBool(), inputBool) ) |
|
129 { |
|
130 TRAPD(err, iAttrValBool = CSdpAttrValueBoolean::NewBoolL(inputBool)); |
|
131 if ( err!=KErrNone ) |
|
132 { |
|
133 ERR_PRINTF2(_L("CSdpAttrValueBoolean::NewBoolL failed with error %d"), err); |
|
134 SetError(err); |
|
135 } |
|
136 } |
|
137 else |
|
138 { |
|
139 ERR_PRINTF2(_L("Missing parameter %S"), &KInputBool()); |
|
140 SetBlockResult(EFail); |
|
141 } |
|
142 } |
|
143 |
|
144 void CT_DataSdpAttrValueBoolean::DoCmdDestructor() |
|
145 { |
|
146 DestroyData(); |
|
147 } |