TInt CMtfTestActionCheckChildrenCountWithFlagBase::CountChildrenL(TMsvId aParent, CMsvSession& aSession) { TInt children = 0; // Get children at this level CMsvEntry* entryContext = CMsvEntry::NewL(aSession, aParent, TMsvSelectionOrdering(KMsvNoGrouping, EMsvSortByNone, ETrue)); CleanupStack::PushL(entryContext); entryContext->SetEntryL(aParent); TMsvSelectionOrdering order; order.SetShowInvisibleEntries(ETrue); entryContext->SetSortTypeL(order); CMsvEntrySelection* selection = entryContext->ChildrenL(); CleanupStack::PushL(selection); // for each child TInt count=selection->Count(); for(TInt child=0;child<count;child++) { entryContext->SetEntryL((*selection)[child]); TMsvEntry entry=entryContext->Entry(); if (entry.iType==KUidMsvMessageEntry && FlagIsSet(entry) ) { ++children; } // if this is a folder then recurse if (entry.iType==KUidMsvFolderEntry) children +=CountChildrenL((*selection)[child], aSession); } CleanupStack::PopAndDestroy(2); // selection,entryContext return children; }
void CMsvSendExe::RestoreScheduleSettingsL(TMsvId aServiceId, const TUid& aMtm, CMsvScheduleSettings& aSettings) { TMsvSelectionOrdering order; order.SetShowInvisibleEntries(ETrue); CMsvEntry* cEntry = CMsvEntry::NewL(*iSession, KMsvRootIndexEntryId, order); CleanupStack::PushL(cEntry); if (aServiceId == KMsvLocalServiceIndexEntryId) { const TInt count = cEntry->Count(); for (TInt i = 0; i < count; i++) { const TMsvEntry& entry = (*cEntry)[i]; if (entry.iType == KUidMsvServiceEntry && entry.iMtm == aMtm) { aServiceId = entry.Id(); break; } } } if (aServiceId == KMsvLocalServiceIndexEntryId) User::Leave(KErrNotFound); CRepository* repository = CRepository::NewLC(aMtm); TMsvScheduleSettingsUtils::LoadScheduleSettingsL(aSettings, *repository); CleanupStack::PopAndDestroy(2, cEntry); // repository, cEntry }
TBool CSmsFile::DeleteSentEntry(TMsvId entry) { TInt err; // Load this entry to our mtm TRAP(err, iReceiveMtm->SwitchCurrentEntryL(entry)); // probably wasn't compatible, ignore if (err!=KErrNone) return EFalse; TRAP(err, iReceiveMtm->LoadMessageL()); // probably wasn't compatible, ignore if (err!=KErrNone) return EFalse; TMsvEntry msvEntry( (iReceiveMtm->Entry()).Entry() ); if (msvEntry.iMtmData3 == KUidRippleVaultApp.iUid) // this entry has been created by our app { // Taking a handle to the Sent folder... TMsvSelectionOrdering sort; sort.SetShowInvisibleEntries(ETrue); // we want to handle also the invisible entries // Take a handle to the parent entry CMsvEntry* parentEntry = CMsvEntry::NewL(iReceiveMtm->Session(), msvEntry.Parent(), sort); CleanupStack::PushL(parentEntry); // here parentEntry is the Sent folder (must be so that we can call DeleteL) parentEntry->DeleteL(msvEntry.Id()); CleanupStack::Pop(); //if(iBillSms == 1) //iAppUi.CheckBillingStatus(5); return ETrue; // entry was deleted } return EFalse; // no entries deleted }
/* ----------------------------------------------------------------------------- RFile GetAttachmentFileL(TMsvAttachmentId aId) ---------------------------------------------------------------------------- */ void CMailBoxContainer::OpenFileL(TBool /*aOpenWith*/) { if(iSession && iSelectionBox) { TInt CurrItmIndex = iSelectionBox->CurrentItemIndex(); TMsvSelectionOrdering sort; sort.SetShowInvisibleEntries(ETrue); sort.SetSorting(EMsvSortByDate); // Take a handle to the folder entry CMsvEntry* parentEntry = CMsvEntry::NewL(*iSession,iCurrentMailBox,sort); CleanupStack::PushL(parentEntry); // A selection of all BT entries CMsvEntrySelection* entries = parentEntry->ChildrenL();//ChildrenWithMtmL(KUidMsgTypeBt); CleanupStack::PushL(entries); //Process all entries if(CurrItmIndex >= 0 && CurrItmIndex < iIDArray->Count()) { //Get entry CMsvEntry* btEntry = iSession->GetEntryL(iIDArray->At(CurrItmIndex).iEnt); CleanupStack::PushL(btEntry); //Then get entrys child CMsvEntrySelection* btChildren = btEntry->ChildrenL(); CleanupStack::PushL(btChildren); btEntry->SetEntryL(iIDArray->At(CurrItmIndex).iMsg); if (btEntry->HasStoreL()) { CMsvStore* store = btEntry->ReadStoreL(); CleanupStack::PushL(store); MMsvAttachmentManager& attMngr = store->AttachmentManagerL(); CMsvAttachment* attachment = attMngr.GetAttachmentInfoL(iIDArray->At(CurrItmIndex).iAtt); if(attachment) { RFile SourceFil(attMngr.GetAttachmentFileL(iIDArray->At(CurrItmIndex).iAtt)); iUtils.GetFileUtils().OpenFileWithHandler(SourceFil); SourceFil.Close(); } CleanupStack::PopAndDestroy(store); } CleanupStack::PopAndDestroy(2); } CleanupStack::PopAndDestroy(2); } }
TVerdict CTestUTCSort::TestSortingL() { TVerdict result=EPass; //create ordering objects TMsvSelectionOrdering ordering; ordering.SetSorting(EMsvSortByDate); //sort the gloabl inbox by date CMsvEntry* inboxEntry = CMsvEntry::NewL(*iSession, KMsvDraftEntryIdValue,ordering); CleanupStack::PushL(inboxEntry); //retrieve the children of the inbox CMsvEntrySelection* msvEntrySelection; msvEntrySelection=inboxEntry->ChildrenL(); CleanupStack::PushL(msvEntrySelection); CMsvEntry* child; TMsvEntry childDetails; TBuf<45> dateTimeString; //look at the id of each child and test its id, these should //be in the order the entries were created. for(TInt i=0;i<KNumEmailMessages;++i) { child=iSession->GetEntryL((*msvEntrySelection)[i]); childDetails=child->Entry(); delete child; //print the time of the entry to the log file dateTimeString.Zero(); FormatDateTime(dateTimeString,childDetails.iDate); INFO_PRINTF2(_L("%S"),&dateTimeString); if(childDetails.Id()!=iTMsvIdList->At(i)) { ERR_PRINTF1(_L("Entries in wrong order")); result=EFail; break; } } CleanupStack::PopAndDestroy(msvEntrySelection); CleanupStack::PopAndDestroy(inboxEntry); return result; }
/* ----------------------------------------------------------------------------- ---------------------------------------------------------------------------- */ void CSMSMonitor::CheckInboxL(void) { TInt smsCount(0),mmsCount(0); CMsvEntry* Entrie = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId); if(Entrie) { CleanupStack::PushL(Entrie); if(Entrie->Count()) { TMsvSelectionOrdering MySortType; MySortType.SetSorting(EMsvSortByDate); Entrie->SetSortTypeL(MySortType); CMsvEntrySelection* entries = Entrie->ChildrenL(); if(entries) { CleanupStack::PushL(entries); for(TInt i = (entries->Count() - 1); i >= 0; i--) { if(Entrie->ChildDataL(entries->At(i)).Unread()) { if(Entrie->ChildDataL(entries->At(i)).iMtm == KUidMsgTypeSMS) { smsCount++; } else if(Entrie->ChildDataL(entries->At(i)).iMtm == KUidMsgTypeMultimedia) { mmsCount++; } } } CleanupStack::PopAndDestroy(entries); } } CleanupStack::PopAndDestroy(1);//Entrie } if(iObserver){ iObserver->InboxChangedL(smsCount,mmsCount); } }
EXPORT_C void CMsvTestUtils::ServiceIdL(TUid aMtm, TMsvId& rFirstId, CMsvEntrySelection* rServiceIds) { //Returns the Service IDs of MTM aMtm rFirstId = KMsvNullIndexEntryId; SetEntryL(KMsvRootIndexEntryId); // TMsvSelectionOrdering oldOrder = aEntry.SortType(); TMsvSelectionOrdering order; order.SetShowInvisibleEntries(ETrue); SetSortTypeL(order); //Get the children on the Root Index Entry CMsvEntrySelection* selection = ChildrenWithTypeLC(KUidMsvServiceEntry); TInt count = selection->Count(); //Find an entry for MTM aMtm for (TInt curChild = 0; curChild < count && (rFirstId == KMsvNullIndexEntryId || rServiceIds); curChild++) { SetEntryL(selection->At(curChild)); if (Entry().iMtm == aMtm) { TMsvId id = Entry().Id(); if (rFirstId == KMsvNullIndexEntryId) rFirstId = id; if (rServiceIds) rServiceIds->AppendL(id); } } //Leave if no Service Entry found for MTM aMtm if (rFirstId == KMsvNullIndexEntryId) { CleanupStack::PopAndDestroy(); //selection User::Leave(KErrNotFound); } CleanupStack::PopAndDestroy(); //selection }
TBool CSmsReplyToStep::CheckMessageL() { INFO_PRINTF1(_L("Received new message in Inbox - should be status report...")); TMsvSelectionOrdering ordering; ordering.ShowInvisibleEntries(); CMsvEntry* entry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId,ordering); CleanupStack::PushL(entry); CMsvEntrySelection* msvEntrySelection; msvEntrySelection=entry->ChildrenL(); CleanupStack::PushL(msvEntrySelection); // Check how many mesasges there are - should be just 1 TInt count = msvEntrySelection->Count(); INFO_PRINTF3(_L("Number of new messages: %d, should be: %d"), count, 1); // Restore the message CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, *iTestUtils->iRichText); CleanupStack::PushL(header); entry->SetEntryL((*msvEntrySelection)[0]); CMsvStore* store = entry->ReadStoreL(); CleanupStack::PushL(store); header->RestoreL(*store); if(store->HasBodyTextL()) { store->RestoreBodyTextL(*iTestUtils->iRichText); } TBuf<KSmsDescriptionLength> desc; User::LeaveIfError(TSmsUtilities::GetDescription(header->Message(), desc)); //Check for a reply address field CSmsReplyAddressOperations& operations = STATIC_CAST(CSmsReplyAddressOperations&,header->Message().GetOperationsForIEL(CSmsInformationElement::ESmsReplyAddressFormat)); TBool result=operations.ContainsReplyAddressIEL(); CleanupStack::PopAndDestroy(4,entry); return result; }
TBool CMsvEntryArray::OkToGroup(TGroupCriterion aGroupCriterion,TMsvSelectionOrdering aOrdering) const // // Returns true if the current grouping method is selected // { switch (aGroupCriterion) { case EGroupByType: return aOrdering.GroupByType(); case EGroupByStandardFolders: return aOrdering.GroupStandardFolders(); case EGroupByPriority: return aOrdering.GroupByPriority(); case EGroupByMtm: return aOrdering.GroupByMtm(); default: //case EStopGrouping: return EFalse; } // return EFalse; }
void CTestUTCParse::TraverseL(const TMsvId aTMsvId) { //open the entry, dont sort TMsvSelectionOrdering ordering; ordering.SetSorting(EMsvSortByNone); CMsvEntry* entry = CMsvEntry::NewL(*iSession, aTMsvId,ordering); CleanupStack::PushL(entry); //retrieve the entries children CMsvEntrySelection* msvEntrySelection; msvEntrySelection=entry->ChildrenL(); CleanupStack::PushL(msvEntrySelection); TInt count = entry->Count(); CMsvEntry* child; TMsvEntry childDetails; //for each child test if its a message entry for(TInt i=0;i<count;i++) { child=iSession->GetEntryL((*msvEntrySelection)[i]); childDetails=child->Entry(); if(childDetails.iType==KUidMsvMessageEntry) { iMessageEntryCount++; iTimeList->AppendL(childDetails.iDate); PrintEntryTime(&childDetails.iDate); } //recursive call TraverseL(childDetails.Id()); if(child) { delete child; } } CleanupStack::PopAndDestroy(msvEntrySelection); CleanupStack::PopAndDestroy(entry); }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ TBool CSMSSender::MoveMessageEntryL(TMsvId aTarget) { ASSERT(iMtm); TMsvEntry msvEntry((iMtm->Entry()).Entry()); if (msvEntry.Parent() != aTarget) { TMsvSelectionOrdering sort; sort.SetShowInvisibleEntries(ETrue); // we want to also handle the invisible entries // Take a handle to the parent entry CMsvEntry* parentEntry = CMsvEntry::NewL(iMtm->Session(), msvEntry.Parent(), sort); CleanupStack::PushL(parentEntry); // Move original from the parent to the new location iOperation = parentEntry->MoveL(msvEntry.Id(), aTarget, iStatus); CleanupStack::PopAndDestroy(parentEntry); SetActive(); return ETrue; } return EFalse; }
EXPORT_C void CMsvEntryArray::SortL(TMsvSelectionOrdering aOrdering) // // sorts this array // { // If we're going to reverse the array first sort by id so sorting twice will give the same result switch(aOrdering.Sorting()) { case EMsvSortByDateReverse: case EMsvSortByIdReverse: case EMsvSortBySizeReverse: case EMsvSortByDescriptionReverse: case EMsvSortByDetailsReverse: { TKeyArrayFixPtr key = MessageSortKey(EMsvSortById); User::LeaveIfError(Sort(key)); break; } default: // Not required - break break; } if (Count() && (aOrdering.Sorting()!=EMsvSortByNone || aOrdering.GroupingOn())) GroupL(EGroupByStandardFolders, aOrdering, (aOrdering.Sorting()!=EMsvSortByNone)); }
void CMsvEntryArray::GroupL(TGroupCriterion aGroupCriterion,TMsvSelectionOrdering aOrdering,TBool aDoSort) // // This function works recursively, grouping and sorting the entry selection. The // 'sort' happens at the same time as the 1st 'group', then separate grouped arrays // are grouped indidvidually and then merged together at the end. The order in which // the grouping occurs is determined by the CMsvEntryArray::TGroupCriterion enum // { TMsvSorting sortType=aOrdering.Sorting(); TKeyArrayFixPtr key=MessageSortKey(sortType); if (aGroupCriterion==EStopGrouping) { // if you haven't sorted yet if (aDoSort) { // Subject based sorting requires a special algorithm. Only message entries are treated as other entries normally // do not have a prefix like e.g. "re: " or "fwd: " if(At(0)->iType == KUidMsvMessageEntry && (sortType == EMsvSortByDescription || sortType == EMsvSortByDescriptionReverse)) { SubjectBasedSortL(sortType == EMsvSortByDescriptionReverse,aOrdering.SubjectSkipString()); } else { CMsvEntryArray* temp=CMsvEntryArray::NewLC(iOrigMtmList); TInt count=Count(); if (count) temp->InsertL(0,&(*(this))[0],count); Reset(); const TMsvEntry** entry = &temp->At(0); while (count--) InsertIsqAllowDuplicatesL(*entry++, key); // Sorted ReverseOrder(sortType); CleanupStack::PopAndDestroy(); // temp } if (At(0)->iType == KUidMsvMessageEntry && (sortType == EMsvSortByDetails || sortType == EMsvSortByDetailsReverse)) { DetailBasedSortL(); // Sort blocks of messages with matching details into newest first } } else { // The aDoSort flag is not set, but we still need to do a subject // based sort if this array contains only message entries, and we are // sorting by description. Alternatively, we need to do a date based sort // if this array contains only message entries and we are sorting by detail. // In order to ensure the array contains only message entries, we // check that we have previously grouped the entries by type which would // have put all the message entries together in their own array. if (Count() > 0 && At(0)->iType == KUidMsvMessageEntry && OkToGroup(EGroupByType, aOrdering)) { if (sortType == EMsvSortByDescription || sortType == EMsvSortByDescriptionReverse) { SubjectBasedSortL(sortType == EMsvSortByDescriptionReverse,aOrdering.SubjectSkipString()); } else if (sortType == EMsvSortByDetails || sortType == EMsvSortByDetailsReverse) { DetailBasedSortL(); // Sort blocks of messages with matching details into newest first } } } return; } if (OkToGroup(aGroupCriterion, aOrdering)) { // // Copy contents into temp and then put new grouped contents into 'this' TInt count=Count(); if (count==0) return; // nothing to do here const TInt numberOfArrays=NumberOfArraysToSplitIntoL(aGroupCriterion); if (numberOfArrays<1) // cannot group on this so move on to next grouping { GroupL(TGroupCriterion(aGroupCriterion+1), aOrdering, aDoSort); return; } CMsvEntryArray* temp; if (iActualMtmList) temp = CMsvEntryArray::NewLC(*iActualMtmList); else temp = CMsvEntryArray::NewLC(iOrigMtmList); temp->InsertL(0,&(*(this))[0],count); Reset(); // // create the separate arrays for each group CArrayFixFlat<CMsvEntryArray*>* arrays=new(ELeave) CArrayFixFlat<CMsvEntryArray*>(numberOfArrays); CleanupStack::PushL(arrays); for (TInt ii=0; ii<numberOfArrays; ii++) { if (iActualMtmList) arrays->AppendL(CMsvEntryArray::NewLC(*iActualMtmList)); else arrays->AppendL(CMsvEntryArray::NewLC(iOrigMtmList)); } // // split the selection into the correct group, // sorting aswell if needed and not doing standard folders const TMsvEntry** entry = &temp->At(0); if (!aDoSort || aGroupCriterion==EGroupByStandardFolders) { while (count--) { arrays->At(ArrayId(*entry,aGroupCriterion))->AppendL(*entry); entry++; } } else if (aGroupCriterion==EGroupByType) { TKeyArrayFixPtr folderKey = TKeyArrayFixPtr(_FOFF(TMsvEntry,iDetails),ECmpCollated); while (count--) { if ((*entry)->iType==KUidMsvFolderEntry) arrays->At(ArrayId(*entry, aGroupCriterion))->InsertIsqAllowDuplicatesL(*entry, folderKey); else arrays->At(ArrayId(*entry, aGroupCriterion))->InsertIsqAllowDuplicatesL(*entry, key); entry++; } for (TInt jj=0; jj<numberOfArrays; jj++) { if (arrays->At(jj)->Count() && arrays->At(jj)->At(0)->iType!=KUidMsvFolderEntry) arrays->At(jj)->ReverseOrder(sortType); } aDoSort=EFalse; } else { while (count--) { arrays->At(ArrayId(*entry, aGroupCriterion))->InsertIsqAllowDuplicatesL(*entry, key); // Sorted entry++; } for (TInt jj=0; jj<numberOfArrays; jj++) arrays->At(jj)->ReverseOrder(sortType); aDoSort=EFalse; } // // group further - but check that standard entries and grouped folders are not grouped anymore if (aGroupCriterion==EGroupByStandardFolders) { __ASSERT_DEBUG(numberOfArrays==2, PanicServer(EMsvToManyGroups)); arrays->At(0)->GroupL(TGroupCriterion(aGroupCriterion+1), aOrdering, aDoSort); } else if (aGroupCriterion==EGroupByType) { for (TInt jj=0; jj<numberOfArrays; jj++) if (arrays->At(jj)->Count() && arrays->At(jj)->At(0)->iType!=KUidMsvFolderEntry) arrays->At(jj)->GroupL(TGroupCriterion(aGroupCriterion+1), aOrdering, aDoSort); } else { for (TInt jj=0; jj<numberOfArrays; jj++) arrays->At(jj)->GroupL(TGroupCriterion(aGroupCriterion+1), aOrdering, aDoSort); } // // merge the separate arrays into 'this' for (TInt kk=0; kk<numberOfArrays; kk++) { count=arrays->At(kk)->Count(); if (count) InsertL(0,&(*(arrays->At(kk)))[0],count); } CleanupStack::PopAndDestroy(numberOfArrays+2); // arrays contents + temp + arrays } else // move on to the next grouping GroupL(TGroupCriterion(aGroupCriterion+1), aOrdering, aDoSort); }
void CPerformanceInitialisationClient::RunL() { User::LeaveIfError(iStatus.Int()); CMsvEntry* imapService=NULL; TMsvSelectionOrdering ordering; TPckg<MMsvImapConnectionObserver*> param(this); CMsvEntry* entry=NULL; TBuf8<4> buf; switch(iState) { case EConnectAndSync: iTestStep.INFO_PRINTF1(_L("Intialisation - Connect and sync...")); iSelection = new (ELeave) CMsvEntrySelection; //select the imap service entry iSelection->AppendL(iImapAccount.iImapService); //make the service entry the current context iClientMtm->SwitchCurrentEntryL(iImapAccount.iImapService); //sync the account iState=EWait; iMsvOperation = iClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndSyncCompleteAfterFullSync,*iSelection,param,iStatus); SetActive(); break; case EWait: delete iMsvOperation; iMsvOperation=NULL; iMsvOperation = iClientMtm->InvokeAsyncFunctionL(KIMAP4MTMWaitForBackground,*iSelection,buf,iStatus); SetActive(); iState=EDeleteRemoteEntries; break; case EDeleteRemoteEntries: iTestStep.INFO_PRINTF1(_L("Intialisation - Deleting remote entries...")); // delete all messages in the Inbox imapService = CMsvEntry::NewL(*iSession, iImapAccount.iImapService,ordering); CleanupStack::PushL(imapService); //retrieve the inbox from the imap service entry CMsvEntrySelection* msvEntrySelection; msvEntrySelection=imapService->ChildrenL(); CleanupStack::PushL(msvEntrySelection); //create a CMsvEntry for the inbox entry iInboxEntry = CMsvEntry::NewL(*iSession, (*msvEntrySelection)[0],ordering); CleanupStack::PopAndDestroy(2,imapService); iChildren = iInboxEntry->ChildrenL(); if(iChildren->Count()>0) { iInboxEntry->DeleteL(*iChildren,iStatus); SetActive(); } else { CompleteSelf(); } iState=EDisconnect; break; case EUploadMessages: iTestStep.INFO_PRINTF1(_L("Intialisation - Uploading messages...")); //select the message in the outbox ordering.SetShowInvisibleEntries(ETrue); entry = CMsvEntry::NewL(*iSession,KMsvGlobalOutBoxIndexEntryIdValue,ordering); CleanupStack::PushL(entry); entry->SetEntryL(KMsvGlobalOutBoxIndexEntryIdValue); iEntrySelectionToSend=entry->ChildrenL(); //copy the message to the smtp service iOperation = entry->CopyL(*iEntrySelectionToSend,iSmtpAccount.iSmtpService,iStatus); CleanupStack::PopAndDestroy(1,entry); SetActive(); iState=EComplete; break; case EDisconnect: iTestStep.INFO_PRINTF1(_L("Intialisation - Disconnecting...")); delete iMsvOperation; iMsvOperation=NULL; iMsvOperation = iClientMtm->InvokeAsyncFunctionL(KIMAP4MTMDisconnect,*iSelection,buf,iStatus); SetActive(); iState=EComplete; break; case EComplete: User::After(10000000); iTestStep.INFO_PRINTF1(_L("EComplete")); //inform the owning object that the process is complete iTestStep.InitialisationComplete(KErrNone); break; default: __ASSERT_DEBUG(0, User::Panic(_L("CPerformanceInitialisationClient unknown state"), KErrUnknown)); break; } }
/* ----------------------------------------------------------------------------- ---------------------------------------------------------------------------- */ void CMailBoxContainer::ReadMailFolderL(TMsvId aSelected) { iCurrentMailBox = aSelected; delete iIDArray; iIDArray = NULL; if(iSession && iSelectionBox) { TInt OrgCount = iSelectionBox->Model()->ItemTextArray()->MdcaCount(); STATIC_CAST(CDesCArray*,iSelectionBox->Model()->ItemTextArray())->Reset(); RPointerArray<CFFileTypeItem> ItemTypeArray = iUtils.GetFileUtils().GetItemTypeArray(); iIDArray = new(ELeave)CArrayFixFlat<TMyMailEntry>(10); TMsvSelectionOrdering sort; sort.SetShowInvisibleEntries(ETrue); sort.SetSorting(EMsvSortByDate); // Take a handle to the folder entry CMsvEntry* parentEntry = CMsvEntry::NewL(*iSession,aSelected,sort); CleanupStack::PushL(parentEntry); // A selection of all BT entries CMsvEntrySelection* entries = parentEntry->ChildrenL();//ChildrenWithMtmL(KUidMsgTypeBt); CleanupStack::PushL(entries); //Process all entries for(TInt ii = 0; ii < entries->Count(); ii++) { //Get entry CMsvEntry* btEntry = iSession->GetEntryL((*entries)[ii]); CleanupStack::PushL(btEntry); //Then get entrys child CMsvEntrySelection* btChildren = btEntry->ChildrenL(); CleanupStack::PushL(btChildren); TInt childc = btChildren->Count(); if (childc>0) { for(TInt i=0; i<childc; i++) { TMsvId btAtt = (*btChildren)[i]; btEntry->SetEntryL(btAtt); if(btEntry->Entry().iMtm == KUidMsgTypePOP3) { CImEmailMessage* emailMessage = CImEmailMessage::NewL(*btEntry); CleanupStack::PushL(emailMessage); MMsvAttachmentManager& attMngr = emailMessage->AttachmentManager(); GetAttachmentsL(attMngr,*btEntry,(*entries)[ii],btAtt); CleanupStack::PopAndDestroy(emailMessage); } else if (btEntry->HasStoreL()) { CMsvStore* store = btEntry->ReadStoreL(); CleanupStack::PushL(store); MMsvAttachmentManager& attMngr = store->AttachmentManagerL(); GetAttachmentsL(attMngr,*btEntry,(*entries)[ii],btAtt); CleanupStack::PopAndDestroy(store); } } } CleanupStack::PopAndDestroy(2); } CleanupStack::PopAndDestroy(2); CDesCArray* itemArray = STATIC_CAST( CDesCArray* ,iSelectionBox->Model()->ItemTextArray()); if(itemArray->Count() > OrgCount) { iSelectionBox->HandleItemAdditionL(); iSelectionBox->SetCurrentItemIndex(0); } else { iSelectionBox->HandleItemRemovalL(); if(itemArray->Count()) { iSelectionBox->SetCurrentItemIndex(0); } } UpdateScrollBar(iSelectionBox); DrawNow(); }
// ----------------------------------------------------------------------------- // CMessageMonitorPlugin::HandleMsgMovedL // ----------------------------------------------------------------------------- // void CMessageMonitorPlugin::HandleMsgMovedL( const TMsvId aFolderId1, const TMsvId aFolderId2, const CMsvEntrySelection& aSelection ) { WRITELOG("ENTER CMessageMonitorPlugin::HandleMsgMovedL"); TInt count( aSelection.Count() ); // cycle through every message in the CMsvEntrySelection for ( TInt i=0; i < count; ++i ) { TMsvId msgId = aSelection[i]; WRITELOG1("msgId: %d", msgId ); TMsvId service = 0; TMsvEntry entry; TInt err = iMsvSession->GetEntry( msgId, service, entry ); // if we have a message and it has been moved from the outbox to the sent // items, and it is a valid message if ( ( !err ) && ( KUidMsvMessageEntry == entry.iType ) && ( KMsvSentEntryId == aFolderId1 ) && ( KMsvGlobalOutBoxIndexEntryId == aFolderId2 ) && ( IsValidMessageTypeL( entry, *iMsvSession ) ) ) { HBufC* uri = CreateUriL( entry.iMtm, msgId ); CleanupStack::PushL( uri ); CHarvesterData* hd = CHarvesterData::NewL( uri ); CleanupStack::Pop( uri ); hd->SetEventType( EHarvesterAdd ); hd->SetTakeSnapshot( EFalse ); hd->SetBinary( EFalse ); iMonitorPluginObserver->MonitorEvent( hd ); } #ifdef __WINSCW__ else if (!err && KMsvDraftEntryId == aFolderId2 && KMsvGlobalOutBoxIndexEntryId == aFolderId1 ) { if( entry.iMtm.iUid != KUidMsgTypeMultimedia.iUid ) { CClientMtmRegistry* clientMtmReg; clientMtmReg = CClientMtmRegistry::NewL(*iMsvSession); CleanupStack::PushL(clientMtmReg); CSmsClientMtm* smsMtm = static_cast<CSmsClientMtm*>(clientMtmReg->NewMtmL(KUidMsgTypeSMS)); CleanupStack::PushL(smsMtm); smsMtm->SwitchCurrentEntryL( msgId ); TMsvSelectionOrdering selection; selection.SetShowInvisibleEntries(ETrue); CMsvEntry* parentEntry = CMsvEntry::NewL( smsMtm->Session(), smsMtm->Entry().Entry().Parent(), selection ); CleanupStack::PushL(parentEntry); // Move the message TRAP_IGNORE( parentEntry->MoveL( msgId, KMsvSentEntryId ) ); CleanupStack::PopAndDestroy(3,clientMtmReg); // parentEntry } } #endif } WRITELOG("END CMessageMonitorPlugin::HandleMsgMovedL"); }
/* ----------------------------------------------------------------------------- RFile GetAttachmentFileL(TMsvAttachmentId aId) ---------------------------------------------------------------------------- */ void CMailBoxContainer::CopyFileL(const TDesC& aFolderName) { TFileName fileName,FullFilName; if(iSession && iSelectionBox && iListArray) { TInt CurrItmIndex = iSelCopyItemIndex; iSelCopyItemIndex = -1; if(CurrItmIndex < 0 || CurrItmIndex >= iIDArray->Count()) { CurrItmIndex = iSelectionBox->CurrentItemIndex(); } TMsvSelectionOrdering sort; sort.SetShowInvisibleEntries(ETrue); sort.SetSorting(EMsvSortByDate); // Take a handle to the folder entry CMsvEntry* parentEntry = CMsvEntry::NewL(*iSession,iCurrentMailBox,sort); CleanupStack::PushL(parentEntry); // A selection of all BT entries CMsvEntrySelection* entries = parentEntry->ChildrenL();//ChildrenWithMtmL(KUidMsgTypeBt); CleanupStack::PushL(entries); //Process all entries if(CurrItmIndex >= 0 && CurrItmIndex < iIDArray->Count()) { //Get entry CMsvEntry* btEntry = iSession->GetEntryL(iIDArray->At(CurrItmIndex).iEnt); CleanupStack::PushL(btEntry); //Then get entrys child CMsvEntrySelection* btChildren = btEntry->ChildrenL(); CleanupStack::PushL(btChildren); btEntry->SetEntryL(iIDArray->At(CurrItmIndex).iMsg); if (btEntry->HasStoreL()) { CMsvStore* store = btEntry->ReadStoreL(); CleanupStack::PushL(store); MMsvAttachmentManager& attMngr = store->AttachmentManagerL(); CMsvAttachment* attachment = attMngr.GetAttachmentInfoL(iIDArray->At(CurrItmIndex).iAtt); if(attachment) { fileName.Copy(attachment->AttachmentName()); delete attachment; attachment = NULL; TBool OkToSave(EFalse),SkipMe(EFalse); do { FullFilName.Zero(); StringLoader::Load(FullFilName,R_SH_STR_FILENAME); CAknTextQueryDialog* Dialog = CAknTextQueryDialog::NewL(fileName,CAknQueryDialog::ENoTone); Dialog->PrepareLC(R_ASK_NAME_DIALOG); Dialog->SetPromptL(FullFilName); if(Dialog->RunLD()) { FullFilName.Copy(aFolderName); FullFilName.Append(fileName); if(BaflUtils::FileExists(CEikonEnv::Static()->FsSession(),FullFilName)) { HBufC* TmpText = StringLoader::LoadLC(R_SH_STR_FILOVERRT); CAknQueryDialog* dlg = CAknQueryDialog::NewL(); if(dlg->ExecuteLD(R_QUERY,*TmpText)) { TInt Err = CEikonEnv::Static()->FsSession().Delete(FullFilName); if(Err == KErrNone) { OkToSave = ETrue; } else { iUtils.GetFileUtils().ShowFileErrorNoteL(FullFilName,Err); } } CleanupStack::PopAndDestroy(TmpText); } else { OkToSave = ETrue; } } else { SkipMe = ETrue; } }while(!SkipMe && !OkToSave); if(OkToSave) { delete iRFileCopier; iRFileCopier = NULL; iRFileCopier = CRFileCopier::NewL(*this,CEikonEnv::Static()->FsSession(),ETrue); RFile SourceFil(attMngr.GetAttachmentFileL(iIDArray->At(CurrItmIndex).iAtt)); iRFileCopier->StartCopyL(SourceFil,FullFilName); SourceFil.Close(); } } CleanupStack::PopAndDestroy(store); } CleanupStack::PopAndDestroy(2); } CleanupStack::PopAndDestroy(2); } }
EXPORT_C void CMsvTestUtils::FindChildrenL(TMsvId aFolderToTraverse, TBool aReplace, TBool aOtherFiles) { iFileCount=0; CDir* rfcFileList; // Loads the any test files into an EntryList iFs.GetDir(iRfc822Dir, KEntryAttNormal, ESortByName, rfcFileList); TMsvSelectionOrdering ordering; ordering.SetShowInvisibleEntries(ETrue); TMsvId entryId; if (iClientServer==EClientSide) { entryId=iMsvEntry->Entry().Id(); iMsvEntry->SetEntryL(aFolderToTraverse); iMsvEntry->SetSortTypeL(ordering); } else { entryId=iServerEntry->Entry().Id(); iServerEntry->SetEntry(aFolderToTraverse); iServerEntry->SetSort(ordering); } RFile file; TFileName filename(iLogsDir); filename.Append(KFileNameEntryStructure); // Print out Hierarchy - Save to file if (aReplace) { // replace both Entry_Structure.txt and Entry_RichTextBodies.txt TInt err1 = file.Replace(iFs, filename, EFileShareAny | EFileStreamText | EFileWrite); if (err1==KErrNotFound) // file does not exist - create it err1=file.Create(iFs, filename, EFileShareAny | EFileStreamText | EFileWrite); if (err1 == KErrNone) ListChildrenL(aReplace, aOtherFiles, file, *rfcFileList); } else { TInt err1 = file.Open(iFs, filename, EFileShareAny | EFileStreamText | EFileWrite); if (err1==KErrNotFound) file.Create(iFs, filename, EFileShareAny | EFileStreamText | EFileWrite); else if (err1 != KErrNone) User::Leave(err1); TInt position=1; User::LeaveIfError(file.Seek(ESeekEnd, position)); ListChildrenL(aReplace, aOtherFiles, file, *rfcFileList); } file.Close(); if (iClientServer==EClientSide) iMsvEntry->SetEntryL(entryId); else iServerEntry->SetEntry(entryId); delete rfcFileList; }
void CMtfTestActionUtilsSmsScripts::ReadSmsSettingsFromConfigurationFileL(CMtfTestCase& aTestCase, const TDesC& aSettingsFile, CSmsSettings& aSmsSettings) { CMtfTestActionUtilsConfigFileParser* scriptFileParser = CMtfTestActionUtilsConfigFileParser::NewL(aSettingsFile); CleanupStack::PushL(scriptFileParser); TPtrC stringPtr; TInt intValue; // Service Centre if(scriptFileParser->GetFieldAsString(KScriptItemSC, stringPtr) == KErrNone) { // get the addresses from the config file TLex detailsToParse(stringPtr); TPtrC scName; TPtrC scNumber; detailsToParse.SkipSpaceAndMark(); while(!detailsToParse.Eos()) { scName.Set(_L("Unknown")); // default SC name while(detailsToParse.Peek() != ';' && !detailsToParse.Eos()) // SCs' details separated by semi-colon { if(detailsToParse.Peek() == ',') // name and number separated by comma { // has a name specified scName.Set(detailsToParse.MarkedToken()); detailsToParse.Inc(); detailsToParse.SkipSpaceAndMark(); } else detailsToParse.Inc(); } scNumber.Set(detailsToParse.MarkedToken()); // add the address to the SCs list aSmsSettings.AddServiceCenterL(scName, scNumber); detailsToParse.Inc(); detailsToParse.SkipSpaceAndMark(); } } // Default Service Centre if(scriptFileParser->GetFieldAsInteger(KScriptItemDefaultSC, intValue) == KErrNone) { aSmsSettings.SetDefaultServiceCenter(intValue); } // Bearer if(scriptFileParser->GetFieldAsString(KScriptItemBearer, stringPtr) == KErrNone) { CSmsSettings::TMobileSmsBearer smsBearer = ObtainValueParameterL<CSmsSettings::TMobileSmsBearer>(aTestCase, stringPtr); aSmsSettings.SetSmsBearer(smsBearer); } // Encoding if(scriptFileParser->GetFieldAsString(KScriptItemEncoding, stringPtr) == KErrNone) { TSmsDataCodingScheme::TSmsAlphabet characterSet = ObtainValueParameterL<TSmsDataCodingScheme::TSmsAlphabet>(aTestCase, stringPtr); aSmsSettings.SetCharacterSet(characterSet); } // Delivery Report if(scriptFileParser->GetFieldAsString(KScriptItemDeliveryReport, stringPtr) == KErrNone) { if (stringPtr.CompareF(_L("NO")) == 0) { aSmsSettings.SetDeliveryReport(EFalse); } else if (stringPtr.CompareF(_L("YES")) == 0) { aSmsSettings.SetDeliveryReport(ETrue); } } // Reply quoted if(scriptFileParser->GetFieldAsString(KScriptItemReplyQuoted, stringPtr) == KErrNone) { if (stringPtr.CompareF(_L("NO")) == 0) { aSmsSettings.SetReplyQuoted(EFalse); } else if (stringPtr.CompareF(_L("YES")) == 0) { aSmsSettings.SetReplyQuoted(ETrue); } } // Description length if(scriptFileParser->GetFieldAsInteger(KScriptItemDescriptionLength, intValue) == KErrNone) { aSmsSettings.SetDescriptionLength(intValue); } // Can Concatenate if(scriptFileParser->GetFieldAsString(KScriptItemCanConcatenate, stringPtr) == KErrNone) { if (stringPtr.CompareF(_L("NO")) == 0) { aSmsSettings.SetCanConcatenate(EFalse); } else if (stringPtr.CompareF(_L("YES")) == 0) { aSmsSettings.SetCanConcatenate(ETrue); } } // Reply path if(scriptFileParser->GetFieldAsString(KScriptItemReplyPath, stringPtr) == KErrNone) { if (stringPtr.CompareF(_L("NO")) == 0) { aSmsSettings.SetReplyPath(EFalse); } else if (stringPtr.CompareF(_L("YES")) == 0) { aSmsSettings.SetReplyPath(ETrue); } } // Reject duplicate if(scriptFileParser->GetFieldAsString(KScriptItemRejectDuplicate, stringPtr) == KErrNone) { if (stringPtr.CompareF(_L("NO")) == 0) { aSmsSettings.SetRejectDuplicate(EFalse); } else if (stringPtr.CompareF(_L("YES")) == 0) { aSmsSettings.SetRejectDuplicate(ETrue); } } // Validity period, value is read in minutes if(scriptFileParser->GetFieldAsInteger(KScriptItemValidityPeriod, intValue) == KErrNone) { aSmsSettings.SetValidityPeriod(TTimeIntervalMinutes(intValue)); } // Delivery if(scriptFileParser->GetFieldAsString(KScriptItemDelivery, stringPtr) == KErrNone) { TSmsDelivery delivery = ObtainValueParameterL<TSmsDelivery>(aTestCase, stringPtr); aSmsSettings.SetDelivery(delivery); } // Status Report Handling if(scriptFileParser->GetFieldAsString(KScriptItemStatusReportHandling, stringPtr) == KErrNone) { CSmsSettings::TSmsReportHandling statusReportHandling = ObtainValueParameterL<CSmsSettings::TSmsReportHandling>(aTestCase, stringPtr); aSmsSettings.SetStatusReportHandling(statusReportHandling); } // Special Message Handling if(scriptFileParser->GetFieldAsString(KScriptItemSpecialMessageHandling, stringPtr) == KErrNone) { CSmsSettings::TSmsReportHandling specialMessageHandling = ObtainValueParameterL<CSmsSettings::TSmsReportHandling>(aTestCase, stringPtr); aSmsSettings.SetSpecialMessageHandling(specialMessageHandling); } // Commdb action if(scriptFileParser->GetFieldAsString(KScriptItemSmsCommdbAction, stringPtr) == KErrNone) { CSmsSettings::TSmsSettingsCommDbAction commdbAction = ObtainValueParameterL<CSmsSettings::TSmsSettingsCommDbAction>(aTestCase, stringPtr); aSmsSettings.SetCommDbAction(commdbAction); } // Sms Bearer Action if(scriptFileParser->GetFieldAsString(KScriptItemSmsBearerAction, stringPtr) == KErrNone) { CSmsSettings::TSmsSettingsCommDbAction smsBearerAction = ObtainValueParameterL<CSmsSettings::TSmsSettingsCommDbAction>(aTestCase, stringPtr); aSmsSettings.SetSmsBearerAction(smsBearerAction); } // Message Conversion if(scriptFileParser->GetFieldAsString(KScriptItemSmsMessageConversion, stringPtr) == KErrNone) { TSmsPIDConversion messageConversion = ObtainValueParameterL<TSmsPIDConversion>(aTestCase, stringPtr); aSmsSettings.SetMessageConversion(messageConversion); } // Vailidity Period Format if(scriptFileParser->GetFieldAsString(KScriptItemSmsValidityPeriodFormat, stringPtr) == KErrNone) { TSmsFirstOctet::TSmsValidityPeriodFormat valPeriodFormat = ObtainValueParameterL<TSmsFirstOctet::TSmsValidityPeriodFormat>(aTestCase, stringPtr); aSmsSettings.SetValidityPeriodFormat(valPeriodFormat); } // Class2 Folder if(scriptFileParser->GetFieldAsString(KScriptItemClass2Folder, stringPtr) == KErrNone) { // Try to find a folder with that name MDummySessionObserver obser; CMsvSession* session = CMsvSession::OpenSyncL(obser); CleanupStack::PushL(session); CMsvEntry* entry = CMsvEntry::NewL(*session, KMsvLocalServiceIndexEntryId, TMsvSelectionOrdering(KMsvGroupByStandardFolders||KMsvGroupByType,EMsvSortByNone)); CleanupStack::PushL(entry); entry->SetEntryL(KMsvLocalServiceIndexEntryId); // Search only the local folders TMsvSelectionOrdering order; order.SetShowInvisibleEntries(ETrue); entry->SetSortTypeL(order); CMsvEntrySelection* selection = entry->ChildrenL(); CleanupStack::PushL(selection); TBool found = EFalse; TInt count = selection->Count(); for (TInt i=0; i<count; i++) { entry->SetEntryL((*selection)[i]); if ((stringPtr.CompareF(entry->Entry().iDescription) == 0) || (stringPtr.CompareF(entry->Entry().iDetails) == 0)) { found = ETrue; break; } } TMsvId entryId = KMsvGlobalInBoxIndexEntryId; if (found) entryId = entry->Entry().Id(); else User::Leave(KErrNotFound); aSmsSettings.SetClass2Folder(entryId); CleanupStack::PopAndDestroy(3, session); // selection, entry, session } //Last Segment Delivery Report if(scriptFileParser->GetFieldAsString(KLastSegmentDeliveryReport, stringPtr) == KErrNone) { if (stringPtr.CompareF(_L("NO")) == 0) { aSmsSettings.SetLastSegmentDeliveryReport(EFalse); } else if (stringPtr.CompareF(_L("YES")) == 0) { aSmsSettings.SetLastSegmentDeliveryReport(ETrue); } } CleanupStack::PopAndDestroy(scriptFileParser); }
TInt CMsvTestUtils::DoNavigateMessageStoreL(TMsvId& aParent, TInt& aStart) { TMsvSelectionOrdering order; order.SetShowInvisibleEntries(ETrue); CMsvEntry* parent = CMsvEntry::NewL(*iMsvSession, aParent, order); CleanupStack::PushL(parent); iRTest.Printf(KMsvTestUtilsNewLine); TInt more = 0; const TInt KMax = 10; ShowChildrenL(*parent, aStart, more, KMax); iRTest.Printf(KMsvTestUtilsNewLine); iRTest.Printf(_L("Select a message or '.' (for parent) or 'N'ext or 'P'revious or e'X'it\n")); const TInt count = Min(KMax, parent->Count() - aStart); const TChar startChar = '0'; const TChar endChar = startChar + count - 1; const TChar key = iRTest.Getch(); TInt ret = KErrNotFound; if (key >= '0' && key <= endChar) { iRTest.Printf(KMsvTestUtilsNewLine); TMsvEntry entry((*parent)[key - startChar + aStart]); if (entry.Owner()) { aStart = 0; aParent = entry.Id(); } else { DisplayChildDetailsL(entry); } ret = KErrNone; } else if (key == '.') { aStart = 0; if (aParent != KMsvRootIndexEntryId) aParent = parent->Entry().Parent(); ret = KErrNone; } else if (key == 'n' || key == 'N') { if (more > 0) { aStart += KMax; } ret = KErrNone; } else if (key == 'p' || key == 'P') { if (aStart > 0) { aStart -= KMax; } ret = KErrNone; } else if (key == 'x' || key == 'X') { ret = KErrDied; } CleanupStack::PopAndDestroy(parent); return ret; }