|
1 /* |
|
2 * Copyright (c) 2004 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: This class handles the data sending |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __CPENGSENDDATAOPERATION_H__ |
|
19 #define __CPENGSENDDATAOPERATION_H__ |
|
20 |
|
21 // INCLUDES |
|
22 #include <E32Std.h> |
|
23 |
|
24 #include "PresenceDebugPrint.h" |
|
25 |
|
26 // WV Engine walk around |
|
27 #include <impspurecli.h> |
|
28 |
|
29 // FORWARD DECLARATION |
|
30 class RImpsEng; |
|
31 |
|
32 // CONSTANTS |
|
33 /** |
|
34 * Send operation repeat time |
|
35 */ |
|
36 const TInt KSendOperationRepeatTime = 100000; |
|
37 |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * Send data operation holder |
|
43 * |
|
44 * @since 3.0 |
|
45 */ |
|
46 NONSHARABLE_CLASS( CPEngSendDataOperation ) : |
|
47 public CBase |
|
48 { |
|
49 public: |
|
50 /** |
|
51 * Default constructor |
|
52 */ |
|
53 static inline CPEngSendDataOperation* NewLC(); |
|
54 |
|
55 inline CPEngSendDataOperation() |
|
56 : iOpId( KErrNone ), |
|
57 iData( NULL ) |
|
58 { |
|
59 } |
|
60 |
|
61 /** |
|
62 * Destructor |
|
63 */ |
|
64 inline ~CPEngSendDataOperation() |
|
65 { |
|
66 delete iData; |
|
67 if ( iStatus ) |
|
68 { |
|
69 User::RequestComplete( iStatus, KErrCancel ); |
|
70 } |
|
71 } |
|
72 |
|
73 public: // new function of the class |
|
74 |
|
75 |
|
76 /** |
|
77 * Set ids, operation and log id |
|
78 * @since 3.0 |
|
79 */ |
|
80 inline void SetIds( TInt aOperationId, TInt aLogId ) |
|
81 { |
|
82 iOpId = aOperationId; |
|
83 iLogId = aLogId; |
|
84 }; |
|
85 |
|
86 inline void SetRequestStatus( TRequestStatus& aStatus ) |
|
87 { |
|
88 iStatus = &aStatus; |
|
89 }; |
|
90 |
|
91 /** |
|
92 * Trequest status of this operation |
|
93 * |
|
94 * @since 3.0 |
|
95 */ |
|
96 inline TRequestStatus* Status() |
|
97 { |
|
98 return iStatus; |
|
99 } |
|
100 |
|
101 /** |
|
102 * Get Ids |
|
103 * |
|
104 * @since 3.0 |
|
105 * @return operation Id |
|
106 */ |
|
107 inline TInt OperationId() const |
|
108 { |
|
109 return iOpId; |
|
110 } |
|
111 |
|
112 inline TInt LogId() const |
|
113 { |
|
114 return iLogId; |
|
115 } |
|
116 |
|
117 /** |
|
118 * Complete operation |
|
119 * |
|
120 * @since 3.0 |
|
121 * @param aCode complete code |
|
122 */ |
|
123 inline void CompletedOperation( TInt aCode ); |
|
124 |
|
125 /** |
|
126 * Set response buffer |
|
127 * Owner ship is transfered |
|
128 * |
|
129 * @since 3.0 |
|
130 * @param aBuff response buffer |
|
131 */ |
|
132 inline void SetResponse( HBufC8* aBuff ); |
|
133 |
|
134 /** |
|
135 * Response buffer, |
|
136 * owner ship is transfered |
|
137 * |
|
138 * @since 3.0 |
|
139 * @return transfer buffer |
|
140 */ |
|
141 inline HBufC8* Response(); |
|
142 |
|
143 private: // Public data |
|
144 |
|
145 /// Status of the operation |
|
146 TRequestStatus* iStatus; |
|
147 |
|
148 /// OWN: Operation Id |
|
149 TInt iOpId; |
|
150 |
|
151 /// OWN: Response buffer |
|
152 HBufC8* iData; |
|
153 |
|
154 /// OWN: Id used for logs writting |
|
155 TInt iLogId; |
|
156 }; |
|
157 |
|
158 /** |
|
159 * NewLC |
|
160 */ |
|
161 inline CPEngSendDataOperation* CPEngSendDataOperation::NewLC() |
|
162 { |
|
163 CPEngSendDataOperation* self = new( ELeave ) |
|
164 CPEngSendDataOperation(); |
|
165 |
|
166 CleanupStack::PushL( self ); |
|
167 return self; |
|
168 } |
|
169 |
|
170 /** |
|
171 * Complete operation |
|
172 */ |
|
173 inline void CPEngSendDataOperation::CompletedOperation( TInt aCode ) |
|
174 { |
|
175 PENG_DP( D_PENG_LIT( "CPEngSendDataOperation::CompletedOperation:id:%d,code:%d" ), |
|
176 iOpId, |
|
177 aCode ); |
|
178 if ( !iStatus ) |
|
179 { |
|
180 PENG_DP( |
|
181 D_PENG_LIT( "CPEngSendDataOperation::CompletedOperation:!!Double Completion!!!" ) ); |
|
182 return; |
|
183 } |
|
184 User::RequestComplete( iStatus, aCode ); |
|
185 iStatus = NULL; |
|
186 } |
|
187 |
|
188 /** |
|
189 * Set response |
|
190 */ |
|
191 inline void CPEngSendDataOperation::SetResponse( HBufC8* aBuff ) |
|
192 { |
|
193 PENG_DP( D_PENG_LIT( "CPEngPureDataHandler::HandlePureDataL - id: %d" ), iOpId ); |
|
194 delete iData; |
|
195 iData = aBuff; |
|
196 } |
|
197 |
|
198 /** |
|
199 * Get response |
|
200 */ |
|
201 inline HBufC8* CPEngSendDataOperation::Response() |
|
202 { |
|
203 HBufC8* b = iData; |
|
204 iData = NULL; |
|
205 return b; |
|
206 } |
|
207 |
|
208 #endif // __CPENGSENDDATAOPERATION_H__ |
|
209 |
|
210 // End of File |