1 /* |
|
2 * Copyright (c) 2002 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 the License "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: Implementation of CUnknownContentHandler. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "CUnknownContentHandler.h" |
|
23 #include "PushMtmUtil.h" |
|
24 #include "PushMtmLog.h" |
|
25 #include "PushContentHandlerPanic.h" |
|
26 #include "StringResourceReader.h" |
|
27 #include <msvids.h> |
|
28 #ifdef __SERIES60_PUSH_SP |
|
29 #include <CUnknownPushMsgEntry.h> |
|
30 #include <BioDB.h> // BIO Message Database and message query methods |
|
31 #include <gsmubuf.h> // CSmsBuffer class |
|
32 #include <gsmumsg.h> // CSmsMessage class |
|
33 #include <smuthdr.h> // CSmsHeader class |
|
34 #include <smut.h> // TSmsUtilities class |
|
35 #include <txtrich.h> // CRichText class |
|
36 #include <biouids.h> // KUidBioMessageTypeMtm const |
|
37 #include <apgcli.h> |
|
38 #include <apmrec.h> |
|
39 #include <DocumentHandler.h> |
|
40 #include <Uri16.h> |
|
41 #include <UriUtils.h> |
|
42 #include <msvuids.h> // KUidMsvMessageEntry const |
|
43 #include <PushMtmUi.rsg> |
|
44 |
|
45 // SMUT Unbranch |
|
46 #include <csmsgetdetdescinterface.h> |
|
47 |
|
48 #endif // __SERIES60_PUSH_SP |
|
49 |
|
50 // CONSTANTS |
|
51 |
|
52 |
|
53 // ================= MEMBER FUNCTIONS ======================= |
|
54 |
|
55 // --------------------------------------------------------- |
|
56 // CUnknownContentHandler::NewL |
|
57 // --------------------------------------------------------- |
|
58 // |
|
59 CUnknownContentHandler* CUnknownContentHandler::NewL() |
|
60 { |
|
61 PUSHLOG_ENTERFN("CUnknownContentHandler::NewL") |
|
62 |
|
63 CUnknownContentHandler* self = new (ELeave) CUnknownContentHandler; |
|
64 CleanupStack::PushL( self ); |
|
65 self->ConstructL(); |
|
66 CleanupStack::Pop( self ); |
|
67 |
|
68 PUSHLOG_LEAVEFN("CUnknownContentHandler::NewL") |
|
69 return self; |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------- |
|
73 // CUnknownContentHandler::~CUnknownContentHandler |
|
74 // --------------------------------------------------------- |
|
75 // |
|
76 CUnknownContentHandler::~CUnknownContentHandler() |
|
77 { |
|
78 PUSHLOG_ENTERFN("CUnknownContentHandler::~CUnknownContentHandler") |
|
79 |
|
80 Cancel(); |
|
81 |
|
82 PUSHLOG_LEAVEFN("CUnknownContentHandler::~CUnknownContentHandler") |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------- |
|
86 // CUnknownContentHandler::CUnknownContentHandler |
|
87 // --------------------------------------------------------- |
|
88 // |
|
89 CUnknownContentHandler::CUnknownContentHandler() |
|
90 : CPushContentHandlerBase(), |
|
91 iSavedMsgId( KMsvNullIndexEntryId ) |
|
92 { |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------- |
|
96 // CUnknownContentHandler::ConstructL |
|
97 // --------------------------------------------------------- |
|
98 // |
|
99 void CUnknownContentHandler::ConstructL() |
|
100 { |
|
101 PUSHLOG_ENTERFN("CUnknownContentHandler::ConstructL") |
|
102 |
|
103 CPushContentHandlerBase::ConstructL(); |
|
104 // Added to Active Scheduler. |
|
105 |
|
106 PUSHLOG_LEAVEFN("CUnknownContentHandler::ConstructL") |
|
107 } |
|
108 |
|
109 |
|
110 // --------------------------------------------------------- |
|
111 // CUnknownContentHandler::CollectGarbageL |
|
112 // --------------------------------------------------------- |
|
113 // |
|
114 void CUnknownContentHandler::CollectGarbageL() |
|
115 { |
|
116 PUSHLOG_ENTERFN("CUnknownContentHandler::CollectGarbageL") |
|
117 |
|
118 DoCollectGarbageL(); |
|
119 |
|
120 #ifdef __SERIES60_PUSH_SP |
|
121 iState = EFilteringAndProcessing; |
|
122 #else // __SERIES60_PUSH_SP |
|
123 // Do nothing - message is discarded. |
|
124 iState = EDone; |
|
125 #endif // __SERIES60_PUSH_SP |
|
126 IdleComplete(); |
|
127 |
|
128 PUSHLOG_LEAVEFN("CUnknownContentHandler::CollectGarbageL") |
|
129 } |
|
130 |
|
131 #ifdef __SERIES60_PUSH_SP |
|
132 |
|
133 // --------------------------------------------------------- |
|
134 // CUnknownContentHandler::ProcessingPushMsgEntryL |
|
135 // --------------------------------------------------------- |
|
136 // |
|
137 void CUnknownContentHandler::ProcessingPushMsgEntryL() |
|
138 { |
|
139 PUSHLOG_ENTERFN("CUnknownContentHandler::ProcessingPushMsgEntryL") |
|
140 |
|
141 const TBool bioMsg( BioMessageTypeL() ); |
|
142 if ( bioMsg ) |
|
143 { |
|
144 PUSHLOG_WRITE(" BIO message"); |
|
145 // convert to bio format & save |
|
146 SaveBioMessageEntryL(); |
|
147 } |
|
148 else |
|
149 { |
|
150 PUSHLOG_WRITE(" Not BIO message"); |
|
151 |
|
152 // Check if the received content is supported. |
|
153 RApaLsSession apaLs; |
|
154 User::LeaveIfError( apaLs.Connect() ); |
|
155 CleanupClosePushL<RApaLsSession>( apaLs ); |
|
156 |
|
157 // Try to find out the data type. |
|
158 TPtrC contentTypePtr; |
|
159 iMessage->GetContentType( contentTypePtr ); |
|
160 HBufC8* contentT8 = HBufC8::NewMaxLC( contentTypePtr.Length() ); |
|
161 contentT8->Des().Copy( contentTypePtr ); |
|
162 TDataRecognitionResult result; |
|
163 User::LeaveIfError( apaLs.RecognizeData( KNullDesC(), |
|
164 *contentT8, |
|
165 result ) ); |
|
166 CleanupStack::PopAndDestroy( contentT8 ); // contentT8 |
|
167 |
|
168 CDocumentHandler* docHandler = CDocumentHandler::NewLC( NULL ); |
|
169 TBool supported = docHandler->CanOpenL( result.iDataType ); |
|
170 |
|
171 CleanupStack::PopAndDestroy( 2, &apaLs ); // docHandler, apaLs |
|
172 |
|
173 // Save only supported msg. |
|
174 if ( supported ) |
|
175 { |
|
176 // create unknown push message entry and save |
|
177 SaveUnknownPushMsgEntryL(); |
|
178 } |
|
179 } |
|
180 |
|
181 iState = EDone; |
|
182 IdleComplete(); |
|
183 |
|
184 PUSHLOG_LEAVEFN("CUnknownContentHandler::ProcessingPushMsgEntryL") |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------- |
|
188 // CUnknownContentHandler::BioMessageTypeL |
|
189 // --------------------------------------------------------- |
|
190 // |
|
191 TBool CUnknownContentHandler::BioMessageTypeL() |
|
192 { |
|
193 PUSHLOG_ENTERFN("CUnknownContentHandler::BioMessageTypeL") |
|
194 |
|
195 // need to create local RFs for BIO otherwise raises exception |
|
196 RFs localFS; |
|
197 CleanupClosePushL( localFS ); |
|
198 User::LeaveIfError( localFS.Connect() ); |
|
199 CBIODatabase* bioDB = CBIODatabase::NewLC( localFS ); |
|
200 |
|
201 TPtrC contentTypePtr; |
|
202 iMessage->GetContentType( contentTypePtr ); |
|
203 |
|
204 iBioMsgUID = KNullUid; |
|
205 TBool isBio = EFalse; |
|
206 // IsBioMessageL returns KErrNone if found or KErrNotFound if not found |
|
207 if ( bioDB->IsBioMessageL( EBioMsgIdIana, |
|
208 contentTypePtr, |
|
209 NULL, |
|
210 iBioMsgUID ) == KErrNone ) |
|
211 { |
|
212 isBio = ETrue; |
|
213 } |
|
214 |
|
215 CleanupStack::PopAndDestroy( 2 ); // bioDB, localFS |
|
216 |
|
217 PUSHLOG_LEAVEFN("CUnknownContentHandler::BioMessageTypeL") |
|
218 return isBio; |
|
219 } |
|
220 |
|
221 // --------------------------------------------------------- |
|
222 // CUnknownContentHandler::SaveBioMessageEntryL |
|
223 // --------------------------------------------------------- |
|
224 // |
|
225 void CUnknownContentHandler::SaveBioMessageEntryL() |
|
226 { |
|
227 PUSHLOG_ENTERFN("CUnknownContentHandler::SaveBioMessageEntryL") |
|
228 |
|
229 // create sms message from CPushMessage and then save message |
|
230 RFs fileSession; |
|
231 User::LeaveIfError(fileSession.Connect()); |
|
232 CleanupClosePushL(fileSession); |
|
233 CSmsBuffer* smsBuffer = CSmsBuffer::NewL(); |
|
234 CleanupStack::PushL(smsBuffer); |
|
235 |
|
236 CSmsMessage* smsMessage = CSmsMessage::NewL( fileSession, |
|
237 CSmsPDU::ESmsDeliver, |
|
238 smsBuffer ); |
|
239 CleanupStack::PushL( smsMessage ); |
|
240 |
|
241 smsMessage->SmsPDU().SetAlphabet( TSmsDataCodingScheme::ESmsAlphabet8Bit ); |
|
242 |
|
243 TPtrC8 fieldValue; |
|
244 |
|
245 if ( iMessage->GetBinaryHeaderField( EHttpFrom, fieldValue ) || |
|
246 iMessage->GetBinaryHeaderField( EHttpXWapInitiatorURI, fieldValue ) || |
|
247 iMessage->GetBinaryHeaderField( EHttpContentLocation, fieldValue ) ) |
|
248 { |
|
249 // Convert 8 bit to 16 bit |
|
250 HBufC* tempAddr = HBufC::NewLC( fieldValue.Length() ); |
|
251 tempAddr->Des().Copy( fieldValue ); |
|
252 |
|
253 smsMessage->SmsPDU().SetToFromAddressL( *tempAddr ); |
|
254 CleanupStack::PopAndDestroy( tempAddr ); |
|
255 } |
|
256 |
|
257 if ( iMessage->GetMessageBody( fieldValue ) ) |
|
258 { |
|
259 HBufC* tempBody = HBufC::NewLC( fieldValue.Length() ); |
|
260 tempBody->Des().Copy( fieldValue ); |
|
261 |
|
262 smsBuffer->InsertL( 0, *tempBody ); |
|
263 CleanupStack::PopAndDestroy( tempBody ); |
|
264 } |
|
265 |
|
266 CleanupStack::Pop( 2 ); //smsBuffer, smsMessage |
|
267 |
|
268 StoreMsgL( smsMessage ); // destroys CSmsMessage (contains smsBuffer) |
|
269 CleanupStack::PopAndDestroy( &fileSession ); |
|
270 |
|
271 PUSHLOG_LEAVEFN("CUnknownContentHandler::SaveBioMessageEntryL") |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------- |
|
275 // CUnknownContentHandler::StoreMsgL |
|
276 // --------------------------------------------------------- |
|
277 // |
|
278 void CUnknownContentHandler::StoreMsgL( CSmsMessage* aSmsMsg ) |
|
279 { |
|
280 PUSHLOG_ENTERFN("CUnknownContentHandler::StoreMsgL") |
|
281 |
|
282 CleanupStack::PushL( aSmsMsg ); |
|
283 |
|
284 // Create a CSmsHeader based on this message. smsHdr takes ownership of aSmsMsg |
|
285 CSmsHeader* smsHdr = CSmsHeader::NewL( aSmsMsg ); |
|
286 CleanupStack::Pop( aSmsMsg ); |
|
287 CleanupStack::PushL( smsHdr ); |
|
288 |
|
289 // get root entry |
|
290 CMsvEntry* msvEntry = iMsvSession->GetEntryL( KMsvRootIndexEntryId ); |
|
291 CleanupStack::PushL( msvEntry ); |
|
292 |
|
293 // create an invisible blank entry |
|
294 TMsvEntry entry; |
|
295 entry.iType = KUidMsvMessageEntry; |
|
296 entry.SetVisible( EFalse ); |
|
297 entry.SetInPreparation( ETrue ); |
|
298 entry.SetReadOnly( EFalse ); |
|
299 entry.SetUnread( ETrue ); |
|
300 |
|
301 TMsvId serviceId = SetBioServiceIdL(); |
|
302 TBuf<KSmsDescriptionLength> description; |
|
303 |
|
304 // SMUT Unbranch |
|
305 CSmsGetDetDescInterface* smsPlugin = CSmsGetDetDescInterface::NewL(); |
|
306 CleanupStack::PushL( smsPlugin ); |
|
307 |
|
308 if ( iBioMsgUID != KNullUid ) |
|
309 { |
|
310 // sets entry with values passed in |
|
311 TSmsUtilities::PopulateMsgEntry( entry, |
|
312 *aSmsMsg, |
|
313 serviceId, |
|
314 KUidBIOMessageTypeMtm ); |
|
315 entry.iBioType = iBioMsgUID.iUid; |
|
316 |
|
317 // Look up and set the description |
|
318 TInt index; |
|
319 CBIODatabase* bioDB = CBIODatabase::NewLC( msvEntry->Session().FileSession() ); |
|
320 bioDB->GetBioIndexWithMsgIDL( iBioMsgUID, index ); |
|
321 description.Copy( bioDB->BifReader(index).Description() ); |
|
322 entry.iDescription.Set( description ); |
|
323 CleanupStack::PopAndDestroy(); // bioDB |
|
324 } |
|
325 else |
|
326 { |
|
327 // sets entry with values passed in |
|
328 TSmsUtilities::PopulateMsgEntry( entry, *aSmsMsg, serviceId ); |
|
329 |
|
330 // Look up and set the description |
|
331 // SMUT Unbranch |
|
332 smsPlugin->GetDescription( *aSmsMsg, description ); |
|
333 entry.iDescription.Set( description ); |
|
334 } |
|
335 |
|
336 // Set the details |
|
337 TBuf<KSmsDetailsLength> details; |
|
338 TInt err = smsPlugin->GetDetails( msvEntry->Session().FileSession(), |
|
339 *aSmsMsg, |
|
340 details ); |
|
341 if ( !err ) |
|
342 { |
|
343 entry.iDetails.Set( details ); |
|
344 } |
|
345 |
|
346 // SMUT Unbranch |
|
347 CleanupStack::PopAndDestroy( smsPlugin ); |
|
348 |
|
349 // Store entry in inbox |
|
350 msvEntry->SetEntryL( KMsvGlobalInBoxIndexEntryId ); |
|
351 msvEntry->CreateL( entry ); |
|
352 msvEntry->Session().CleanupEntryPushL( entry.Id() ); |
|
353 msvEntry->SetEntryL( entry.Id() ); |
|
354 |
|
355 // Save the message |
|
356 CMsvStore* store = msvEntry->EditStoreL(); |
|
357 CleanupStack::PushL( store ); |
|
358 |
|
359 // Save off the CSmsHdr |
|
360 smsHdr->StoreL( *store ); |
|
361 |
|
362 // Save the body |
|
363 |
|
364 // Create and fill a CRichText object to save to store.. |
|
365 CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(); |
|
366 CleanupStack::PushL( paraFormatLayer ); |
|
367 CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(); |
|
368 CleanupStack::PushL( charFormatLayer ); |
|
369 CRichText* richText = CRichText::NewL( paraFormatLayer, charFormatLayer ); |
|
370 CleanupStack::PushL( richText ); |
|
371 HBufC* bufBody=HBufC::NewLC( aSmsMsg->Buffer().Length() ); |
|
372 TPtr bufBodyPtr = bufBody->Des(); |
|
373 aSmsMsg->Buffer().Extract( bufBodyPtr, 0, aSmsMsg->Buffer().Length() ); |
|
374 richText->InsertL( 0, bufBodyPtr ); |
|
375 store->StoreBodyTextL( *richText ); |
|
376 CleanupStack::PopAndDestroy( 4 ); //bufBody, richText, charFormatLayer, paraFormatLayer |
|
377 |
|
378 store->CommitL(); |
|
379 entry.SetReadOnly( ETrue ); |
|
380 entry.SetVisible( ETrue ); |
|
381 entry.SetInPreparation( EFalse ); |
|
382 msvEntry->ChangeL( entry ); |
|
383 |
|
384 CleanupStack::PopAndDestroy(); //store |
|
385 msvEntry->Session().CleanupEntryPop(); //entry |
|
386 CleanupStack::PopAndDestroy( 2 ); //msvEntry, smsHdr |
|
387 |
|
388 PUSHLOG_LEAVEFN("CUnknownContentHandler::StoreMsgL") |
|
389 } |
|
390 |
|
391 // --------------------------------------------------------- |
|
392 // CUnknownContentHandler::SetBioServiceIdL |
|
393 // --------------------------------------------------------- |
|
394 // |
|
395 TMsvId CUnknownContentHandler::SetBioServiceIdL() |
|
396 { |
|
397 PUSHLOG_ENTERFN("CUnknownContentHandler::SetBioServiceIdL") |
|
398 |
|
399 CMsvEntry* msvEntry = iMsvSession->GetEntryL( KMsvRootIndexEntryId ); |
|
400 |
|
401 CleanupStack::PushL( msvEntry ); |
|
402 |
|
403 TMsvId serviceId = KMsvNullIndexEntryId; |
|
404 TRAPD( err, TSmsUtilities::ServiceIdL( *msvEntry, |
|
405 serviceId, |
|
406 KUidBIOMessageTypeMtm ) ); |
|
407 if ( err == KErrNotFound ) |
|
408 { |
|
409 serviceId = KMsvLocalServiceIndexEntryId; |
|
410 err = KErrNone; |
|
411 } |
|
412 |
|
413 CleanupStack::PopAndDestroy(); //msvEntry |
|
414 User::LeaveIfError( err ); |
|
415 |
|
416 PUSHLOG_LEAVEFN("CUnknownContentHandler::SetBioServiceIdL") |
|
417 return serviceId; |
|
418 } |
|
419 |
|
420 // --------------------------------------------------------- |
|
421 // CUnknownContentHandler::SaveUnknownPushMsgEntryL |
|
422 // --------------------------------------------------------- |
|
423 // |
|
424 void CUnknownContentHandler::SaveUnknownPushMsgEntryL() |
|
425 { |
|
426 PUSHLOG_ENTERFN("CUnknownContentHandler::SaveUnknownPushMsgEntryL") |
|
427 |
|
428 CUnknownPushMsgEntry* unknownPushMsgEntry = |
|
429 CUnknownPushMsgEntry::NewL(); |
|
430 CleanupStack::PushL( unknownPushMsgEntry ); |
|
431 |
|
432 SetUnknownPushMsgEntryFieldsL( *unknownPushMsgEntry ); |
|
433 |
|
434 iSavedMsgId = unknownPushMsgEntry->SaveL( *iMsvSession, |
|
435 KMsvGlobalInBoxIndexEntryId ); |
|
436 |
|
437 CleanupStack::PopAndDestroy( unknownPushMsgEntry ); // unknownPushMsgEntry |
|
438 |
|
439 PUSHLOG_LEAVEFN("CUnknownContentHandler::SaveUnknownPushMsgEntryL") |
|
440 } |
|
441 |
|
442 // --------------------------------------------------------- |
|
443 // CUnknownContentHandler::SetUnknownPushMsgEntryFieldsL |
|
444 // --------------------------------------------------------- |
|
445 // |
|
446 void CUnknownContentHandler::SetUnknownPushMsgEntryFieldsL |
|
447 ( CUnknownPushMsgEntry& aUnknownPushMsgEntry ) |
|
448 { |
|
449 PUSHLOG_ENTERFN("CUnknownContentHandler::SetUnknownPushMsgEntryFieldsL") |
|
450 |
|
451 // Set all the relevant fields |
|
452 |
|
453 // Get server address. |
|
454 TPtrC8 srvAddress; |
|
455 if ( iMessage->GetServerAddress( srvAddress ) ) |
|
456 { |
|
457 aUnknownPushMsgEntry.SetFromL( srvAddress ); |
|
458 } |
|
459 |
|
460 TPtrC contentTypePtr; |
|
461 iMessage->GetContentType( contentTypePtr ); |
|
462 aUnknownPushMsgEntry.SetContentTypeL( contentTypePtr ); |
|
463 |
|
464 TPtrC8 msgBodyPtr; |
|
465 iMessage->GetMessageBody( msgBodyPtr ); |
|
466 aUnknownPushMsgEntry.SetMessageDataL( msgBodyPtr ); |
|
467 |
|
468 // First line in Inbox: TMsvEntry::iDetails. |
|
469 if ( srvAddress.Length() == 0 ) |
|
470 { |
|
471 // Read from resource. |
|
472 HBufC* details = |
|
473 iStrRscReader->AllocReadResourceLC( R_PUSHMISC_UNK_SENDER ); |
|
474 aUnknownPushMsgEntry.SetMsgDetailsL( *details ); |
|
475 CleanupStack::PopAndDestroy( details ); |
|
476 } |
|
477 else |
|
478 { |
|
479 // Convert the "From" information to the format required by the UI |
|
480 // spec and then decode it. |
|
481 HBufC* details = iWapPushUtils->ConvertDetailsL( srvAddress ); |
|
482 CleanupStack::PushL( details ); |
|
483 HBufC* convertedFrom = |
|
484 CPushMtmUtil::ConvertUriToDisplayFormL( *details ); |
|
485 CleanupStack::PushL( convertedFrom ); |
|
486 // |
|
487 aUnknownPushMsgEntry.SetMsgDetailsL( *convertedFrom ); |
|
488 // |
|
489 CleanupStack::PopAndDestroy( 2, details ); // convertedFrom, details |
|
490 } |
|
491 |
|
492 // Second line in Inbox: TMsvEntry::iDescription. |
|
493 TPtrC8 contentUriPtr; |
|
494 iMessage->GetBinaryHeaderField( EHttpXWapContentURI, contentUriPtr ); |
|
495 // Copy the 8-bit descriptor into a unicode one. |
|
496 HBufC* contentUri = HBufC::NewMaxLC( contentUriPtr.Length() ); |
|
497 contentUri->Des().Copy( contentUriPtr ); |
|
498 // Extract file name from X-wap-content-uri. |
|
499 HBufC* fileName = FileNameFromUriL( *contentUri ); |
|
500 CleanupStack::PopAndDestroy( contentUri ); // contentUri |
|
501 CleanupStack::PushL( fileName ); |
|
502 |
|
503 if ( fileName->Length() == 0 ) |
|
504 { |
|
505 // TODO: Read from resource. |
|
506 //"Unknown content type" qtn_wap_push_msg_content_not_supported |
|
507 } |
|
508 else |
|
509 { |
|
510 aUnknownPushMsgEntry.SetMsgDescriptionL( *fileName ); |
|
511 } |
|
512 |
|
513 CleanupStack::PopAndDestroy( fileName ); // fileName |
|
514 |
|
515 PUSHLOG_LEAVEFN("CUnknownContentHandler::SetUnknownPushMsgEntryFieldsL") |
|
516 } |
|
517 |
|
518 // --------------------------------------------------------- |
|
519 // CUnknownContentHandler::FileNameFromUriL |
|
520 // --------------------------------------------------------- |
|
521 // |
|
522 HBufC* CUnknownContentHandler::FileNameFromUriL( const TDesC& aUri ) const |
|
523 { |
|
524 TUriParser pars; |
|
525 User::LeaveIfError( pars.Parse( aUri ) ); |
|
526 |
|
527 HBufC* res = NULL; |
|
528 if ( pars.IsPresent( EUriPath ) ) |
|
529 { |
|
530 TPtrC path = pars.Extract( EUriPath ); |
|
531 // Extract the remaining text after the last slash character. |
|
532 // If the path contains a file name, then it has to contain |
|
533 // a slash also, so if there is no slash then it's sure that there |
|
534 // is no file name in it. |
|
535 TInt index = path.LocateReverse( TChar('/') ); |
|
536 if ( index < 0 ) |
|
537 { |
|
538 // No file name. |
|
539 } |
|
540 else if ( ++index < path.Length() ) // If not at the end... |
|
541 { |
|
542 // Last slash found. Extract the text after the slash. |
|
543 res = path.Mid( index ).AllocL(); |
|
544 } |
|
545 } |
|
546 |
|
547 if ( !res ) |
|
548 { |
|
549 res = KNullDesC().AllocL(); |
|
550 } |
|
551 |
|
552 return res; |
|
553 } |
|
554 |
|
555 #endif // __SERIES60_PUSH_SP |
|
556 |
|
557 |
|
558 // --------------------------------------------------------- |
|
559 // CUnknownContentHandler::HandleMessageL |
|
560 // --------------------------------------------------------- |
|
561 // |
|
562 void CUnknownContentHandler::HandleMessageL( CPushMessage* aPushMsg, |
|
563 TRequestStatus& aStatus ) |
|
564 { |
|
565 PUSHLOG_ENTERFN("CUnknownContentHandler::HandleMessageL") |
|
566 |
|
567 __ASSERT_DEBUG( aPushMsg != NULL, |
|
568 ContHandPanic( EPushContHandPanMsgNull ) ); |
|
569 |
|
570 iMessage = aPushMsg; |
|
571 iAcknowledge = ETrue; |
|
572 SetConfirmationStatus( aStatus ); |
|
573 iState = EGarbageCollecting; |
|
574 IdleComplete(); |
|
575 } |
|
576 |
|
577 // --------------------------------------------------------- |
|
578 // CUnknownContentHandler::HandleMessageL |
|
579 // --------------------------------------------------------- |
|
580 // |
|
581 void CUnknownContentHandler::HandleMessageL( CPushMessage* aPushMsg ) |
|
582 { |
|
583 PUSHLOG_ENTERFN("CUnknownContentHandler::HandleMessageL") |
|
584 |
|
585 __ASSERT_DEBUG( aPushMsg != NULL, |
|
586 ContHandPanic( EPushContHandPanMsgNull ) ); |
|
587 |
|
588 iAcknowledge = EFalse; |
|
589 iMessage = aPushMsg; |
|
590 iState = EGarbageCollecting; |
|
591 IdleComplete(); |
|
592 |
|
593 PUSHLOG_LEAVEFN("CUnknownContentHandler::HandleMessageL") |
|
594 } |
|
595 |
|
596 // --------------------------------------------------------- |
|
597 // CUnknownContentHandler::CancelHandleMessage |
|
598 // --------------------------------------------------------- |
|
599 // |
|
600 void CUnknownContentHandler::CancelHandleMessage() |
|
601 { |
|
602 PUSHLOG_ENTERFN("CUnknownContentHandler::CancelHandleMessage") |
|
603 Cancel(); |
|
604 PUSHLOG_LEAVEFN("CUnknownContentHandler::CancelHandleMessage") |
|
605 } |
|
606 |
|
607 // --------------------------------------------------------- |
|
608 // CUnknownContentHandler::CPushHandlerBase_Reserved1 |
|
609 // --------------------------------------------------------- |
|
610 // |
|
611 void CUnknownContentHandler::CPushHandlerBase_Reserved1() |
|
612 { |
|
613 } |
|
614 |
|
615 // --------------------------------------------------------- |
|
616 // CUnknownContentHandler::CPushHandlerBase_Reserved2 |
|
617 // --------------------------------------------------------- |
|
618 // |
|
619 void CUnknownContentHandler::CPushHandlerBase_Reserved2() |
|
620 { |
|
621 } |
|
622 |
|
623 // --------------------------------------------------------- |
|
624 // CUnknownContentHandler::DoCancel |
|
625 // --------------------------------------------------------- |
|
626 // |
|
627 void CUnknownContentHandler::DoCancel() |
|
628 { |
|
629 PUSHLOG_ENTERFN("CUnknownContentHandler::DoCancel") |
|
630 Complete( KErrCancel ); |
|
631 PUSHLOG_LEAVEFN("CUnknownContentHandler::DoCancel") |
|
632 } |
|
633 |
|
634 // --------------------------------------------------------- |
|
635 // CUnknownContentHandler::RunL |
|
636 // --------------------------------------------------------- |
|
637 // |
|
638 void CUnknownContentHandler::RunL() |
|
639 { |
|
640 // Handle errors in RunError(). |
|
641 PUSHLOG_WRITE_FORMAT("iStatus.Int(): %d",iStatus.Int()) |
|
642 User::LeaveIfError( iStatus.Int() ); |
|
643 |
|
644 // use active state machine routine to manage activites: |
|
645 switch ( iState ) |
|
646 { |
|
647 case EGarbageCollecting: |
|
648 { |
|
649 CollectGarbageL(); |
|
650 break; |
|
651 } |
|
652 |
|
653 #ifdef __SERIES60_PUSH_SP |
|
654 |
|
655 case EFilteringAndProcessing: |
|
656 { |
|
657 if ( !FilterPushMsgL() ) |
|
658 { |
|
659 // It did not pass the filter. Done. |
|
660 iState = EDone; |
|
661 IdleComplete(); |
|
662 } |
|
663 else |
|
664 { |
|
665 // Continue. |
|
666 ProcessingPushMsgEntryL(); |
|
667 } |
|
668 break; |
|
669 } |
|
670 |
|
671 #endif // __SERIES60_PUSH_SP |
|
672 |
|
673 default: |
|
674 { |
|
675 PUSHLOG_WRITE("CUnknownContentHandler default EDone") |
|
676 Complete( KErrNone ); |
|
677 break; |
|
678 } |
|
679 } |
|
680 } |
|
681 |
|
682 // --------------------------------------------------------- |
|
683 // CUnknownContentHandler::RunError |
|
684 // --------------------------------------------------------- |
|
685 // |
|
686 TInt CUnknownContentHandler::RunError( TInt aError ) |
|
687 { |
|
688 PUSHLOG_WRITE_FORMAT("CUnknownContentHandler::RunError: %d",aError) |
|
689 |
|
690 iState = EDone; |
|
691 Complete( aError ); |
|
692 return KErrNone; |
|
693 } |
|
694 |
|