|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <ctsy/tflogger.h> |
|
20 #include "cmmfaxcompletion.h" |
|
21 #include "cmmcalltsy.h" |
|
22 |
|
23 // ======== MEMBER FUNCTIONS ======== |
|
24 |
|
25 CMmFaxCompletion::CMmFaxCompletion() : CBase(), iTsyReqHandle ( 0 ), |
|
26 iTelObject( NULL ) |
|
27 { |
|
28 TFLOGSTRING("TSY: CMmFaxCompletion::CMmFaxCompletion" ); |
|
29 } |
|
30 |
|
31 CMmFaxCompletion::~CMmFaxCompletion() |
|
32 { |
|
33 TFLOGSTRING("TSY: CMmFaxCompletion::~CMmFaxCompletion"); |
|
34 if ( iTsyReqHandle ) |
|
35 { |
|
36 TFLOGSTRING2("TSY: CMmFaxCompletion::~CMmFaxCompletion: request %d not completed!", iTsyReqHandle); |
|
37 // Completion should not be done here, because in some cases |
|
38 // operations are completed automatically by ETel! |
|
39 // CompleteOperation(KErrCancel); |
|
40 } |
|
41 } |
|
42 |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CMmFaxCompletion::CompleteOperation |
|
46 // Completes ongoing read/write operation. |
|
47 // Returns: None |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 void CMmFaxCompletion::CompleteOperation( |
|
51 TInt aError ) // error Value |
|
52 { |
|
53 TFLOGSTRING2("TSY: CMmFaxCompletion::CompleteOperation iTsyReqHandle: %d", iTsyReqHandle ); |
|
54 if ( 0 < iTsyReqHandle ) |
|
55 { |
|
56 iTelObject->ReqCompleted( iTsyReqHandle, aError ); |
|
57 iTsyReqHandle = 0; |
|
58 } |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CMmFaxCompletion::Configure |
|
63 // Fax configuration. Set parameters for Fax server completion. |
|
64 // Returns: None |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 void CMmFaxCompletion::Configure( |
|
68 const TTsyReqHandle aTsyReqHandle, |
|
69 CTelObject* aTelObject ) |
|
70 { |
|
71 if ( 0 < iTsyReqHandle ) |
|
72 { |
|
73 TFLOGSTRING3("TSY: CMmFaxCompletion::Configure overwriting previous request %d with %d", |
|
74 iTsyReqHandle, aTsyReqHandle); |
|
75 } |
|
76 |
|
77 iTsyReqHandle = aTsyReqHandle; |
|
78 iTelObject = aTelObject; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // CMmFaxCompletion::GetCadenceAndTimeOfLastRing |
|
83 // Returns a cadence and time of the last ring. |
|
84 // Returns: None |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void CMmFaxCompletion::GetCadenceAndTimeOfLastRing( |
|
88 TTimeIntervalMicroSeconds& /*aCadence*/, // cadence time |
|
89 TTime& /*aTime*/ ) // time |
|
90 { |
|
91 TFLOGSTRING("TSY: CMmFaxCompletion::GetCadenceAndTimeOfLastRing"); |
|
92 // Checking the usage of aCadence and aTime in the calling function |
|
93 // (fax server) shows that we don't need to change the values. |
|
94 // REINTERPRET_CAST(CTsyPhone*,iMmCall->Owner()->Owner())-> |
|
95 // GetCadenceAndTimeOfLastRing(aCadence,aTime); |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CMmFaxCompletion::RxConnectComplete |
|
100 // Informs that receiving connection is complete. |
|
101 // Returns: None |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 void CMmFaxCompletion::RxConnectComplete( |
|
105 TInt aError ) |
|
106 { |
|
107 TFLOGSTRING2("TSY: CMmFaxCompletion::RXConnectComplete ErrorValue: %d", aError); |
|
108 CMmCallTsy* mmCall = REINTERPRET_CAST(CMmCallTsy*, iTelObject); |
|
109 |
|
110 // This is a good place to fill missing remote party phone number. |
|
111 if ( KErrNone== aError ) |
|
112 { |
|
113 FillAnswerback( mmCall ); |
|
114 } |
|
115 |
|
116 if ( 0 < iTsyReqHandle ) |
|
117 { |
|
118 |
|
119 |
|
120 if ( RMobileCall::EMobileTerminated== mmCall->CallDirection() ) |
|
121 { |
|
122 // answered to incoming call |
|
123 mmCall->CompleteAnswerIncomingCall( aError ); |
|
124 } |
|
125 else |
|
126 { |
|
127 // dialled to some fax machine to get a fax.. |
|
128 mmCall->CompleteDial( aError); |
|
129 } |
|
130 iTsyReqHandle = 0; |
|
131 } |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // CMmFaxCompletion::RxFaxDataComplete |
|
136 // Informs that receiving data is complete. |
|
137 // Returns: None |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 void CMmFaxCompletion::RxFaxDataComplete( |
|
141 TInt aError ) // in: an error value |
|
142 { |
|
143 TFLOGSTRING2("TSY: CMmFaxCompletion::RxFaxDataComplete ErrorValue: %d", aError); |
|
144 if ( 0 < iTsyReqHandle ) |
|
145 { |
|
146 iTelObject->ReqCompleted( iTsyReqHandle, aError ); |
|
147 iTsyReqHandle = 0; |
|
148 } |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // CMmFaxCompletion::RxPostPageComplete |
|
153 // Informs that Post Page is complete. |
|
154 // Returns: None |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 void CMmFaxCompletion::RxPostPageComplete( |
|
158 TInt aError ) |
|
159 { |
|
160 |
|
161 TFLOGSTRING2("TSY: CMmFaxCompletion::RxPostPageComplete ErrorValue: %d", aError ); |
|
162 if ( 0 < iTsyReqHandle) |
|
163 { |
|
164 iTelObject->ReqCompleted( iTsyReqHandle, aError ); |
|
165 iTsyReqHandle = 0; |
|
166 } |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // CMmFaxCompletion::RxPostPageComplete |
|
171 // Fax transmit connection is completed. |
|
172 // Returns: None |
|
173 // --------------------------------------------------------------------------- |
|
174 // |
|
175 void CMmFaxCompletion::TxConnectComplete( |
|
176 TInt aError ) |
|
177 { |
|
178 TFLOGSTRING2("TSY: CMmFaxCompletion::TXConnectComplete ErrorValue: %d", aError); |
|
179 |
|
180 CMmCallTsy* mmCall = REINTERPRET_CAST(CMmCallTsy*,iTelObject); |
|
181 |
|
182 // this is a good place to fill missing caller id |
|
183 if ( KErrNone == aError ) |
|
184 { |
|
185 FillAnswerback( mmCall ); |
|
186 } |
|
187 |
|
188 if ( 0 < iTsyReqHandle ) |
|
189 { |
|
190 mmCall->CompleteDial( aError ); |
|
191 iTsyReqHandle = 0; |
|
192 } |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------------------------- |
|
196 // CMmFaxCompletion::TxFaxDataComplete |
|
197 // Transmission fax data is complete. |
|
198 // Returns: None |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 void CMmFaxCompletion::TxFaxDataComplete( |
|
202 TInt aError ) |
|
203 { |
|
204 TFLOGSTRING2("TSY: CMmFaxCompletion::TxFaxDataComplete ErrorValue: %d", aError); |
|
205 |
|
206 if ( 0 < iTsyReqHandle ) |
|
207 { |
|
208 iTelObject->ReqCompleted( iTsyReqHandle, aError ); |
|
209 iTsyReqHandle = 0; |
|
210 } |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------------------------- |
|
214 // CMmFaxCompletion::TxPostPageComplete |
|
215 // Transmission post page is complete. |
|
216 // Returns: None |
|
217 // --------------------------------------------------------------------------- |
|
218 // |
|
219 void CMmFaxCompletion::TxPostPageComplete( |
|
220 TInt aError ) |
|
221 { |
|
222 TFLOGSTRING2("TSY: CMmFaxCompletion::TxPostPageComplete ErrorValue: %d", aError ); |
|
223 |
|
224 if ( 0 < iTsyReqHandle ) |
|
225 { |
|
226 iTelObject->ReqCompleted( iTsyReqHandle, aError ); |
|
227 iTsyReqHandle = 0; |
|
228 } |
|
229 } |
|
230 |
|
231 // --------------------------------------------------------------------------- |
|
232 // CMmFaxCompletion::FillAnswerback |
|
233 // Checks progress information chunk and fills iAnswerBack field. |
|
234 // Returns: None |
|
235 // --------------------------------------------------------------------------- |
|
236 // |
|
237 void CMmFaxCompletion::FillAnswerback( |
|
238 CMmCallTsy* aMmCall ) |
|
239 { |
|
240 TFLOGSTRING("TSY: CMmFaxCompletion::FillAnswerback"); |
|
241 |
|
242 if ( aMmCall ) |
|
243 { |
|
244 // if progress chunk already exists, this will return pointer to existing chunk. |
|
245 RFax::TProgress* faxProgress = aMmCall->CreateFaxProgressChunk(); |
|
246 if ( faxProgress ) |
|
247 { |
|
248 |
|
249 if ( 0 == faxProgress->iAnswerback.Length() ) |
|
250 { |
|
251 TFLOGSTRING("TSY: CMmFaxCompletion::FillAnswerback Getting missing remote number from call info"); |
|
252 // Copy remote party phone number to Progress chunk's |
|
253 // answerback field. Answerback will hold only leftmost 20 |
|
254 // numbers if the number is longer than that. |
|
255 RMobileCall::TMobileCallInfoV1 info; |
|
256 RMobileCall::TMobileCallInfoV1Pckg infoPkg(info); |
|
257 aMmCall->FillMobileCallInfo(&infoPkg); |
|
258 faxProgress->iAnswerback.Copy( |
|
259 info.iRemoteParty.iRemoteNumber.iTelNumber.Left( 20 ) ); |
|
260 } |
|
261 } |
|
262 } |
|
263 } |
|
264 |
|
265 // ================= OTHER EXPORTED FUNCTIONS =============================== |
|
266 |
|
267 // End of File |