BOOL CUploadTransferED2K::Request(MD4* pMD4) { BOOL bSame = ( m_bED2K && m_pED2K == *pMD4 ); Cleanup( ! bSame ); CSingleLock oLock( &Library.m_pSection, TRUE ); if ( CLibraryFile* pFile = LibraryMaps.LookupFileByED2K( pMD4, TRUE, TRUE ) ) { // Send comments if necessary if ( m_pClient ) m_pClient->SendCommentsPacket( pFile->m_nRating, pFile->m_sComments ); RequestComplete( pFile ); oLock.Unlock(); } else { oLock.Unlock(); if ( CDownload* pFile = Downloads.FindByED2K( pMD4, TRUE ) ) { RequestPartial( pFile ); } else { UploadQueues.Dequeue( this ); theApp.Message( MSG_ERROR, IDS_UPLOAD_FILENOTFOUND, (LPCTSTR)m_sAddress, (LPCTSTR)CED2K::HashToString( pMD4, TRUE ) ); CEDPacket* pReply = CEDPacket::New( ED2K_C2C_FILENOTFOUND ); pReply->Write( pMD4, sizeof(MD4) ); Send( pReply ); Close(); return FALSE; } } if ( UploadQueues.GetPosition( this, FALSE ) < 0 && ! UploadQueues.Enqueue( this ) ) { theApp.Message( MSG_ERROR, IDS_UPLOAD_BUSY_QUEUE, (LPCTSTR)m_sFileName, (LPCTSTR)m_sAddress, _T("ED2K") ); CEDPacket* pReply = CEDPacket::New( ED2K_C2C_FILENOTFOUND ); pReply->Write( pMD4, sizeof(MD4) ); Send( pReply ); Close(); return FALSE; } AllocateBaseFile(); theApp.Message( MSG_SYSTEM, IDS_UPLOAD_FILE, (LPCTSTR)m_sFileName, (LPCTSTR)m_sAddress ); m_nRanking = -1; return CheckRanking(); }
void CPosSession::OpenFromModuleIdL(const RMessage2& aMessage) { DEBUG_TRACE("EPositionerOpenModuleId", __LINE__) TPckgBuf<TPositionModuleId> moduleIdBuf; User::LeaveIfError(Global::Read(aMessage, KParamModuleIdOpen, moduleIdBuf)); CreateSubSessionL(moduleIdBuf(), EFalse, aMessage); RequestComplete(aMessage, KErrNone); }
bool Cancel( Request& inReq) { if (inReq.mReqType == kReqTypeNone) { return false; // Not in flight, or in the queue. } Remove(inReq); RequestComplete(inReq, kErrorCancel, 0, 0); return true; }
void CPosSession::OpenPositionerFromCriteriaL(const RMessage2& aMessage) { DEBUG_TRACE("EPositionerOpenCriteria", __LINE__) // Read Criteria TPckgBuf<TPositionCriteria> criteria; User::LeaveIfError(Global::Read(aMessage, KParamCriteria, criteria)); CreateSubSessionL(KPosStrategyModule, ETrue, aMessage); RequestComplete(aMessage, KErrNone); }
EXPORT_C void CDosExtensionBase::CompleteRequest(const RMessage2& aMessage, TInt aError, TAny* aPar, TInt aParLength, TBool aParameterModified) const { // Write over client's parameters if ((aError == KErrNone) && aParameterModified) { TPtrC8 ptr(static_cast<TUint8*>(aPar), aParLength); aError = aMessage.Write(1, ptr); } RequestComplete(aMessage, aError); }
void CPosSession::GetNumModulesL(const RMessage2& aMessage) { DEBUG_TRACE("EPositionServerGetNumModules", __LINE__) CPosModuleIdList* moduleList = iModuleSettings.ModuleIdListL(); TInt num = moduleList->Count(); delete moduleList; TPckg<TUint> numPackage(num); User::LeaveIfError(Global::Write(aMessage, KParamNumModules, numPackage)); RequestComplete(aMessage, KErrNone); }
void CPosSession::ClosePositioner(const RMessage2& aMessage) { iLocMonitorReqHandlerHub.NotifySubSessionClosed(aMessage); TInt handle = aMessage.Int3(); iSubSessionRegistry->CloseSubSession(handle); RequestComplete(aMessage, KErrNone); DEBUG_TRACE("EPositionerClose", __LINE__) }
void CReconnectRequest::StartRequest() { TInt testNo = REINTERPRET_CAST(TInt, iAgent); switch (testNo) { case 300: case 900: case 1000: RequestComplete(KErrNone); break; case 400: RequestComplete(KErrDiskFull); break; case 800: iAsyncCb->CallBack(); break; default: User::Invariant(); } }
BOOL CUploadTransferDC::RequestTigerTree(CLibraryFile* pFile, QWORD nOffset, QWORD nLength) { m_pXML.Clear(); if ( ! RequestComplete( pFile ) ) { ASSERT( FALSE ); return FALSE; } theApp.Message( MSG_INFO, IDS_UPLOAD_TIGER_SEND, (LPCTSTR)m_sName, (LPCTSTR)m_sAddress ); CAutoPtr< CTigerTree > pTigerTree( pFile->GetTigerTree() ); if ( ! pTigerTree ) return FALSE; BYTE* pSerialTree = NULL; DWORD nSerialTree = 0; if ( ! pTigerTree->ToBytesLevel1( &pSerialTree, &nSerialTree ) ) return FALSE; if ( nOffset >= nSerialTree ) nLength = SIZE_UNKNOWN; else nLength = min( ( ( nLength == SIZE_UNKNOWN ) ? nSerialTree : nLength ), nSerialTree - nOffset ); if ( nLength > nSerialTree || nOffset + nLength > nSerialTree ) { GlobalFree( pSerialTree ); return FALSE; } CString strAnswer; strAnswer.Format( _T("$ADCSND tthl TTH/%s %I64u %I64u|"), m_oTiger.toString(), nOffset, nLength ); m_pClient->SendCommand( strAnswer ); m_pClient->Write( pSerialTree + nOffset, nLength ); // Start uploading m_nOffset = nOffset; m_nLength = nLength; m_nPosition = 0; StartSending( upsTigerTree ); GlobalFree( pSerialTree ); return TRUE; }
/** Send all the emails to the server @param aSendFiles Files to send @param aClientStatus Client status to be completed */ void CImSmtpSession::SendFilesL(CMsgImOutboxSend& aSendFiles, TRequestStatus& aClientStatus) { __ASSERT_DEBUG(iSocketIsConnected, gPanic(EImsmSocketNotConnected1)); TInt error = aSendFiles.NextFile(); if (iSocketIsConnected && error == KErrNone) { iSendFiles = &aSendFiles; iState = ESendingImail; DoStateL(); Queue(aClientStatus); } else if(error == KErrNotFound) { // Nothing to do so just complete the caller RequestComplete(aClientStatus, KErrNotFound); } else { // Nothing to do so just complete the caller RequestComplete(aClientStatus, KErrNone); } }
/** Quit from the server @param aClientStatus Client status to be completed */ void CImSmtpSession::QuitL(TRequestStatus& aClientStatus) { __ASSERT_DEBUG(iSocketIsConnected, gPanic(EImsmSocketNotConnected2)); if (iSocketIsConnected) { iState = EClosingSmtp; DoStateL(); Queue(aClientStatus); } else { // Nothing to do so just complete the caller RequestComplete(aClientStatus, KErrNone); } }
void CPosSession::HandleCancelAsyncRequestL(const RMessage2& aMessage) { switch (aMessage.Int0()) { case KServerNotifyModuleStatusEventSymbian: case KServerNotifyModuleStatusEventVariant: case ELbsNotifyModuleStatusEvent: // TODO Verify NotifyModuleStatusEventCancelL(aMessage); break; case ELbsEmptyLastKnownPositionStore: EmptyLastKnownPositionStoreCancelL(aMessage); // TODO Verify default: RequestComplete(aMessage, KErrNotSupported); break; } }
void CPosSession::GetModuleInfoByIndexL(const RMessage2& aMessage) { DEBUG_TRACE("EPositionServerGetModuleInfoByIndex in", __LINE__) // module index TInt modIndex = aMessage.Int0(); CPosModuleIdList* moduleIdList = iModuleSettings.ModuleIdListL(); CleanupStack::PushL( moduleIdList ); if (modIndex >= moduleIdList->Count() || modIndex < 0) { User::Leave(KErrNotFound); } TPositionModuleId moduleId = (*moduleIdList)[modIndex]; // module info HBufC8* buffer = Global::CopyClientBuffer8LC(aMessage, KParamModuleInfo); TPositionModuleInfoBase* moduleInfoBase = reinterpret_cast<TPositionModuleInfoBase*>( const_cast<TUint8*>(buffer->Ptr())); Global::ValidatePositionClassBufferL(*moduleInfoBase, buffer->Des()); // TPositionModuleInfo is the only class supported by CPosModules Global::ValidatePositionClassTypeL(*moduleInfoBase, EPositionModuleInfoClass); DEBUG_TRACE("Buffer validation done", __LINE__) CleanupStack::PopAndDestroy(2, moduleIdList); // TPositionModuleInfo contains descriptor. If it is corrupt // (malicious client) then writing to this will panic server // Local instance of TPositionModuleInfo is created to be sure // that module name descriptor is not corrupt TPositionModuleInfo modInfo; iModuleSettings.GetModuleInfoL(moduleId, modInfo); TPckg<TPositionModuleInfo> modInfoPack(modInfo); User::LeaveIfError(Global::Write(aMessage, KParamModuleInfo, modInfoPack)); RequestComplete(aMessage, KErrNone); DEBUG_TRACE("EPositionServerGetModuleInfoByIndex out", __LINE__) }
/** Connect the session to the server @param aClientStatus Client status to be completed */ void CImSmtpSession::ConnectL(TRequestStatus& aClientStatus) { __ASSERT_DEBUG(!iSocketIsConnected, gPanic(EImsmSocketAlreadyConnected)); if (!iSocketIsConnected) { if(iSettings.SecureSockets()) iThisSession = ESecureSession; // if the user has chosen to use TLS then we have to use ESMTP+TLS else if(iSettings.SMTPAuth()) iThisSession = EEnhancedSmtpSession; // if the user has chosen to use AUTH, when we have to use ESMTP else iThisSession = ESmtpSession; // use SMTP session for now iCompleted = KErrNone; iState = EConnectingToSmtp; // Initialise to 1st state of state machine DoStateL(); // Here we go... Queue(aClientStatus); } else { // Nothing to do so just complete the caller RequestComplete(aClientStatus, KErrNone); } }
void CIacSettingsParser::RunL() { TInt eCode = iStatus.Int(); if(eCode==KErrNone) { switch(iState) { case EParseSms: ChangeStateL(ECheckData); return; case ECheckData: if(++iCurrentSettingsCtr < iParsedFieldCollections->Count()) { CheckMandatoryDataL(); SetActive(); RequestComplete(iStatus, KErrNone); return; } else { // Storing parsed data array as a new stream within the CMsvStore // associated with the Msg Entry StoreParsedDataL(); iSmsParsed=ETrue; } break; case ESetParsersData: ChangeStateL(EProcessSms); return; case EProcessSms: if(eCode == KErrNone) { if(++iCurrentSettingsCtr < iParsedFieldCollections->Count()) { // set connections preferences flag TSmsType currentType = (*iParsedFieldCollections)[iCurrentSettingsCtr-1]->MessageType(); if(currentType==EBasicIAP || currentType== EExtGprsSettings || currentType== EExtendedIAP) { if(iConnectionPreference==EIacpAttempCreateAsFirstRank) iConnectionPreference = EIacpAttempCreateAsSecondRank; else iConnectionPreference = EIacpDoNotCreatePreference; } // If IAP settings are found, store a ref to them if(currentType== EBasicIAP || currentType== EExtendedIAP) { iDefaultIAP = iIspParser->IapEntryId(); // If Mail settings have been found previously, associate mail with IAP if(iDefaultMail) { iMailParser->AssociateIAPWithMailL(iEntry,iDefaultIAP); } } // If Mail settings are found, set a flag if(currentType== EBasicMail || currentType== EExtendedMail) { iDefaultMail = 1; // If IAP settings have ben found previously, associate mail with IAP if(iDefaultIAP) { iMailParser->AssociateIAPWithMailL(iEntry,iDefaultIAP); } } SetParsersDataL(); iState = ESetParsersData; SetActive(); RequestComplete(iStatus,KErrNone); return; } else eCode = CompleteMessage(); } TSmsType currentType = (*iParsedFieldCollections)[iCurrentSettingsCtr-1]->MessageType(); // If IAP settings are found, store a ref to them if(currentType== EBasicIAP || currentType== EExtendedIAP) { iDefaultIAP = iIspParser->IapEntryId(); // If Mail settings have been found previously, associate mail with IAP if(iDefaultMail) { iMailParser->AssociateIAPWithMailL(iEntry,iDefaultIAP); } } // If Mail settings are found, set a flag if(currentType== EBasicMail || currentType== EExtendedMail) { iDefaultMail = 1; // If IAP settings have ben found previously, associate mail with IAP if(iDefaultIAP) { iMailParser->AssociateIAPWithMailL(iEntry,iDefaultIAP); } } break; } } User::RequestComplete(iReport,eCode); }
BOOL CHTTPClient::ProcessData(unsigned char *lpData, int iLen) { char *szWork; char *lpStartOfContent = (char *) lpData; int iHeaderLen; int iIndex; char szLen[12]; char *lpWork; if (!bHeader) { dwFirstByte = ::XPlatGetMilliseconds(); szWork = strstr((char *) lpData, "\r\n\r\n"); if (szWork) { bHeader = TRUE; iHeaderLen = (szWork - (char *) lpData) + 4; cHeader.replace(cHeader.length(), iHeaderLen, (char *) lpData, iHeaderLen); ParseHeader(); if (bHeadRequest || !strcmp(szStatus, "100") || !strcmp(szStatus, "204") || !strcmp(szStatus, "304")) { // Only requested header or it's a no data reply so we're done RequestComplete(); return(TRUE); }; lpStartOfContent = szWork + 4; // Get content length if present iIndex = cHeaderLwr.find(CONTENT_LENGTH); if ((unsigned) iIndex != string::npos) { strncpy(szLen, &(cHeader[iIndex]) + strlen(CONTENT_LENGTH), sizeof(szLen)); szLen[sizeof(szLen) - 1] = '\0'; lpWork = szLen; while(*lpWork && !isdigit(*lpWork)) { *lpWork = ' '; lpWork++; }; while(*lpWork && isdigit(*lpWork)) lpWork++; if (*lpWork) *lpWork = '\0'; lContentLength = atol(szLen); if (!lContentLength) { // Content length of zero, we're done RequestComplete(); }; }; lReceivedLength = iLen - iHeaderLen; if (lReceivedLength > 0) { // Save any content following the header cContent.replace(0, lReceivedLength, lpStartOfContent, lReceivedLength); if (lContentLength && (lReceivedLength >= lContentLength)) { RequestComplete(); }; }; return(TRUE); } else { // Header incomplete cHeader += (char *) lpData; return(TRUE); }; }; // Have header,continue to get content cContent.replace(cContent.length(), iLen, lpStartOfContent, iLen); lReceivedLength += iLen; if (lContentLength && (lReceivedLength >= lContentLength)) { RequestComplete(); }; return(TRUE); };
void CPosSession::OpenDefaultPositionerL(const RMessage2& aMessage) { DEBUG_TRACE("EPositionerOpen(Default)", __LINE__) CreateSubSessionL(KPosDefaultModule, ETrue, aMessage); RequestComplete(aMessage, KErrNone); }
BOOL CUploadTransferDC::RequestFile(CLibraryFile* pFile, QWORD nOffset, QWORD nLength) { m_pXML.Clear(); if ( ! RequestComplete( pFile ) ) { ASSERT( FALSE ); return FALSE; } if ( ! UploadQueues.CanUpload( PROTOCOL_DC, pFile, FALSE ) ) { theApp.Message( MSG_ERROR, IDS_UPLOAD_FILENOTFOUND, (LPCTSTR)m_sAddress, (LPCTSTR)m_sName ); m_pClient->SendCommand( FILE_NOT_AVAILABLE ); return TRUE; } m_nOffset = nOffset; if ( m_nOffset >= m_nSize ) m_nLength = SIZE_UNKNOWN; else m_nLength = min( ( ( nLength == SIZE_UNKNOWN ) ? m_nSize : nLength ), m_nSize - m_nOffset ); m_nPosition = 0; if ( m_nLength > m_nSize || m_nOffset + m_nLength > m_nSize ) { theApp.Message( MSG_ERROR, IDS_UPLOAD_BAD_RANGE, (LPCTSTR)m_sAddress, (LPCTSTR)m_sName ); m_pClient->SendCommand( FILE_NOT_AVAILABLE ); return TRUE; } AllocateBaseFile(); if ( m_bStopTransfer ) { m_tRotateTime = 0; m_bStopTransfer = FALSE; CUploadQueue* pQueue = m_pQueue; if ( pQueue ) pQueue->Dequeue( this ); } int nPosition = UploadQueues.GetPosition( this, TRUE ); if ( nPosition < 0 && UploadQueues.Enqueue( this ) ) { nPosition = UploadQueues.GetPosition( this, TRUE ); } if ( nPosition == 0 ) { // Ready to send if ( m_bGet ) return TRUE; // Wait for $Send return SendFile(); } else if ( nPosition > 0 ) { // Queued theApp.Message( MSG_INFO, IDS_UPLOAD_QUEUED, (LPCTSTR)m_sName, (LPCTSTR)m_sAddress, nPosition, m_pQueue->GetQueuedCount(), (LPCTSTR)m_pQueue->m_sName ); CString strQueued; strQueued.Format( UPLOAD_QUEUE, nPosition ); m_pClient->SendCommand( strQueued ); StartSending( upsPreQueue ); m_tRankingCheck = GetTickCount(); return TRUE; } else { // Unable to queue anywhere UploadQueues.Dequeue( this ); ASSERT( m_pQueue == NULL ); theApp.Message( MSG_ERROR, IDS_UPLOAD_BUSY_QUEUE, (LPCTSTR)m_sName, (LPCTSTR)m_sAddress, (LPCTSTR)m_sUserAgent ); m_pClient->SendCommand( UPLOAD_BUSY ); return TRUE; } }
void QCDiskQueue::Queue::Process( Request& inReq, int* inFdPtr, struct iovec* inIoVecPtr) { QCASSERT(mMutex.IsOwned()); QCASSERT(mIoVecPerThreadCount > 0 && mBufferPoolPtr); QCRTASSERT(//mFileInfoPtr[inReq.mFileIdx].mLastBlockIdx >= 0 && inReq.mBlockIdx + inReq.mBufferCount <= uint64_t(mFileInfoPtr[inReq.mFileIdx].mLastBlockIdx)); const int theFd = inFdPtr[inReq.mFileIdx]; char** const theBufPtr = GetBuffersPtr(inReq); const off_t theOffset = (off_t)inReq.mBlockIdx * mBlockSize; const bool theReadFlag = inReq.mReqType == kReqTypeRead; const int64_t theAllocSize = (inReq.mReqType == kReqTypeWrite && mFileInfoPtr[inReq.mFileIdx].mSpaceAllocPendingFlag) ? mFileInfoPtr[inReq.mFileIdx].mLastBlockIdx * mBlockSize : 0; QCASSERT((theReadFlag || inReq.mReqType == kReqTypeWrite) && theFd >= 0); inReq.mInFlightFlag = true; QCStMutexUnlocker theUnlock(mMutex); Error theError = kErrorNone; int theSysError = 0; if (theAllocSize > 0) { // Theoretically space allocation can be simultaneously invoked from // more than one io thread. This is to ensure that allocation always // happen before the first write. // OS can deal with concurrent allocations. const int64_t theResv = QCUtils::ReserveFileSpace(theFd, theAllocSize); if (theResv < 0) { theError = kErrorSpaceAlloc; theSysError = int(-theResv); } if (theResv > 0 && ftruncate(theFd, theAllocSize)) { theError = kErrorSpaceAlloc; theSysError = errno; } if (theError == kErrorNone) { QCStMutexLocker theLock(mMutex); mFileInfoPtr[inReq.mFileIdx].mSpaceAllocPendingFlag = false; } } const bool theGetBufFlag = ! theBufPtr[0]; if (theError == kErrorNone && theGetBufFlag) { QCASSERT(theReadFlag); BuffersIterator theIt(*this, inReq, inReq.mBufferCount); // Allocate buffers for read request. if (! mBufferPoolPtr->Get(theIt, inReq.mBufferCount, QCIoBufferPool::kRefillReqIdRead)) { theError = kErrorOutOfBuffers; } } if (theError == kErrorNone && lseek(theFd, theOffset, SEEK_SET) != theOffset) { theError = kErrorSeek; theSysError = errno; } BuffersIterator theItr(*this, inReq, inReq.mBufferCount); int theBufCnt = inReq.mBufferCount; int64_t theIoByteCnt = 0; while (theBufCnt > 0 && theError == kErrorNone) { ssize_t theIoBytes = 0; int theIoVecCnt = 0; char* thePtr; while (theIoVecCnt < mIoVecPerThreadCount && (thePtr = theItr.Get())) { inIoVecPtr[theIoVecCnt ].iov_base = thePtr; inIoVecPtr[theIoVecCnt++].iov_len = mBlockSize; theIoBytes += mBlockSize; theBufCnt--; } QCRTASSERT(theIoVecCnt > 0); if (theReadFlag) { const ssize_t theNRd = readv(theFd, inIoVecPtr, theIoVecCnt); if (theNRd < 0) { theError = kErrorRead; theSysError = theNRd < 0 ? errno : 0; break; } theIoByteCnt += theNRd; if (theNRd < theIoBytes) { if (theGetBufFlag) { // Short read -- release extra buffers. mBufferPoolPtr->Put(theItr, theBufCnt); inReq.mBufferCount -= theBufCnt; int i = (theNRd + mBlockSize - 1) / mBlockSize; inReq.mBufferCount -= theIoVecCnt - i; while (i < theIoVecCnt) { mBufferPoolPtr->Put((char*)inIoVecPtr[i++].iov_base); } } break; } } else { const ssize_t theNWr = writev(theFd, inIoVecPtr, theIoVecCnt); if (theNWr > 0) { theIoByteCnt += theNWr; } if (theNWr != theIoBytes) { theError = kErrorWrite; theSysError = errno; break; } } } if (theGetBufFlag && theError != kErrorNone && theBufPtr[0]) { BuffersIterator theIt(*this, inReq, inReq.mBufferCount); mBufferPoolPtr->Put(theIt, inReq.mBufferCount); theBufPtr[0] = 0; } theUnlock.Lock(); RequestComplete(inReq, theError, theSysError, theIoByteCnt, theGetBufFlag); }
void CReconnectRequest::MDPOReconnectComplete(TInt aError) { RequestComplete(aError); }
void CImSmtpSession::SendFileL() { // Start the 'file mailer' object __ASSERT_DEBUG(!iSmtpFile,gPanic(EImsmSmtpFileObjectAlreadyExists)); // log the info of the message to be sent if (iLogMessage) iLogMessage->Reset(); // Update the header info for this message.. CImHeader* header = CImHeader::NewLC(); CMsvStore* store = iServerEntry.EditStoreL(); CleanupStack::PushL(store); header->RestoreL(*store); TBool isBccRcpt = EFalse; CDesCArray* rcptArray = NULL; TBool sendBccNow = iToRcptHeaderUpdated; if(!iToRcptHeaderUpdated) { // Set the new info... //set from address HBufC* formatedAddress = CreateFormattedAddressLC(iSettings.EmailAddress(), iSettings.EmailAlias());//Format the address fields header->SetFromL(*formatedAddress); CleanupStack::PopAndDestroy(formatedAddress); formatedAddress = NULL; // set ReceiptAddress if one exists in the settings if( header->ReceiptAddress().Length() == 0 && iSettings.ReceiptAddress().Length() > 0 ) { formatedAddress=CreateFormattedAddressLC(iSettings.ReceiptAddress(),iSettings.EmailAlias());//Format the address fields header->SetReceiptAddressL(*formatedAddress); CleanupStack::PopAndDestroy(formatedAddress); formatedAddress = NULL; } if(header->ToRecipients().Count()==0 && header->CcRecipients().Count()==0) { sendBccNow=ETrue; } // ReplyToAddress if ((header->ReplyTo().Length() == 0 || header->ReplyTo() == iSettings.ReplyToAddress()) && (iSettings.ReplyToAddress().Length() > 0)) { formatedAddress= CreateFormattedAddressLC(iSettings.ReplyToAddress(),iSettings.EmailAlias());//Format the address fields header->SetReplyToL(*formatedAddress); CleanupStack::PopAndDestroy(formatedAddress); formatedAddress = NULL; } //make a copy of 'Bcc' recipients then remove from Msg header rcptArray= &(header->BccRecipients()); if (iSettings.SendCopyToSelf()==ESendCopyAsBccRecipient) { if ( header->ReceiptAddress().Length() ) rcptArray->AppendL(header->ReceiptAddress()); else if ( header->ReplyTo().Length() ) rcptArray->AppendL(header->ReplyTo()); } if(rcptArray->Count() > 0) { iBccRcptFound=ETrue; // 'Bcc' recipients exists iBccRcptIndex=0; //reset the counter iFinishedWithBccRcpts=EFalse; iSendFiles->ResetBccRcptArrayL(); TInt numberRcpts = rcptArray->Count(); if(numberRcpts) { iSendFiles->BccRcptArray().AppendL((*rcptArray)[0]); CDesCArray& tempArr = iSendFiles->BccRcptArray(); for(TInt counter=1; counter<numberRcpts; counter++) { TInt aPos = 0; tempArr.Find((*rcptArray)[counter],aPos,ECmpFolded16); if(aPos > 0) iSendFiles->BccRcptArray().AppendL((*rcptArray)[counter]); } } rcptArray->Reset(); } iToRcptHeaderUpdated=ETrue; isBccRcpt=EFalse; } // Reset the number of Sent Messages, if all previous messages have been sent if (iNumMsgsSent >= iNumMsgsToSend) { iNumMsgsSent = 0; } // Calc the num of messages we're sending. If there is a To or CC, // recipient then there will be a message sent if(header->ToRecipients().Count()>0 || header->CcRecipients().Count()>0) iNumMsgsToSend = 1; else iNumMsgsToSend = 0; // If there are BCC recipients, then we will be sending a message to each if (iBccRcptFound) iNumMsgsToSend += iSendFiles->BccRcptArray().Count(); // Make sure there are recipients to send to. __ASSERT_ALWAYS(iNumMsgsToSend,gPanic(EImsmZeroRecipientsInMessage)); // sending Msg to 'Bcc' recipients so update header if (sendBccNow && iBccRcptFound) { rcptArray= &(header->BccRecipients()); rcptArray->Reset(); header->BccRecipients().AppendL(iSendFiles->BccRcptArray()[iBccRcptIndex]); ++iBccRcptIndex;//for the next recipient if(iBccRcptIndex < iSendFiles->BccRcptArray().Count()) iFinishedWithBccRcpts=EFalse; else iFinishedWithBccRcpts=ETrue; isBccRcpt=ETrue; } header->StoreL(*store); store->CommitL(); if (iLogMessage) { iLogMessage->LogEvent().SetEventType(KLogMailEventTypeUid); if ((header->ToRecipients().Count() + header->CcRecipients().Count() + header->BccRecipients().Count()) > 1) // If there are multiple recipients then set the recipient to 'multiple' { TBuf<KLogMaxSharedStringLength> multipleRecipientsString; iLogMessage->GetString(multipleRecipientsString, R_LOG_REMOTE_MULTIPLE); iLogMessage->LogEvent().SetRemoteParty(multipleRecipientsString); } else // If there is only one recipient then set the recipient name { if (header->ToRecipients().Count()) iLogMessage->LogEvent().SetRemoteParty(header->ToRecipients()[0]); else if (header->CcRecipients().Count()) iLogMessage->LogEvent().SetRemoteParty(header->CcRecipients()[0]); else if (header->BccRecipients().Count()) iLogMessage->LogEvent().SetRemoteParty(header->BccRecipients()[0]); } iLogMessage->LogEvent().SetSubject(header->Subject()); TBuf<KLogMaxSharedStringLength> outString; iLogMessage->GetString(outString, R_LOG_DIR_OUT); iLogMessage->LogEvent().SetDirection(outString); iLogMessage->LogEvent().SetLink(iServerEntry.Entry().Id()); } CleanupStack::PopAndDestroy(2, header); iTimeNow.UniversalTime(); // Set time/date of sending this message file if (iLogMessage) iLogMessage->LogEvent().SetTime(iTimeNow); TRAPD(error,iSmtpFile = CImSmtpFile::NewL( *iSocket, iServerEntry, iTimeNow, iSmtpBuffer, iSettings, isBccRcpt)); // Create the file mailing object if(error == KErrNone) { // If this is the first message to send, then calc the total bytes to send if (iNumMsgsSent == 0) { iTotalBytesToSend = iSmtpFile->TotalMsgSizeL() * iNumMsgsToSend; } // Tell the file how many bytes it will be sending. This is just a // rough estimate for progress iSmtpFile->SetBytesToSend(iTotalBytesToSend/iNumMsgsToSend); // Increment the number of messages sent ++iNumMsgsSent; iSmtpFile->StartL(iStatus); // start sending the message MOBILITY_TEST_MTM_STATE(iServiceId, KMobilityTestMtmStateSmtpSendFile); } else { iCompleted=error; RequestComplete(iStatus,0-error); // Failed to create File object, but don't want to stop session prematurely, so negate error code } }