26 #include "PushMtmUiDef.h" |
26 #include "PushMtmUiDef.h" |
27 #include "StringResourceReader.h" |
27 #include "StringResourceReader.h" |
28 #include "PushContentHandlerPanic.h" |
28 #include "PushContentHandlerPanic.h" |
29 #include "si_dict.h" |
29 #include "si_dict.h" |
30 #include "PushContentHandlerUtils.h" |
30 #include "PushContentHandlerUtils.h" |
31 #include <CSIPushMsgEntry.h> |
31 #include <push/CSIPushMsgEntry.h> |
32 #include <msvids.h> |
32 #include <msvids.h> |
33 #include <PushMtmUi.rsg> |
33 #include <PushMtmUi.rsg> |
34 #include <nw_dom_node.h> |
34 #include <nw_dom_node.h> |
35 #include <nw_dom_document.h> |
35 #include <nw_dom_document.h> |
36 #include <nw_dom_element.h> |
36 #include <nw_dom_element.h> |
128 // --------------------------------------------------------- |
128 // --------------------------------------------------------- |
129 // CSIContentHandler::CSIContentHandler |
129 // CSIContentHandler::CSIContentHandler |
130 // --------------------------------------------------------- |
130 // --------------------------------------------------------- |
131 // |
131 // |
132 CSIContentHandler::CSIContentHandler() |
132 CSIContentHandler::CSIContentHandler() |
133 : CPushContentHandlerBase(), |
133 : CPushContentHandlerBase(), |
134 iSavedMsgId( KMsvNullIndexEntryId ), |
134 iSavedMsgId( KMsvNullIndexEntryId ), |
135 iPushMsgAction( KErrNotFound ), |
135 iPushMsgAction( KErrNotFound ), |
136 iExpiresTime( Time::NullTTime() ), |
136 iExpiresTime( Time::NullTTime() ), |
137 iCreatedTime( Time::NullTTime() ) |
137 iCreatedTime( Time::NullTTime() ) |
138 { |
138 { |
139 } |
139 } |
140 |
140 |
141 // --------------------------------------------------------- |
141 // --------------------------------------------------------- |
203 PUSHLOG_WRITE_FORMAT(" HTTP header - Content encoding <%S>",&encodingBuf); |
203 PUSHLOG_WRITE_FORMAT(" HTTP header - Content encoding <%S>",&encodingBuf); |
204 #endif // __TEST_LOG__ |
204 #endif // __TEST_LOG__ |
205 */ |
205 */ |
206 |
206 |
207 // Add SI dictionary. |
207 // Add SI dictionary. |
208 NW_WBXML_Dictionary_t* dictArray[ KNoOfDictArrays ] = |
208 NW_WBXML_Dictionary_t* dictArray[ KNoOfDictArrays ] = |
209 { (NW_WBXML_Dictionary_t*)&NW_SI_WBXMLDictionary }; |
209 { (NW_WBXML_Dictionary_t*)&NW_SI_WBXMLDictionary }; |
210 |
210 |
211 NW_Status_t stat = NW_STAT_SUCCESS; |
211 NW_Status_t stat = NW_STAT_SUCCESS; |
212 |
212 |
213 RWbxmlDictionary wbxmlDict; |
213 RWbxmlDictionary wbxmlDict; |
216 |
216 |
217 NW_TinyDom_Handle_t domHandle; |
217 NW_TinyDom_Handle_t domHandle; |
218 NW_Byte* buffer = (NW_Byte*)bodyPtr.Ptr(); |
218 NW_Byte* buffer = (NW_Byte*)bodyPtr.Ptr(); |
219 NW_Int32 length = (NW_Int32)bodyPtr.Size(); |
219 NW_Int32 length = (NW_Int32)bodyPtr.Size(); |
220 // Let's use the content type now. |
220 // Let's use the content type now. |
221 NW_Bool encoded = ( contentType.CompareF( KSiTextContentType ) == 0 ) ? |
221 NW_Bool encoded = ( contentType.CompareF( KSiTextContentType ) == 0 ) ? |
222 NW_FALSE : NW_TRUE; |
222 NW_FALSE : NW_TRUE; |
223 // SI public identifier. |
223 // SI public identifier. |
224 NW_Uint32 publicID = NW_SI_PublicId; |
224 NW_Uint32 publicID = NW_SI_PublicId; |
225 NW_Bool extTNotStringTable = NW_FALSE; |
225 NW_Bool extTNotStringTable = NW_FALSE; |
226 NW_DOM_NodeType_t type = 0; |
226 NW_DOM_NodeType_t type = 0; |
272 PUSHLOG_WRITE("CSIContentHandler::ParsePushMsgL: No SI element present in the dom tree. Message corrupted.") |
272 PUSHLOG_WRITE("CSIContentHandler::ParsePushMsgL: No SI element present in the dom tree. Message corrupted.") |
273 User::Leave( KErrCorrupt ); |
273 User::Leave( KErrCorrupt ); |
274 } |
274 } |
275 |
275 |
276 PUSHLOG_WRITE("CSIContentHandler::ParsePushMsgL: before calling getDocumentElement") |
276 PUSHLOG_WRITE("CSIContentHandler::ParsePushMsgL: before calling getDocumentElement") |
277 NW_DOM_ElementNode_t* siElement = |
277 NW_DOM_ElementNode_t* siElement = |
278 NW_DOM_DocumentNode_getDocumentElement( domNode ); |
278 NW_DOM_DocumentNode_getDocumentElement( domNode ); |
279 PUSHLOG_WRITE("CSIContentHandler::ParsePushMsgL: after calling getDocumentElement") |
279 PUSHLOG_WRITE("CSIContentHandler::ParsePushMsgL: after calling getDocumentElement") |
280 if (!siElement) |
280 if (!siElement) |
281 { |
281 { |
282 PUSHLOG_WRITE("CSIContentHandler::ParsePushMsgL: siElement is Null") |
282 PUSHLOG_WRITE("CSIContentHandler::ParsePushMsgL: siElement is Null") |
334 stringOwner->SetString( name ); |
334 stringOwner->SetString( name ); |
335 stat = NW_DOM_Node_getNodeName( node, name ); |
335 stat = NW_DOM_Node_getNodeName( node, name ); |
336 PUSHLOG_WRITE_FORMAT("CSIContentHandler::ParsePushMsgL: getNodeName ErrCode: %d", NwxStatusToErrCode( stat )) |
336 PUSHLOG_WRITE_FORMAT("CSIContentHandler::ParsePushMsgL: getNodeName ErrCode: %d", NwxStatusToErrCode( stat )) |
337 User::LeaveIfError( NwxStatusToErrCode( stat ) ); |
337 User::LeaveIfError( NwxStatusToErrCode( stat ) ); |
338 NW_Byte* nameBuf = NW_String_getStorage( name ); |
338 NW_Byte* nameBuf = NW_String_getStorage( name ); |
339 NW_Uint16 nameLen = NW_String_getCharCount( name, |
339 NW_Uint16 nameLen = NW_String_getCharCount( name, |
340 iCharEncoding ); |
340 iCharEncoding ); |
341 TPtrC8 namePtr( nameBuf, nameLen ); |
341 TPtrC8 namePtr( nameBuf, nameLen ); |
342 |
342 |
343 if ( type == NW_DOM_ELEMENT_NODE && |
343 if ( type == NW_DOM_ELEMENT_NODE && |
344 namePtr.CompareF( KIndication ) == 0 ) |
344 namePtr.CompareF( KIndication ) == 0 ) |
345 { |
345 { |
346 // We found the indication element. Parse it. |
346 // We found the indication element. Parse it. |
347 PUSHLOG_WRITE("CSIContentHandler::ParsePushMsgL: indication under si found.") |
347 PUSHLOG_WRITE("CSIContentHandler::ParsePushMsgL: indication under si found.") |
348 indicationFound = ETrue; |
348 indicationFound = ETrue; |
349 NW_DOM_ElementNode_t* indicationElement = |
349 NW_DOM_ElementNode_t* indicationElement = |
350 REINTERPRET_CAST( NW_DOM_ElementNode_t*, node ); |
350 REINTERPRET_CAST( NW_DOM_ElementNode_t*, node ); |
351 ParseIndicationL( *indicationElement ); |
351 ParseIndicationL( *indicationElement ); |
352 } |
352 } |
353 |
353 |
354 CleanupStack::PopAndDestroy( stringOwner ); // stringOwner |
354 CleanupStack::PopAndDestroy( stringOwner ); // stringOwner |
414 /********************************** |
414 /********************************** |
415 * PCDATA of ELEMENT indication |
415 * PCDATA of ELEMENT indication |
416 ***********************************/ |
416 ***********************************/ |
417 if ( NW_DOM_Node_hasChildNodes( &aIndication ) ) |
417 if ( NW_DOM_Node_hasChildNodes( &aIndication ) ) |
418 { |
418 { |
419 NW_DOM_TextNode_t* textNode = |
419 NW_DOM_TextNode_t* textNode = |
420 NW_DOM_Node_getFirstChild( &aIndication ); |
420 NW_DOM_Node_getFirstChild( &aIndication ); |
421 User::LeaveIfNull( textNode ); |
421 User::LeaveIfNull( textNode ); |
422 |
422 |
423 type = NW_DOM_Node_getNodeType( textNode ); |
423 type = NW_DOM_Node_getNodeType( textNode ); |
424 if ( type != NW_DOM_TEXT_NODE ) |
424 if ( type != NW_DOM_TEXT_NODE ) |
435 |
435 |
436 // --------------------------------------------------------- |
436 // --------------------------------------------------------- |
437 // CSIContentHandler::ParseIndAttributeL |
437 // CSIContentHandler::ParseIndAttributeL |
438 // --------------------------------------------------------- |
438 // --------------------------------------------------------- |
439 // |
439 // |
440 void CSIContentHandler::ParseIndAttributeL( NW_DOM_AttributeHandle_t& |
440 void CSIContentHandler::ParseIndAttributeL( NW_DOM_AttributeHandle_t& |
441 aAttrHandle ) |
441 aAttrHandle ) |
442 { |
442 { |
443 PUSHLOG_ENTERFN("CSIContentHandler::ParseIndAttributeL") |
443 PUSHLOG_ENTERFN("CSIContentHandler::ParseIndAttributeL") |
444 |
444 |
445 NW_Status_t stat = NW_STAT_SUCCESS; |
445 NW_Status_t stat = NW_STAT_SUCCESS; |
490 stat = NW_DOM_AttributeHandle_getValue( &aAttrHandle, val ); |
490 stat = NW_DOM_AttributeHandle_getValue( &aAttrHandle, val ); |
491 if ( stat != NW_STAT_DOM_NO_STRING_RETURNED ) |
491 if ( stat != NW_STAT_DOM_NO_STRING_RETURNED ) |
492 { |
492 { |
493 User::LeaveIfError( NwxStatusToErrCode( stat ) ); |
493 User::LeaveIfError( NwxStatusToErrCode( stat ) ); |
494 NW_Byte* storage = NW_String_getStorage( val ); |
494 NW_Byte* storage = NW_String_getStorage( val ); |
495 NW_Uint16 length = NW_String_getCharCount( val, |
495 NW_Uint16 length = NW_String_getCharCount( val, |
496 iCharEncoding ); |
496 iCharEncoding ); |
497 if ( length == 0 ) |
497 if ( length == 0 ) |
498 { |
498 { |
499 // Zero length href attribute is considered as missing. |
499 // Zero length href attribute is considered as missing. |
500 PUSHLOG_WRITE(" Zero length HrefFlag"); |
500 PUSHLOG_WRITE(" Zero length HrefFlag"); |
572 CleanupStack::PushL( stringOwner ); |
572 CleanupStack::PushL( stringOwner ); |
573 |
573 |
574 NW_String_t* val = NW_String_new(); |
574 NW_String_t* val = NW_String_new(); |
575 User::LeaveIfNull( val ); |
575 User::LeaveIfNull( val ); |
576 stringOwner->SetString( val ); |
576 stringOwner->SetString( val ); |
577 stat = NW_DOM_AttributeHandle_getValue( &aAttrHandle, val ); |
577 stat = NW_DOM_AttributeHandle_getValue( &aAttrHandle, val ); |
578 User::LeaveIfError( NwxStatusToErrCode( stat ) ); |
578 User::LeaveIfError( NwxStatusToErrCode( stat ) ); |
579 NW_Byte* storage = NW_String_getStorage( val ); |
579 NW_Byte* storage = NW_String_getStorage( val ); |
580 NW_Uint16 length = NW_String_getCharCount( val, iCharEncoding ); |
580 NW_Uint16 length = NW_String_getCharCount( val, iCharEncoding ); |
581 TPtrC8 actionPtr( storage, length ); |
581 TPtrC8 actionPtr( storage, length ); |
582 |
582 |
705 ucs2buffer = HBufC::NewLC( ptr.Length() ); |
705 ucs2buffer = HBufC::NewLC( ptr.Length() ); |
706 resultOnStack = ETrue; |
706 resultOnStack = ETrue; |
707 } |
707 } |
708 else |
708 else |
709 { |
709 { |
710 __ASSERT_DEBUG( resultOnStack, |
710 __ASSERT_DEBUG( resultOnStack, |
711 ContHandPanic( EPushContHandPanSiResNotOnStack ) ); |
711 ContHandPanic( EPushContHandPanSiResNotOnStack ) ); |
712 // This may change the address of ucs2buffer so we need to put |
712 // This may change the address of ucs2buffer so we need to put |
713 // it on the cleanup stack again!! |
713 // it on the cleanup stack again!! |
714 ucs2buffer = ucs2buffer->ReAllocL |
714 ucs2buffer = ucs2buffer->ReAllocL |
715 ( ucs2buffer->Length() + ptr.Length() ); |
715 ( ucs2buffer->Length() + ptr.Length() ); |
829 |
829 |
830 // Source |
830 // Source |
831 PUSHLOG_WRITE_FORMAT(" Storage: 0x%x",NW_String_getStorage(&aString)); |
831 PUSHLOG_WRITE_FORMAT(" Storage: 0x%x",NW_String_getStorage(&aString)); |
832 PUSHLOG_WRITE_FORMAT(" Byte count: %d",NW_String_getByteCount(&aString)-1); |
832 PUSHLOG_WRITE_FORMAT(" Byte count: %d",NW_String_getByteCount(&aString)-1); |
833 |
833 |
834 // We will use NW_String_getByteCount(&aString)-1 as size, because |
834 // We will use NW_String_getByteCount(&aString)-1 as size, because |
835 // NW_String_getByteCount(&aString) includes NULL terminator. |
835 // NW_String_getByteCount(&aString) includes NULL terminator. |
836 const TPtrC8 src( NW_String_getStorage(&aString), |
836 const TPtrC8 src( NW_String_getStorage(&aString), |
837 NW_String_getByteCount(&aString)-1 ); |
837 NW_String_getByteCount(&aString)-1 ); |
838 HBufC16* ucs2buffer = ConvertToUnicodeL( src, id ); |
838 HBufC16* ucs2buffer = ConvertToUnicodeL( src, id ); |
839 |
839 |
840 PUSHLOG_LEAVEFN("CSIContentHandler::ConvertToUnicodeL"); |
840 PUSHLOG_LEAVEFN("CSIContentHandler::ConvertToUnicodeL"); |
841 return ucs2buffer; |
841 return ucs2buffer; |
850 PUSHLOG_ENTERFN("CSIContentHandler::InitialiseCharacterSetConverterL") |
850 PUSHLOG_ENTERFN("CSIContentHandler::InitialiseCharacterSetConverterL") |
851 |
851 |
852 iCharacterSetConverter = CCnvCharacterSetConverter::NewL(); |
852 iCharacterSetConverter = CCnvCharacterSetConverter::NewL(); |
853 |
853 |
854 RFs& fs = iMsvSession->FileSession(); |
854 RFs& fs = iMsvSession->FileSession(); |
855 iCharacterSetsAvailable = |
855 iCharacterSetsAvailable = |
856 CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableL( fs ); |
856 CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableL( fs ); |
857 |
857 |
858 PUSHLOG_LEAVEFN("CSIContentHandler::InitialiseCharacterSetConverterL") |
858 PUSHLOG_LEAVEFN("CSIContentHandler::InitialiseCharacterSetConverterL") |
859 } |
859 } |
860 |
860 |
896 |
896 |
897 // --------------------------------------------------------- |
897 // --------------------------------------------------------- |
898 // CSIContentHandler::SetSIPushMsgEntryFieldsL |
898 // CSIContentHandler::SetSIPushMsgEntryFieldsL |
899 // --------------------------------------------------------- |
899 // --------------------------------------------------------- |
900 // |
900 // |
901 void CSIContentHandler::SetSIPushMsgEntryFieldsL( CSIPushMsgEntry& |
901 void CSIContentHandler::SetSIPushMsgEntryFieldsL( CSIPushMsgEntry& |
902 aSIPushMsgEntry ) |
902 aSIPushMsgEntry ) |
903 { |
903 { |
904 PUSHLOG_ENTERFN("CSIContentHandler::SetSIPushMsgEntryFieldsL") |
904 PUSHLOG_ENTERFN("CSIContentHandler::SetSIPushMsgEntryFieldsL") |
905 |
905 |
906 if ( SiIdFlag() || HrefFlag() ) |
906 if ( SiIdFlag() || HrefFlag() ) |
958 |
958 |
959 // First line in Inbox: TMsvEntry::iDetails. |
959 // First line in Inbox: TMsvEntry::iDetails. |
960 if ( srvAddress.Length() == 0 ) |
960 if ( srvAddress.Length() == 0 ) |
961 { |
961 { |
962 // Read from resource. |
962 // Read from resource. |
963 HBufC* details = |
963 HBufC* details = |
964 iStrRscReader->AllocReadResourceLC( R_PUSHMISC_UNK_SENDER ); |
964 iStrRscReader->AllocReadResourceLC( R_PUSHMISC_UNK_SENDER ); |
965 aSIPushMsgEntry.SetMsgDetailsL( *details ); |
965 aSIPushMsgEntry.SetMsgDetailsL( *details ); |
966 CleanupStack::PopAndDestroy( details ); |
966 CleanupStack::PopAndDestroy( details ); |
967 } |
967 } |
968 else |
968 else |
969 { |
969 { |
970 // Convert the "From" information to the format required by the UI |
970 // Convert the "From" information to the format required by the UI |
971 // spec and then decode it. |
971 // spec and then decode it. |
972 HBufC* details = iWapPushUtils->ConvertDetailsL( srvAddress ); |
972 HBufC* details = iWapPushUtils->ConvertDetailsL( srvAddress ); |
973 CleanupStack::PushL( details ); |
973 CleanupStack::PushL( details ); |
974 HBufC* convertedFrom = |
974 HBufC* convertedFrom = |
975 CPushMtmUtil::ConvertUriToDisplayFormL( *details ); |
975 CPushMtmUtil::ConvertUriToDisplayFormL( *details ); |
976 CleanupStack::PushL( convertedFrom ); |
976 CleanupStack::PushL( convertedFrom ); |
977 // |
977 // |
978 aSIPushMsgEntry.SetMsgDetailsL( *convertedFrom ); |
978 aSIPushMsgEntry.SetMsgDetailsL( *convertedFrom ); |
979 // |
979 // |
987 aSIPushMsgEntry.SetMsgDescriptionL( *iData ); |
987 aSIPushMsgEntry.SetMsgDescriptionL( *iData ); |
988 } |
988 } |
989 else |
989 else |
990 { |
990 { |
991 // Display URL. |
991 // Display URL. |
992 __ASSERT_DEBUG( HrefFlag(), |
992 __ASSERT_DEBUG( HrefFlag(), |
993 ContHandPanic( EPushContHandPanUnspecSiHref ) ); |
993 ContHandPanic( EPushContHandPanUnspecSiHref ) ); |
994 const TPtrC url = aSIPushMsgEntry.Url(); |
994 const TPtrC url = aSIPushMsgEntry.Url(); |
995 HBufC* convertedUrl = CPushMtmUtil::ConvertUriToDisplayFormL( url ); |
995 HBufC* convertedUrl = CPushMtmUtil::ConvertUriToDisplayFormL( url ); |
996 CleanupStack::PushL( convertedUrl ); |
996 CleanupStack::PushL( convertedUrl ); |
997 // |
997 // |
1001 } |
1001 } |
1002 |
1002 |
1003 // ******** Push MTM specific processing ********* |
1003 // ******** Push MTM specific processing ********* |
1004 |
1004 |
1005 /* |
1005 /* |
1006 * Unfortunately in CPushMsgEntryBase there is no such functionality |
1006 * Unfortunately in CPushMsgEntryBase there is no such functionality |
1007 * with which we can reach TMsvEntry as non-const, but we have to |
1007 * with which we can reach TMsvEntry as non-const, but we have to |
1008 * modify the entry's iMtmData2 member somehow. We can do it |
1008 * modify the entry's iMtmData2 member somehow. We can do it |
1009 * with either casting or with modifying and saving the entry |
1009 * with either casting or with modifying and saving the entry |
1010 * manually after it has been saved by CSIPushMsgEntry. The latter |
1010 * manually after it has been saved by CSIPushMsgEntry. The latter |
1011 * solution is more expensive so we choose the first. |
1011 * solution is more expensive so we choose the first. |
1012 */ |
1012 */ |
1013 TMsvEntry& tEntry = CONST_CAST( TMsvEntry&, aSIPushMsgEntry.Entry() ); |
1013 TMsvEntry& tEntry = CONST_CAST( TMsvEntry&, aSIPushMsgEntry.Entry() ); |
1014 if ( HrefFlag() ) |
1014 if ( HrefFlag() ) |
1015 { |
1015 { |
1036 { |
1036 { |
1037 PUSHLOG_ENTERFN("CSIContentHandler::ProcessingPushMsgEntryL") |
1037 PUSHLOG_ENTERFN("CSIContentHandler::ProcessingPushMsgEntryL") |
1038 |
1038 |
1039 TBool deletePushMsg( EFalse ); |
1039 TBool deletePushMsg( EFalse ); |
1040 |
1040 |
1041 __ASSERT_DEBUG( ActionFlag(), |
1041 __ASSERT_DEBUG( ActionFlag(), |
1042 ContHandPanic( EPushContHandPanUnspecSiAction ) ); |
1042 ContHandPanic( EPushContHandPanUnspecSiAction ) ); |
1043 |
1043 |
1044 // S60 requirement: if both the href and the message is empty then |
1044 // S60 requirement: if both the href and the message is empty then |
1045 // delete the msg. |
1045 // delete the msg. |
1046 if ( HrefFlag() == EFalse && DataFlag() == EFalse ) |
1046 if ( HrefFlag() == EFalse && DataFlag() == EFalse ) |
1047 { |
1047 { |
1048 deletePushMsg = ETrue; |
1048 deletePushMsg = ETrue; |
1049 } |
1049 } |
1148 { |
1148 { |
1149 PUSHLOG_WRITE("Matching SI found"); |
1149 PUSHLOG_WRITE("Matching SI found"); |
1150 //Delete this old entry |
1150 //Delete this old entry |
1151 iWapPushUtils->DeleteEntryL( aMatchingEntryId ); |
1151 iWapPushUtils->DeleteEntryL( aMatchingEntryId ); |
1152 } |
1152 } |
1153 |
1153 |
1154 SetSIPushMsgEntryFieldsL( *siEntry ); |
1154 SetSIPushMsgEntryFieldsL( *siEntry ); |
1155 iSavedMsgId = siEntry->SaveL( *iMsvSession, KMsvGlobalInBoxIndexEntryId ); |
1155 iSavedMsgId = siEntry->SaveL( *iMsvSession, KMsvGlobalInBoxIndexEntryId ); |
1156 |
1156 |
1157 #ifdef __TEST_LOG__ |
1157 #ifdef __TEST_LOG__ |
1158 _LIT( KDateFormat, "%E%D%X%N%Y %1 %2 %3" ); |
1158 _LIT( KDateFormat, "%E%D%X%N%Y %1 %2 %3" ); |
1177 // |
1177 // |
1178 TBool CSIContentHandler::HandleMsgOrderReceptionL( TMsvId& aMatchingEntryId ) |
1178 TBool CSIContentHandler::HandleMsgOrderReceptionL( TMsvId& aMatchingEntryId ) |
1179 { |
1179 { |
1180 PUSHLOG_ENTERFN("CSIContentHandler::HandleMsgOrderReceptionL") |
1180 PUSHLOG_ENTERFN("CSIContentHandler::HandleMsgOrderReceptionL") |
1181 |
1181 |
1182 __ASSERT_DEBUG( ( SiIdFlag() || HrefFlag() ), |
1182 __ASSERT_DEBUG( ( SiIdFlag() || HrefFlag() ), |
1183 ContHandPanic( EPushContHandPanNoSiIdOrHrefAttr ) ); |
1183 ContHandPanic( EPushContHandPanNoSiIdOrHrefAttr ) ); |
1184 __ASSERT_DEBUG( CreatedFlag(), |
1184 __ASSERT_DEBUG( CreatedFlag(), |
1185 ContHandPanic( EPushContHandPanNoCreatedAttr ) ); |
1185 ContHandPanic( EPushContHandPanNoCreatedAttr ) ); |
1186 |
1186 |
1187 CMsvEntrySelection* matchingIdList = NULL; |
1187 CMsvEntrySelection* matchingIdList = NULL; |
1188 TBool discardPushMsg( EFalse ); |
1188 TBool discardPushMsg( EFalse ); |
1189 |
1189 |
1205 if ( 0 < matchingListCount && CreatedFlag() ) |
1205 if ( 0 < matchingListCount && CreatedFlag() ) |
1206 { |
1206 { |
1207 CSIPushMsgEntry* siEntry = CSIPushMsgEntry::NewL(); |
1207 CSIPushMsgEntry* siEntry = CSIPushMsgEntry::NewL(); |
1208 CleanupStack::PushL( siEntry ); |
1208 CleanupStack::PushL( siEntry ); |
1209 |
1209 |
1210 // Delete older stored messages and/or mark current message for |
1210 // Delete older stored messages and/or mark current message for |
1211 // deletion if same date or older than stored messages |
1211 // deletion if same date or older than stored messages |
1212 TBool foundOneToBeReplaced = EFalse; |
1212 TBool foundOneToBeReplaced = EFalse; |
1213 for ( TInt count = 0; count < matchingListCount; ++count ) |
1213 for ( TInt count = 0; count < matchingListCount; ++count ) |
1214 { |
1214 { |
1215 TMsvId matchingSiMsgEntryId( matchingIdList->At(count) ); |
1215 TMsvId matchingSiMsgEntryId( matchingIdList->At(count) ); |
1216 |
1216 |
1217 siEntry->RetrieveL( *iMsvSession, matchingSiMsgEntryId ); |
1217 siEntry->RetrieveL( *iMsvSession, matchingSiMsgEntryId ); |
1218 |
1218 |
1219 // Skip date comparisons if creation date not valid - |
1219 // Skip date comparisons if creation date not valid - |
1220 // SI without created attribute never gets replaced. |
1220 // SI without created attribute never gets replaced. |
1221 TTime existingSiCreatedTime( siEntry->Created() ); |
1221 TTime existingSiCreatedTime( siEntry->Created() ); |
1222 |
1222 |
1223 if ( existingSiCreatedTime == Time::NullTTime() ) |
1223 if ( existingSiCreatedTime == Time::NullTTime() ) |
1224 { |
1224 { |
1225 // continue; |
1225 // continue; |
1226 } |
1226 } |
1227 else |
1227 else |
1228 { |
1228 { |
1229 __ASSERT_DEBUG( !foundOneToBeReplaced, |
1229 __ASSERT_DEBUG( !foundOneToBeReplaced, |
1230 ContHandPanic( EPushContHandPanTooManySi ) ); |
1230 ContHandPanic( EPushContHandPanTooManySi ) ); |
1231 if ( foundOneToBeReplaced ) |
1231 if ( foundOneToBeReplaced ) |
1232 { |
1232 { |
1233 PUSHLOG_WRITE(" Already found one") |
1233 PUSHLOG_WRITE(" Already found one") |
1234 // Only one SI has to be found. |
1234 // Only one SI has to be found. |
1235 // If the program runs into it, then make a |
1235 // If the program runs into it, then make a |
1236 // garbage collection to ensure consistency and |
1236 // garbage collection to ensure consistency and |
1237 // remove other messages found. |
1237 // remove other messages found. |
1238 iWapPushUtils->DeleteEntryL( matchingSiMsgEntryId ); |
1238 iWapPushUtils->DeleteEntryL( matchingSiMsgEntryId ); |
1239 // After the 'for' only one SI is allowed that has created |
1239 // After the 'for' only one SI is allowed that has created |
1240 // attribute. |
1240 // attribute. |
1241 } |
1241 } |
1242 else |
1242 else |
1243 { |
1243 { |
1244 foundOneToBeReplaced = ETrue; // A match was found. |
1244 foundOneToBeReplaced = ETrue; // A match was found. |
1245 // Check if received SI is newer than existing stored Si |
1245 // Check if received SI is newer than existing stored Si |
1246 // (out of order). |
1246 // (out of order). |
1247 if ( iCreatedTime > existingSiCreatedTime ) |
1247 if ( iCreatedTime > existingSiCreatedTime ) |
1248 { |
1248 { |
1249 PUSHLOG_WRITE(" Replacing...") |
1249 PUSHLOG_WRITE(" Replacing...") |
1250 // The new SI replaces the existing. |
1250 // The new SI replaces the existing. |
1251 aMatchingEntryId = matchingSiMsgEntryId; |
1251 aMatchingEntryId = matchingSiMsgEntryId; |
1252 discardPushMsg = EFalse; |
1252 discardPushMsg = EFalse; |
1261 } |
1261 } |
1262 } |
1262 } |
1263 |
1263 |
1264 CleanupStack::PopAndDestroy( siEntry ); // siEntry |
1264 CleanupStack::PopAndDestroy( siEntry ); // siEntry |
1265 } |
1265 } |
1266 |
1266 |
1267 CleanupStack::PopAndDestroy( matchingIdList ); // matchingIdList |
1267 CleanupStack::PopAndDestroy( matchingIdList ); // matchingIdList |
1268 |
1268 |
1269 PUSHLOG_LEAVEFN("CSIContentHandler::HandleMsgOrderReceptionL") |
1269 PUSHLOG_LEAVEFN("CSIContentHandler::HandleMsgOrderReceptionL") |
1270 return discardPushMsg; |
1270 return discardPushMsg; |
1271 } |
1271 } |
1272 |
1272 |
1273 // --------------------------------------------------------- |
1273 // --------------------------------------------------------- |
1274 // CSIContentHandler::ConvertDateTimeL |
1274 // CSIContentHandler::ConvertDateTimeL |
1275 // --------------------------------------------------------- |
1275 // --------------------------------------------------------- |
1276 // |
1276 // |
1277 TBool CSIContentHandler::ConvertDateTimeL( const TDesC& aDateTime, |
1277 TBool CSIContentHandler::ConvertDateTimeL( const TDesC& aDateTime, |
1278 TTime& aConvertedDate ) const |
1278 TTime& aConvertedDate ) const |
1279 { |
1279 { |
1280 PUSHLOG_ENTERFN("CSIContentHandler::ConvertDateTimeL") |
1280 PUSHLOG_ENTERFN("CSIContentHandler::ConvertDateTimeL") |
1281 |
1281 |
1282 TTime convertedTime = Time::NullTTime(); |
1282 TTime convertedTime = Time::NullTTime(); |
1299 User::Leave( KErrCorrupt ); |
1299 User::Leave( KErrCorrupt ); |
1300 } |
1300 } |
1301 else |
1301 else |
1302 { |
1302 { |
1303 // Now 'str' is in format YYYYMMDD:HHMMSS |
1303 // Now 'str' is in format YYYYMMDD:HHMMSS |
1304 // Adjust UTC time to zero offset TTime. Only month and day |
1304 // Adjust UTC time to zero offset TTime. Only month and day |
1305 // is effected. |
1305 // is effected. |
1306 const TInt KFirstMonthChar = KValidTTimeMonthStart; |
1306 const TInt KFirstMonthChar = KValidTTimeMonthStart; |
1307 const TInt KSecondMonthChar = KFirstMonthChar + 1; |
1307 const TInt KSecondMonthChar = KFirstMonthChar + 1; |
1308 const TInt KFirstDayChar = KValidTTimeDayStart; |
1308 const TInt KFirstDayChar = KValidTTimeDayStart; |
1309 const TInt KSecondDayChar = KFirstDayChar + 1; |
1309 const TInt KSecondDayChar = KFirstDayChar + 1; |
1334 // day value is between 1 and 9 so reduce day by one |
1334 // day value is between 1 and 9 so reduce day by one |
1335 // eg 29 becomes 28, 11 bcomes 10, 31 becomes 30 |
1335 // eg 29 becomes 28, 11 bcomes 10, 31 becomes 30 |
1336 str[KSecondDayChar]--; |
1336 str[KSecondDayChar]--; |
1337 } |
1337 } |
1338 |
1338 |
1339 // string is now syntaxically correct, but Set() will return an |
1339 // string is now syntaxically correct, but Set() will return an |
1340 // error if it's semantically incorrect. |
1340 // error if it's semantically incorrect. |
1341 User::LeaveIfError( convertedTime.Set( str ) ); |
1341 User::LeaveIfError( convertedTime.Set( str ) ); |
1342 convertedOK = ETrue; |
1342 convertedOK = ETrue; |
1343 } |
1343 } |
1344 } |
1344 } |
1385 } |
1385 } |
1386 convertedPtr.Append( TChar(KAsciiZeroCharCode + high) ); |
1386 convertedPtr.Append( TChar(KAsciiZeroCharCode + high) ); |
1387 convertedPtr.Append( TChar(KAsciiZeroCharCode + low) ); |
1387 convertedPtr.Append( TChar(KAsciiZeroCharCode + low) ); |
1388 } |
1388 } |
1389 |
1389 |
1390 // A valid UTC %Datetime contains 14 numerical characters and 6 |
1390 // A valid UTC %Datetime contains 14 numerical characters and 6 |
1391 // non-numerical: “1999-04-30T06:40:00Z”. |
1391 // non-numerical: “1999-04-30T06:40:00Z”. |
1392 // So fill the remaining bytes with zeros. |
1392 // So fill the remaining bytes with zeros. |
1393 for ( i = convertedPtr.Length(); i < KValidUTCNumericals; ++i ) |
1393 for ( i = convertedPtr.Length(); i < KValidUTCNumericals; ++i ) |
1394 { |
1394 { |
1395 convertedPtr.Append( TChar('0') ); |
1395 convertedPtr.Append( TChar('0') ); |
1441 } |
1441 } |
1442 else |
1442 else |
1443 { |
1443 { |
1444 // strip out formatting characters |
1444 // strip out formatting characters |
1445 TInt formatCharPos = 4; |
1445 TInt formatCharPos = 4; |
1446 aDateTime.Delete( formatCharPos, 1 ); |
1446 aDateTime.Delete( formatCharPos, 1 ); |
1447 // now move through two characters at a time and remove other chars |
1447 // now move through two characters at a time and remove other chars |
1448 // to just leave digits |
1448 // to just leave digits |
1449 const TInt KRemainingFormatChars = 5; |
1449 const TInt KRemainingFormatChars = 5; |
1450 TInt i( 0 ); |
1450 TInt i( 0 ); |
1451 for ( i = 0; i < KRemainingFormatChars; ++i ) |
1451 for ( i = 0; i < KRemainingFormatChars; ++i ) |
1452 { |
1452 { |
1454 aDateTime.Delete( formatCharPos, 1 ); |
1454 aDateTime.Delete( formatCharPos, 1 ); |
1455 } |
1455 } |
1456 |
1456 |
1457 // Now aDateTime has to be in format YYYYMMDDHHMMSS |
1457 // Now aDateTime has to be in format YYYYMMDDHHMMSS |
1458 |
1458 |
1459 __ASSERT_DEBUG( aDateTime.Length() == KValidTTimeLength, |
1459 __ASSERT_DEBUG( aDateTime.Length() == KValidTTimeLength, |
1460 ContHandPanic( EPushContHandPanBadTTimeLength ) ); |
1460 ContHandPanic( EPushContHandPanBadTTimeLength ) ); |
1461 |
1461 |
1462 // now have UTC string stripped of format characters - check remaining |
1462 // now have UTC string stripped of format characters - check remaining |
1463 // characters are all digits - YYYYMMDDHHMMSS |
1463 // characters are all digits - YYYYMMDDHHMMSS |
1464 TChar ch; |
1464 TChar ch; |
1465 for ( i = 0; i < KValidTTimeLength; ++i ) |
1465 for ( i = 0; i < KValidTTimeLength; ++i ) |
1466 { |
1466 { |
1467 ch = aDateTime[i]; |
1467 ch = aDateTime[i]; |
1599 // --------------------------------------------------------- |
1599 // --------------------------------------------------------- |
1600 // CSIContentHandler::AttributeToTTimeL |
1600 // CSIContentHandler::AttributeToTTimeL |
1601 // --------------------------------------------------------- |
1601 // --------------------------------------------------------- |
1602 // |
1602 // |
1603 TBool CSIContentHandler::AttributeToTTimeL |
1603 TBool CSIContentHandler::AttributeToTTimeL |
1604 ( NW_DOM_AttributeHandle_t& aAttrHandle, |
1604 ( NW_DOM_AttributeHandle_t& aAttrHandle, |
1605 TTime& aConvertedDate ) const |
1605 TTime& aConvertedDate ) const |
1606 { |
1606 { |
1607 PUSHLOG_ENTERFN("CSIContentHandler::AttributeToTTimeL") |
1607 PUSHLOG_ENTERFN("CSIContentHandler::AttributeToTTimeL") |
1608 |
1608 |
1609 TBool gotDate = EFalse; |
1609 TBool gotDate = EFalse; |
1638 TPtrC8 dataPtr( storage, length ); |
1638 TPtrC8 dataPtr( storage, length ); |
1639 HBufC* dataBuf = HBufC::NewMaxLC( dataPtr.Length() ); |
1639 HBufC* dataBuf = HBufC::NewMaxLC( dataPtr.Length() ); |
1640 dataBuf->Des().Copy( dataPtr ); |
1640 dataBuf->Des().Copy( dataPtr ); |
1641 gotDate = ConvertDateTimeL( *dataBuf, aConvertedDate ); |
1641 gotDate = ConvertDateTimeL( *dataBuf, aConvertedDate ); |
1642 |
1642 |
1643 CleanupStack::PopAndDestroy( 2, stringOwner ); // dataBuf, |
1643 CleanupStack::PopAndDestroy( 2, stringOwner ); // dataBuf, |
1644 // stringOwner |
1644 // stringOwner |
1645 } |
1645 } |
1646 else if ( valType == NW_DOM_ATTR_VAL_OPAQUE ) |
1646 else if ( valType == NW_DOM_ATTR_VAL_OPAQUE ) |
1647 { |
1647 { |
1648 NW_Uint32 len = 0; |
1648 NW_Uint32 len = 0; |
1667 |
1667 |
1668 // --------------------------------------------------------- |
1668 // --------------------------------------------------------- |
1669 // CSIContentHandler::HandleMessageL |
1669 // CSIContentHandler::HandleMessageL |
1670 // --------------------------------------------------------- |
1670 // --------------------------------------------------------- |
1671 // |
1671 // |
1672 void CSIContentHandler::HandleMessageL( CPushMessage* aPushMsg, |
1672 void CSIContentHandler::HandleMessageL( CPushMessage* aPushMsg, |
1673 TRequestStatus& aStatus ) |
1673 TRequestStatus& aStatus ) |
1674 { |
1674 { |
1675 PUSHLOG_ENTERFN("CSIContentHandler::HandleMessageL") |
1675 PUSHLOG_ENTERFN("CSIContentHandler::HandleMessageL") |
1676 |
1676 |
1677 __ASSERT_DEBUG( aPushMsg != NULL, |
1677 __ASSERT_DEBUG( aPushMsg != NULL, |
1678 ContHandPanic( EPushContHandPanMsgNull ) ); |
1678 ContHandPanic( EPushContHandPanMsgNull ) ); |
1679 |
1679 |
1680 #ifdef __TEST_LOG__ |
1680 #ifdef __TEST_LOG__ |
1681 TPtrC8 bodyPtr; |
1681 TPtrC8 bodyPtr; |
1682 aPushMsg->GetMessageBody( bodyPtr ); |
1682 aPushMsg->GetMessageBody( bodyPtr ); |