|
1 /* |
|
2 * Copyright (c) 2006 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 |
|
19 #include <s32strm.h> |
|
20 |
|
21 #include "ncdquerytextitemimpl.h" |
|
22 #include "ncd_cp_queryelement.h" |
|
23 #include "catalogsinterfaceidentifier.h" |
|
24 #include "catalogsutils.h" |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 CNcdQueryTextItem* CNcdQueryTextItem::NewL( |
|
29 RReadStream& aReadStream, CNcdQuery& aParent ) |
|
30 { |
|
31 CNcdQueryTextItem* self = CNcdQueryTextItem::NewLC( aReadStream, aParent ); |
|
32 CleanupStack::Pop( self ); |
|
33 return self; |
|
34 } |
|
35 |
|
36 CNcdQueryTextItem* CNcdQueryTextItem::NewLC( |
|
37 RReadStream& aReadStream, CNcdQuery& aParent ) |
|
38 { |
|
39 CNcdQueryTextItem* self = new ( ELeave ) CNcdQueryTextItem( aParent ); |
|
40 // Using PushL because the object does not have any references yet |
|
41 CleanupStack::PushL( self ); |
|
42 |
|
43 self->ConstructL(); |
|
44 self->InternalizeL( aReadStream ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 CNcdQueryTextItem* CNcdQueryTextItem::NewL( |
|
49 const MNcdConfigurationProtocolQueryElement& aQueryElement, |
|
50 CNcdQuery& aParent ) |
|
51 { |
|
52 CNcdQueryTextItem* self = CNcdQueryTextItem::NewLC( aQueryElement, aParent ); |
|
53 CleanupStack::Pop( self ); |
|
54 return self; |
|
55 } |
|
56 |
|
57 CNcdQueryTextItem* CNcdQueryTextItem::NewLC( |
|
58 const MNcdConfigurationProtocolQueryElement& aQueryElement, |
|
59 CNcdQuery& aParent ) |
|
60 { |
|
61 CNcdQueryTextItem* self = new ( ELeave ) CNcdQueryTextItem( aParent ); |
|
62 // Using PushL because the object does not have any references yet |
|
63 CleanupStack::PushL( self ); |
|
64 |
|
65 self->ConstructL(); |
|
66 self->InternalizeL( aQueryElement ); |
|
67 return self; |
|
68 } |
|
69 |
|
70 void CNcdQueryTextItem::InternalizeL( RReadStream& aReadStream ) |
|
71 { |
|
72 CNcdQueryItem::InternalizeL( aReadStream ); |
|
73 delete iText; |
|
74 iText = NULL; |
|
75 iText = HBufC::NewL( aReadStream, KMaxTInt ); |
|
76 } |
|
77 |
|
78 void CNcdQueryTextItem::InternalizeL( |
|
79 const MNcdConfigurationProtocolQueryElement& aQueryElement ) |
|
80 { |
|
81 CNcdQueryItem::InternalizeL( aQueryElement ); |
|
82 } |
|
83 |
|
84 void CNcdQueryTextItem::ExternalizeL( RWriteStream& aWriteStream ) const |
|
85 { |
|
86 CNcdQueryItem::ExternalizeL( aWriteStream ); |
|
87 aWriteStream << *iText; |
|
88 } |
|
89 |
|
90 |
|
91 const TDesC& CNcdQueryTextItem::Text() |
|
92 { |
|
93 return *iText; |
|
94 } |
|
95 |
|
96 void CNcdQueryTextItem::SetTextL( const TDesC& aText ) |
|
97 { |
|
98 delete iText; |
|
99 iText = NULL; |
|
100 iText = aText.AllocL(); |
|
101 iIsSet = ETrue; |
|
102 } |
|
103 |
|
104 TNcdInterfaceId CNcdQueryTextItem::Type() const |
|
105 { |
|
106 return static_cast<TNcdInterfaceId>(MNcdQueryTextItem::KInterfaceUid); |
|
107 } |
|
108 |
|
109 const TDesC& CNcdQueryTextItem::ValueL() |
|
110 { |
|
111 if ( ! iIsSet ) |
|
112 { |
|
113 User::Leave( KErrArgument ); |
|
114 } |
|
115 return *iText; |
|
116 } |
|
117 |
|
118 CNcdQueryTextItem::~CNcdQueryTextItem() |
|
119 { |
|
120 delete iText; |
|
121 } |
|
122 |
|
123 CNcdQueryTextItem::CNcdQueryTextItem( CNcdQuery& aParent ) |
|
124 : CNcdQueryItem( aParent ) |
|
125 { |
|
126 } |
|
127 |
|
128 void CNcdQueryTextItem::ConstructL() |
|
129 { |
|
130 CNcdQueryItem::ConstructL(); |
|
131 AssignDesL( iText, KNullDesC ); |
|
132 // Register the interfaces of this object |
|
133 MNcdQueryTextItem* queryItem( this ); |
|
134 AddInterfaceL( |
|
135 CCatalogsInterfaceIdentifier::NewL( |
|
136 queryItem, this, MNcdQueryTextItem::KInterfaceUid ) ); |
|
137 } |