|
1 /* |
|
2 * Copyright (c) 2006-2007 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <s32strm.h> |
|
20 |
|
21 #include "CFActionSubscriptionImpl.h" |
|
22 #include "cftrace.h" |
|
23 |
|
24 EXPORT_C CCFActionSubscriptionImpl* CCFActionSubscriptionImpl::NewL() |
|
25 { |
|
26 FUNC_LOG; |
|
27 |
|
28 CCFActionSubscriptionImpl* self = |
|
29 CCFActionSubscriptionImpl::NewLC(); |
|
30 CleanupStack::Pop( self ); |
|
31 return self; |
|
32 } |
|
33 |
|
34 EXPORT_C CCFActionSubscriptionImpl* CCFActionSubscriptionImpl::NewLC() |
|
35 { |
|
36 FUNC_LOG; |
|
37 |
|
38 CCFActionSubscriptionImpl* self = |
|
39 new( ELeave ) CCFActionSubscriptionImpl; |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL(); |
|
42 |
|
43 return self; |
|
44 } |
|
45 |
|
46 CCFActionSubscriptionImpl::~CCFActionSubscriptionImpl() |
|
47 { |
|
48 FUNC_LOG; |
|
49 |
|
50 delete iIdentifier; |
|
51 } |
|
52 |
|
53 void CCFActionSubscriptionImpl::ConstructL() |
|
54 { |
|
55 FUNC_LOG; |
|
56 |
|
57 iIdentifier = KNullDesC().AllocL(); |
|
58 } |
|
59 |
|
60 CCFActionSubscriptionImpl::CCFActionSubscriptionImpl() |
|
61 { |
|
62 FUNC_LOG; |
|
63 } |
|
64 |
|
65 // METHODS |
|
66 |
|
67 //----------------------------------------------------------------------------- |
|
68 // CCFActionSubscriptionImpl::SetActionIdentifierL |
|
69 //----------------------------------------------------------------------------- |
|
70 // |
|
71 void CCFActionSubscriptionImpl::SetActionIdentifierL( |
|
72 const TDesC& aIdentifier ) |
|
73 { |
|
74 FUNC_LOG; |
|
75 |
|
76 TPtr identifier = iIdentifier->Des(); |
|
77 if( aIdentifier.Length() < identifier.MaxLength() ) |
|
78 { |
|
79 // Just copy |
|
80 identifier.Copy( aIdentifier ); |
|
81 } |
|
82 else |
|
83 { |
|
84 // Delete and re-allocate |
|
85 delete iIdentifier; |
|
86 iIdentifier = 0; |
|
87 iIdentifier = aIdentifier.AllocL(); |
|
88 } |
|
89 } |
|
90 |
|
91 //----------------------------------------------------------------------------- |
|
92 // CCFActionSubscriptionImpl::ActionIdentifier |
|
93 //----------------------------------------------------------------------------- |
|
94 // |
|
95 const TDesC& CCFActionSubscriptionImpl::ActionIdentifier() const |
|
96 { |
|
97 FUNC_LOG; |
|
98 |
|
99 if( iIdentifier ) |
|
100 { |
|
101 return *iIdentifier; |
|
102 } |
|
103 else |
|
104 { |
|
105 return KNullDesC; |
|
106 } |
|
107 } |
|
108 |
|
109 //----------------------------------------------------------------------------- |
|
110 // CCFActionSubscriptionImpl::ExternalizeL |
|
111 //----------------------------------------------------------------------------- |
|
112 // |
|
113 EXPORT_C void CCFActionSubscriptionImpl::ExternalizeL( RWriteStream& aStream ) |
|
114 { |
|
115 FUNC_LOG; |
|
116 |
|
117 aStream.WriteInt16L( iIdentifier->Length() ); |
|
118 aStream.WriteL( *iIdentifier, iIdentifier->Length() ); |
|
119 |
|
120 // Commit stream |
|
121 aStream.CommitL(); |
|
122 } |
|
123 |
|
124 //----------------------------------------------------------------------------- |
|
125 // CCFActionSubscriptionImpl::InternalizeL |
|
126 //----------------------------------------------------------------------------- |
|
127 // |
|
128 EXPORT_C void CCFActionSubscriptionImpl::InternalizeL( RReadStream& aStream ) |
|
129 { |
|
130 FUNC_LOG; |
|
131 |
|
132 delete iIdentifier; |
|
133 iIdentifier = NULL; |
|
134 |
|
135 TInt length = aStream.ReadInt16L(); |
|
136 if( length > 0 ) |
|
137 { |
|
138 iIdentifier = HBufC::NewL( length ); |
|
139 TPtr identifierPtr = iIdentifier->Des(); |
|
140 aStream.ReadL( identifierPtr, length ); |
|
141 } |
|
142 } |
|
143 |
|
144 //----------------------------------------------------------------------------- |
|
145 // CCFActionSubscriptionImpl::SetListener |
|
146 //----------------------------------------------------------------------------- |
|
147 // |
|
148 EXPORT_C void CCFActionSubscriptionImpl::SetListener( |
|
149 MCFActionSubscriptionListener* aListener ) |
|
150 { |
|
151 FUNC_LOG; |
|
152 |
|
153 iListener = aListener; |
|
154 } |
|
155 |
|
156 //----------------------------------------------------------------------------- |
|
157 // CCFActionSubscriptionImpl::Listener |
|
158 //----------------------------------------------------------------------------- |
|
159 // |
|
160 EXPORT_C MCFActionSubscriptionListener& |
|
161 CCFActionSubscriptionImpl::Listener() const |
|
162 { |
|
163 FUNC_LOG; |
|
164 |
|
165 return *iListener; |
|
166 } |
|
167 |
|
168 //----------------------------------------------------------------------------- |
|
169 // CCFActionSubscriptionImpl::Size |
|
170 //----------------------------------------------------------------------------- |
|
171 // |
|
172 EXPORT_C TInt CCFActionSubscriptionImpl::Size() const |
|
173 { |
|
174 FUNC_LOG; |
|
175 |
|
176 TInt size = 0; |
|
177 |
|
178 // Action id length and data |
|
179 size += sizeof( TInt ); |
|
180 size += iIdentifier->Size(); |
|
181 |
|
182 return size; |
|
183 } |