/** CountLinesOfBodyTextL() Counts the lines of body text in the email aEntry @param aEntry A reference to an object representing the email @param aFooterExists Reference to a boolean variable - set to ETrue if the footer string is found in the body text @param aFooterSize Expected KB left on server inserted into footer string if present @return Number of lines in the body text */ TInt CT_MsgComparePopEmailMsgs::CountLinesOfBodyTextL(CMsvEntry& aEntry, TBool& aFooterExists, TInt& aFooterSize) { TInt lines = 0; aFooterExists=EFalse; aFooterSize=0; aEntry.SetEntryL(aEntry.EntryId()); if(aEntry.HasStoreL()) { CMsvStore* msvStore1= aEntry.ReadStoreL(); CleanupStack::PushL(msvStore1); CParaFormatLayer* paraFormatLayer1 = CParaFormatLayer::NewL(); CleanupStack::PushL(paraFormatLayer1); CCharFormatLayer* charFormatLayer1 = CCharFormatLayer::NewL(); CleanupStack::PushL(charFormatLayer1); CRichText* bodyText1=CRichText::NewL(paraFormatLayer1, charFormatLayer1, CEditableText::EFlatStorage, 256); CleanupStack::PushL(bodyText1); bodyText1->Reset(); if (msvStore1->HasBodyTextL()) { msvStore1->RestoreBodyTextL(*bodyText1); TUint16 val = CEditableText::ELineBreak; TInt n = 0; TInt pos = 0; for(;;) { TPtrC bodyText = bodyText1->Read(pos); n = bodyText.Find(&val, 1); if(n < 0) break; lines++; pos += n+1; //This Check is needed to delete the extra line introduced by communigate Pro Server TInt fpos = CheckIfServerMessageExists(bodyText); if (fpos != KErrNotFound) { lines--; } } TPtrC pBt = bodyText1->Read(0); aFooterExists = CheckIfFooterMessageExistsL(pBt , aFooterSize); } CleanupStack::PopAndDestroy(4, msvStore1); //bodyText1,charFormatLayer1,paraFormatLayer1,msvStore1. } return lines; }
/** CountLinesOfHtmlL() Counts the number of lines of HTML @param aEntry A reference to an object representing the email @return Number of lines of HTML */ TInt CT_MsgComparePopEmailMsgs::CountLinesOfHtmlL(CMsvEntry& aEntry) { TInt lines = 0; aEntry.SetEntryL(aEntry.EntryId()); CMsvStore* store = aEntry.ReadStoreL(); CleanupStack::PushL(store); MMsvAttachmentManager& attManager = store->AttachmentManagerL(); RFile htmlFile = attManager.GetAttachmentFileL(0); CleanupClosePushL(htmlFile); _LIT8(KFindData, "\r\n"); TInt htmlSize = 0; User::LeaveIfError(htmlFile.Size(htmlSize)); HBufC8* fBuf = HBufC8::NewLC(htmlSize); TPtr8 p = fBuf->Des(); htmlFile.Read(p); TInt pos = 0; for(;;) { pos = p.Find(KFindData); if(pos < 0) { break; } p = p.Mid(pos+2); lines++; } CleanupStack::PopAndDestroy(fBuf); CleanupStack::PopAndDestroy(); // htmlFile CleanupStack::PopAndDestroy(store); return lines; }
LOCAL_C void CreateEntry(TMsvEntry& aNewEntry, CMsvEntry& aClientEntry, TInt aError, CEntryObserver& aObserver) { CTestActive* active = new (ELeave) CTestActive; CleanupStack::PushL(active); active->StartL(); aObserver.Start(); CMsvOperation* opert = aClientEntry.CreateL(aNewEntry, active->iStatus); CActiveScheduler::Start(); // operation complete CActiveScheduler::Start(); // cEntry changed test(opert->iStatus.Int()==KErrNone); test(opert->Mtm()==KUidMsvLocalServiceMtm); test(opert->Service()==KMsvLocalServiceIndexEntryId); TMsvLocalOperationProgress details; TPckgC<TMsvLocalOperationProgress> package(details); package.Set(opert->ProgressL()); test(package().iType==TMsvLocalOperationProgress::ELocalNew); test(package().iTotalNumberOfEntries==1); test(package().iError==aError); if (aError) { test(package().iNumberCompleted==0); test(package().iNumberFailed==1); } else { test(package().iNumberCompleted==1); test(package().iNumberFailed==0); TTestMsvEntry* ptr = (TTestMsvEntry*)&aNewEntry; ptr->SetId(package().iId); ptr->SetParent(aClientEntry.EntryId()); if (aNewEntry.iType==KUidMsvServiceEntry) aNewEntry.iServiceId = aNewEntry.Id(); } test(package().iNumberRemaining==0); delete opert; opert=NULL; CleanupStack::PopAndDestroy(); // active }
void CTestUTCSort::RemoveDefaultEntryL() { TMsvSelectionOrdering ordering; //sort the gloabl inbox by date CMsvEntry* inboxEntry = CMsvEntry::NewL(*iSession, KMsvDraftEntryIdValue,ordering); CleanupStack::PushL(inboxEntry); if(inboxEntry->Count()==1) { CMsvEntrySelection* mvEntrySelection; mvEntrySelection=inboxEntry->ChildrenL(); CleanupStack::PushL(mvEntrySelection); CMsvEntry* child; child=iSession->GetEntryL((*mvEntrySelection)[0]); iSession->RemoveEntry(child->EntryId()); delete child; CleanupStack::PopAndDestroy(mvEntrySelection); } CleanupStack::PopAndDestroy(inboxEntry); }
//--------------------------------------------------------------- // TestUniDataModelPlugin::createMMS //--------------------------------------------------------------- void TestUniDataModelMMSPlugin::createMMS(TMsvId pId, TBool subjectField) { TMsvEntry indexEntry; indexEntry.iType = KUidMsvMessageEntry; indexEntry.iMtm = KUidMsgTypeMultimedia; indexEntry.iServiceId = iServiceId; indexEntry.iDate.HomeTime(); // Convert TTime to QDateTime , this will be used for comparing the time of mesage // when fetched from datamodel TTime unixEpoch(KUnixEpoch); TTimeIntervalSeconds seconds; TTime timeStamp = indexEntry.iDate; timeStamp.SecondsFrom(unixEpoch, seconds); retTimeStamp.setTime_t(seconds.Int()); TMsvId parentId = pId; CMsvEntry* entry = CMsvEntry::NewL(*iMSession,parentId,TMsvSelectionOrdering()); CleanupStack::PushL(entry); entry->SetEntryL(parentId); entry->CreateL(indexEntry); entry->SetEntryL(indexEntry.Id()); iMmsClientMtm->SwitchCurrentEntryL(entry->EntryId()); CMsvStore* store = iMmsClientMtm->Entry().EditStoreL(); CleanupStack::PushL(store); //MMS Message ID Saved iMessageId = indexEntry.Id(); //Adding Subject if(subjectField) { QString subject(TEST_MSG_SUBJECT); HBufC* subj = XQConversions::qStringToS60Desc(subject); iMmsClientMtm->SetSubjectL(*subj); } //Adding Sender QString sender(TEST_MSG_FROM1); HBufC* addr = XQConversions::qStringToS60Desc(sender); if (addr) { CleanupStack::PushL(addr); TBuf<32> name; name.Copy(addr->Left(32)); indexEntry.iDetails.Set(name); iMmsClientMtm->SetSenderL(*addr); CleanupStack::PopAndDestroy(addr); } //Adding Recipient QString recipient(TEST_MSG_RECIEPIENT1); HBufC* addr2 = XQConversions::qStringToS60Desc(recipient); if (addr2) { CleanupStack::PushL(addr2); iMmsClientMtm->AddAddresseeL(EMsvRecipientTo,*addr2); CleanupStack::PopAndDestroy(addr2); } //Adding cCRecipient QString recipient2(TEST_MSG_RECIEPIENT2); HBufC* addr3 = XQConversions::qStringToS60Desc(recipient2); if (addr3) { CleanupStack::PushL(addr3); iMmsClientMtm->AddAddresseeL(EMsvRecipientCc,*addr3); CleanupStack::PopAndDestroy(addr3); } //Adding bCCRecipient QString recipient3(TEST_MSG_RECIEPIENT3); HBufC* addr4 = XQConversions::qStringToS60Desc(recipient3); if (addr4) { CleanupStack::PushL(addr4); iMmsClientMtm->AddAddresseeL(EMsvRecipientBcc,*addr4); CleanupStack::PopAndDestroy(addr4); } //Create Text Attachment TMsvAttachmentId attaId = 0; TFileName attachmentFile( _L("story.txt") ); TBufC<12> story = _L( "Hello world!" ); iMmsClientMtm->CreateTextAttachmentL(*store, attaId, story, attachmentFile, ETrue ); qDebug() << "Text Attachment id" << attaId; //Image Attachment added to the message entry RFile attaFile; // Set filename of attachment TFileName name( KPictureFileName ); CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL(); CleanupStack::PushL( mimeHeaders ); // Set values to mime headers mimeHeaders->SetContentTypeL( _L8( "image") ); mimeHeaders->SetContentSubTypeL( _L8( "jpeg" ) ); _LIT8(KMimeType, "image/jpeg"); TBufC8<10> mimeType(KMimeType); // CreateAttachment2L will set the content type to attachment Info // Open the attachment file for reading attaFile.Open( iFs, name, EFileShareReadersOnly | EFileRead ); CleanupClosePushL(attaFile); CMsvAttachment* attaInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // attaInfo ownerhip will be transferred to Attachment Manager. // It must not be pushed onto the cleanupStack before calling // CreateAttachment2L. iMmsClientMtm->CreateAttachment2L(*store, attaFile,mimeType,*mimeHeaders,attaInfo,attaId); qDebug() << "Image Attachment id" << attaId; // Now Attachment Manager owns the attaInfo CleanupStack::Pop(); // attaFile.Close() CleanupStack::PopAndDestroy(); // mimeHeaders store->CommitL(); CleanupStack::PopAndDestroy(store); // store iMmsClientMtm->SaveMessageL(); //Saving the message size for future checking msgSize = iMmsClientMtm->MessageSize(); CleanupStack::Pop(entry); // entry }
/** CountLinesOfBodyTextL() Counts the lines of body text in the email aEntry @param aEntry A reference to an object representing the email @param aFooterExists Reference to a boolean variable - set to ETrue if the footer string is found in the body text @param aFooterSize Expected KB left on server inserted into footer string if present @return Number of lines in the body text */ TInt CT_MsgComparePopEmailMsgs::CountLinesOfBodyTextL(CMsvEntry& aEntry, TBool& aFooterExists, TInt& aFooterSize) { TInt lines = 0; TInt count =0; aFooterExists=EFalse; aFooterSize=0; aEntry.SetEntryL(aEntry.EntryId()); if(aEntry.HasStoreL()) { CMsvStore* msvStore1= aEntry.ReadStoreL(); CleanupStack::PushL(msvStore1); CParaFormatLayer* paraFormatLayer1 = CParaFormatLayer::NewL(); CleanupStack::PushL(paraFormatLayer1); CCharFormatLayer* charFormatLayer1 = CCharFormatLayer::NewL(); CleanupStack::PushL(charFormatLayer1); CRichText* bodyText1=CRichText::NewL(paraFormatLayer1, charFormatLayer1, CEditableText::EFlatStorage, 256); CleanupStack::PushL(bodyText1); bodyText1->Reset(); if (msvStore1->HasBodyTextL()) { msvStore1->RestoreBodyTextL(*bodyText1); TUint16 val = CEditableText::ELineBreak; TUint16 val1 = CEditableText::EParagraphDelimiter; TUint16 val2 = KUnicodeValue; TInt n = 0; TInt pos = 0; for(;;) { TPtrC bodyText = bodyText1->Read(pos); n = bodyText.Find(&val, 1); // if iStore8BitData flag is set, the line is terminated by "CEditableText::EParagraphDelimiter" if(msvStore1->IsPresentL(KMsvPlainBodyText8)) { if ( 0 == count ) { TPtrC buffer = bodyText.Mid(0,n+2); // eg for 8bit the body look as : This is a simple email message.\x2028\x2029\x2029 // eg for 16bit the body look as: This is a simple email message.\x2028\x2028\x2029 if((bodyText.Right(2).Compare(KParagraphDelimiter)==KErrNone) && \ buffer.Find(&val2,1) != 75) { lines++; count++; } // Increment the line if EParagraphDelimiter or 0x0046 is found sequence as eg:1. \x2028\x2029 // 2. \x2028\x2029\x2028\x2029\x0046 3. \x2028\x2029\x2028\x2029\x2028\x2029 else if ( (buffer.Find(&val1,1)==0 && n==-1) || (buffer.Find(&val2,1)==1) \ || (buffer.Find(&val1,1)>0) ) { lines++; } } } if(n < 0) break; lines++; pos += n+1; //This Check is needed to delete the extra line introduced by communigate Pro Server TInt fpos = CheckIfServerMessageExists(bodyText); if (fpos != KErrNotFound) { lines--; } } TPtrC pBt = bodyText1->Read(0); aFooterExists = CheckIfFooterMessageExistsL(pBt , aFooterSize); } CleanupStack::PopAndDestroy(4, msvStore1); //bodyText1,charFormatLayer1,paraFormatLayer1,msvStore1. } return lines; }