|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include "cmscontact.h" |
|
22 #include "cmssession.h" |
|
23 #include "cmscontactbase.h" |
|
24 #include "cmscontactfielditem.h" |
|
25 #include "cmscommondefines.h" |
|
26 |
|
27 // ---------------------------------------------------- |
|
28 // CCmsContactBase::CCmsContactBase |
|
29 // |
|
30 // ---------------------------------------------------- |
|
31 // |
|
32 CCmsContactBase::CCmsContactBase( RCmsContact& aContact ) : |
|
33 CActive( EPriorityStandard ), |
|
34 iStreamDesc16( ( TText* )"", 0, 0 ), |
|
35 iStreamDesc8( ( TText8* )"", 0, 0 ), |
|
36 iContact( aContact ) |
|
37 { |
|
38 |
|
39 } |
|
40 |
|
41 // ---------------------------------------------------- |
|
42 // CCmsContactBase::CCmsContactBase |
|
43 // |
|
44 // ---------------------------------------------------- |
|
45 // |
|
46 CCmsContactBase::CCmsContactBase( RCmsContact& aContact, |
|
47 TRequestStatus& aClientStatus ) : |
|
48 CActive( EPriorityStandard ), |
|
49 iStreamDesc16( ( TText* )"", 0, 0 ), |
|
50 iStreamDesc8( ( TText8* )"", 0, 0 ), |
|
51 iContact( aContact ), |
|
52 iClientStatus( &aClientStatus ) |
|
53 { |
|
54 |
|
55 } |
|
56 |
|
57 // ---------------------------------------------------- |
|
58 // CCmsContactBase::~CCmsContactBase |
|
59 // |
|
60 // ---------------------------------------------------- |
|
61 // |
|
62 CCmsContactBase::~CCmsContactBase() |
|
63 { |
|
64 Cancel(); |
|
65 delete iStreamBuffer8; |
|
66 delete iStreamBuffer16; |
|
67 } |
|
68 |
|
69 // ---------------------------------------------------- |
|
70 // CCmsContactBase::BaseConstructL |
|
71 // |
|
72 // ---------------------------------------------------- |
|
73 // |
|
74 void CCmsContactBase::BaseConstructL() |
|
75 { |
|
76 CActiveScheduler::Add( this ); |
|
77 ReAllocBufferL( iBinary ? KStreamBufferDefaultSizeBinary : KStreamBufferDefaultSizeText ); |
|
78 } |
|
79 |
|
80 // ---------------------------------------------------- |
|
81 // CCmsContactBase::BaseConstructL |
|
82 // |
|
83 // ---------------------------------------------------- |
|
84 // |
|
85 void CCmsContactBase::ReAllocBufferL( TInt aBufferSize ) |
|
86 { |
|
87 #ifdef _DEBUG |
|
88 RCmsSession::WriteToLog( _L8( "CCmsContactFieldInfo::ReAllocBufferL() - Size: %d" ), aBufferSize ); |
|
89 #endif |
|
90 if( !iBinary ) |
|
91 { |
|
92 delete iStreamBuffer16; |
|
93 iStreamBuffer16 = NULL; |
|
94 iStreamBuffer16 = HBufC::NewL( aBufferSize ); |
|
95 iStreamDesc16.Set( iStreamBuffer16->Des() ); |
|
96 } |
|
97 else |
|
98 { |
|
99 delete iStreamBuffer8; |
|
100 iStreamBuffer8 = NULL; |
|
101 iStreamBuffer8 = HBufC8::NewL( aBufferSize ); |
|
102 iStreamDesc8.Set( iStreamBuffer8->Des() ); |
|
103 } |
|
104 } |
|
105 |
|
106 // ---------------------------------------------------- |
|
107 // CCmsContactBase::StreamDesc8 |
|
108 // |
|
109 // ---------------------------------------------------- |
|
110 // |
|
111 TPtr* CCmsContactBase::StreamDesc16() |
|
112 { |
|
113 return &iStreamDesc16; |
|
114 } |
|
115 |
|
116 // ---------------------------------------------------- |
|
117 // CCmsContactBase::StreamDesc |
|
118 // |
|
119 // ---------------------------------------------------- |
|
120 // |
|
121 TPtr8* CCmsContactBase::StreamDesc8() |
|
122 { |
|
123 return &iStreamDesc8; |
|
124 } |
|
125 |
|
126 // ---------------------------------------------------- |
|
127 // CCmsContactField::ConstructL |
|
128 // |
|
129 // ---------------------------------------------------- |
|
130 // |
|
131 TBool CCmsContactBase::IsBinary() const |
|
132 { |
|
133 return iBinary; |
|
134 } |
|
135 |
|
136 // ---------------------------------------------------- |
|
137 // CCmsContactFieldInfo::DoCancel |
|
138 // |
|
139 // ---------------------------------------------------- |
|
140 // |
|
141 void CCmsContactBase::HandleError() |
|
142 { |
|
143 #ifdef _DEBUG |
|
144 RCmsSession::WriteToLog( _L8( "CCmsContactFieldInfo::HandleError()" ) ); |
|
145 #endif |
|
146 if( iClientStatus ) |
|
147 { |
|
148 User::RequestComplete( iClientStatus, iStatus.Int() ); |
|
149 #ifdef _DEBUG |
|
150 RCmsSession::WriteToLog( _L8( " Client request completed with %d" ), iStatus.Int() ); |
|
151 #endif |
|
152 } |
|
153 else |
|
154 { |
|
155 #ifdef _DEBUG |
|
156 RCmsSession::WriteToLog( _L8( " Client not active => ignore" ) ); |
|
157 #endif |
|
158 } |
|
159 } |
|
160 |
|
161 // ---------------------------------------------------- |
|
162 // CCmsContactBase::Activate |
|
163 // |
|
164 // ---------------------------------------------------- |
|
165 // |
|
166 TRequestStatus& CCmsContactBase::Activate() |
|
167 { |
|
168 #ifdef _DEBUG |
|
169 RCmsSession::WriteToLog( _L8( "CCmsContactBase::Activate()" ) ); |
|
170 #endif |
|
171 SetActive(); |
|
172 if( iClientStatus ) |
|
173 { |
|
174 iStatus = KRequestPending; |
|
175 *iClientStatus = KRequestPending; |
|
176 } |
|
177 return iStatus; |
|
178 } |
|
179 |
|
180 // ---------------------------------------------------- |
|
181 // CCmsContactFieldInfo::DoCancel |
|
182 // |
|
183 // ---------------------------------------------------- |
|
184 // |
|
185 void CCmsContactBase::DoCancel() |
|
186 { |
|
187 #ifdef _DEBUG |
|
188 RCmsSession::WriteToLog( _L8( "CCmsContactBase::DoCancel()" ) ); |
|
189 #endif |
|
190 if( NULL != iClientStatus ) |
|
191 { |
|
192 User::RequestComplete( iClientStatus, KErrCancel ); |
|
193 } |
|
194 else |
|
195 { |
|
196 #ifdef _DEBUG |
|
197 RCmsSession::WriteToLog( _L8( " No request pending" ) ); |
|
198 #endif |
|
199 } |
|
200 } |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 // End of File |