// --------------------------------------------------------- // GetOutboxEntries() // Outgoing Pending message/messages // --------------------------------------------------------- TInt MsgStoreHandler::GetOutboxEntriesL(MsgInfo& aFailedIndicatorData, MsgInfo& aPendingIndicatorData) { CMsvEntry* rootEntry = iMsvSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId); CMsvEntrySelection* messages = rootEntry->ChildrenL(); TInt failedMessageCount = 0; TInt pendingMessageCount = 0; for (TInt i = 0; i < messages->Count(); ++i) { TMsvEntry entry = rootEntry->ChildDataL(messages->At(i)); if ((entry.iMtm != KSenduiMtmSmsUid) && (entry.iMtm != KSenduiMtmMmsUid)) { continue; } if (entry.SendingState() == KMsvSendStateFailed) { ++failedMessageCount; } else { ++pendingMessageCount; } if (entry.SendingState() == KMsvSendStateFailed) { ProcessIndicatorDataL(entry.Id(), aFailedIndicatorData); } else { ProcessIndicatorDataL(entry.Id(), aPendingIndicatorData); } } aFailedIndicatorData.mFromSingle = (failedMessageCount > 1) ? false : true; aPendingIndicatorData.mFromSingle = (pendingMessageCount > 1) ? false : true; aFailedIndicatorData.mIndicatorType = FailedIndicatorPlugin; aPendingIndicatorData.mIndicatorType = PendingIndicatorPlugin; aFailedIndicatorData.mMsgCount = failedMessageCount; aPendingIndicatorData.mMsgCount = pendingMessageCount; return KErrNone; }
void CMsvSendExe::AddTaskL(const TMsvSchedulePackage& aPackage) { CMsvEntry* cEntry = NULL; TRAPD(err, cEntry = iSession->GetEntryL(aPackage.iId)); if (err != KErrNotFound) { User::LeaveIfError(err); CleanupStack::PushL(cEntry); TMsvEntry entry = cEntry->Entry(); const TInt sendState = entry.SendingState(); //Only send the message if sending state is Scheduled or Resend. if (entry.Scheduled() && (sendState == KMsvSendStateScheduled || sendState == KMsvSendStateResend)) { entry.SetSendingState(KMsvSendStateWaiting); // Fix for DEF000924: Need to be able to send/cancel an sms while another is being sent if (entry.iServiceId == KMsvLocalServiceIndexEntryId && entry.iRelatedId != KMsvNullIndexEntryId) { SCHSENDLOG( FLog(iFileName, _L("Changing service from %x to %x"), entry.iServiceId, entry.iRelatedId)); entry.iServiceId = entry.iRelatedId; } else { SCHSENDLOG( FLog(iFileName, _L("Not changing service from %x (related=%x)"), entry.iServiceId, entry.iRelatedId)); } // End of fix cEntry->ChangeL(entry); AddTaskL(aPackage, entry.iMtm); SCHSENDLOG(FLog(iFileName, _L("\t\tMsg=%d [Mtm=%d SendState=%d]"), aPackage.iId, entry.iMtm.iUid, entry.SendingState())); } else { SCHSENDLOG(FLog(iFileName, _L("\t\tIGNORING Msg=%d (Mtm=%d SendState=%d Scheduled=%d)"), aPackage.iId, entry.iMtm.iUid, sendState, entry.Scheduled())); } CleanupStack::PopAndDestroy(cEntry); } else { SCHSENDLOG(FLog(iFileName, _L("\t\tIGNORING Msg=%d: NOT FOUND"), aPackage.iId)); } }
void CSmsCancelTest::CancelIfSendingL(const CMsvEntrySelection& aSelection) { const TInt count = aSelection.Count(); for (TInt i = 0; i < count; i++) { TRAPD(err, iSmsTest.SetEntryL(aSelection[i])); if (!err) { TMsvEntry entry = iSmsTest.Entry(); if (entry.SendingState() == KMsvSendStateSending) { if (iOperation) { iOperation->Cancel(); return; } else { entry.SetSendingState(KMsvSendStateSuspended); TRAP(err, iSmsTest.ChangeEntryL(entry)); //ignore error if (err) { iSmsTest.Printf(_L("Error Cancelling Entry %d: On ChangeEntryL()\n"), aSelection[i]); } //end if } //end if } //end if } else { iSmsTest.Printf(_L("Error Cancelling Entry %d: On SetEntryL()\n"), aSelection[i]); } } }
void CMsvSendExe::DoResheduleOnErrorL(RScheduler& aScheduler, const CMsvEntrySelection& aSelection, const TMsvSchedulePackage& aPackage, TInt aError, TSchedulerItemRef& aRef, TInt& aCount, TTime& aStartTime) { SCHSENDLOG(FLog(iFileName, _L("\tDoRescheduleOnError [aError=%d]"), aError)); CMsvScheduleSettings* settings = CMsvScheduleSettings::NewL(); CleanupStack::PushL(settings); TMsvSchedulePackage package(aPackage); TInt selCount = aSelection.Count(); TTaskInfo info; TInt err = KErrNone; //Schedule each message while (selCount--) { const TMsvId id = aSelection[selCount]; TBool scheduleMessage = ETrue; CMsvEntry* cEntry = NULL; TMsvEntry entry; if (iSession != NULL) TRAP(err, cEntry = iSession->GetEntryL(id)); SCHSENDLOG(FLog(iFileName, _L("\t\tScheduling Task [Id=%d Err=%d iSession=0x%X cEntry=0x%X]..."), id, err, iSession, cEntry)); if (cEntry != NULL) { CleanupStack::PushL(cEntry); entry = cEntry->Entry(); switch (entry.SendingState()) { case KMsvSendStateWaiting: case KMsvSendStateScheduled: case KMsvSendStateResend: scheduleMessage = ETrue; break; case KMsvSendStateFailed: case KMsvSendStateSent: case KMsvSendStateSuspended: default: scheduleMessage = EFalse; SCHSENDLOG(FLog(iFileName, _L("\t\tNot Scheduled Task [Id=%d State=%d Err=%d]"), id, entry.SendingState(), entry.iError)); break; } } //end if if (scheduleMessage) { if (aRef.iHandle == KErrNotFound) { //Find or create the schedule if (cEntry != NULL) { TRAP(err, RestoreScheduleSettingsL(entry.iServiceId, entry.iMtm, *settings)); //use default if err != KErrNone SCHSENDLOG(FLog(iFileName, _L("\t\tRestoreScheduleSettings [Err=%d]"), err)); } CMsvScheduleSend::ConnectAndRegisterL(aScheduler, *settings); if (FindorCreateScheduleL(aScheduler, aStartTime, *settings, aRef)) aCount++; User::LeaveIfError(aScheduler.DisableSchedule(aRef.iHandle)); } //Schedule the message package.iId = id; CMsvScheduleSend::ScheduleEntryL(aScheduler, aRef, package, info); SCHSENDLOG(FLog(iFileName, _L("\t\tScheduleEntryL [Id=%d Task=%d]"), id, info.iTaskId)); if (cEntry != NULL) { //Update the message entry.iError = aError; TRAP(err, UpdateEntryL(*cEntry, entry, aRef, info, aStartTime)); SCHSENDLOG(FLog(iFileName, _L("\t\tEntry updated [Err=%d]"), err)); } aCount++; SCHSENDLOG(FLog(iFileName, _L("\t\tScheduled Task Complete [Id=%d Task=%d]"), id, info.iTaskId)); } if (cEntry) CleanupStack::PopAndDestroy(cEntry); } //end while CleanupStack::PopAndDestroy(settings); }
void CPigeonServerMtm::DoStartCommandL(CMsvEntrySelection& aSelection, TSchSendTestOperation aCommand, const TDesC8& aParameter, TRequestStatus& aStatus) { if(iHeapFailure) __UHEAP_FAILNEXT(iNextFailure++); else __UHEAP_RESET; TMsvSchedulePackage package; package.iCommandId = ESendScheduledL; package.iParameter = aParameter; switch(aCommand) { case EOpFail: { TPckgC<TInt> pkg(0); pkg.Set(aParameter); User::Leave(pkg()); } break; case EScheduleOpFail: { package.iCommandId = EOpFail; //pass through } case EScheduleAllL: { iScheduleSend->ScheduleL(aSelection, package); UpdateProgressL(aSelection); } break; case EReScheduleRetryAllL: { // Change the iCommandId to do a re-schedule package.iCommandId = EReScheduleRetryAllL; iScheduleSend->ReScheduleL(aSelection, package); UpdateProgressL(aSelection); // Bit of a hack here!! Check the selection to see if the messages // have been re-scheduled. If they have not been re-scheduled, then // copy to the Sent folder... for( TInt i=0; i<aSelection.Count(); ++i ) { User::LeaveIfError(iServerEntry->SetEntry(aSelection[i])); TMsvEntry entry = iServerEntry->Entry(); if( entry.SendingState() == KMsvSendStateWaiting ) { User::LeaveIfError(iServerEntry->SetEntry(KMsvSentEntryId)); User::LeaveIfError(iServerEntry->CreateEntry(entry)); } } User::LeaveIfError(iServerEntry->SetEntry(KMsvNullIndexEntryId)); } break; case EReScheduleAllL: { // Pass through action to be performed on reschedule. (Default is to do nothing.) TMsvSendErrorAction laterAction; laterAction.iAction = ESendActionRetryImmediately; laterAction.iRetries = ESendRetriesFixed; laterAction.iRetrySpacing = ESendRetrySpacingStatic; iScheduleSend->ReScheduleL(aSelection, package, &laterAction); UpdateProgressL(aSelection); } break; case EDeleteScheduleL: { iScheduleSend->DeleteScheduleL(aSelection); } break; case ESendScheduledL: { SendScheduledL(aSelection, aCommand, aParameter, aStatus); } break; case ECheckScheduleL: { iScheduleSend->CheckScheduleL(aSelection); } break; case ESetRetryImmediately: case ESetRetryLater: case ESetRetryVariable: case ESetNoRetry: { iScheduleSend->SetupL(aCommand); CRepository* repository = CRepository::NewLC(KUidMsgTypePigeon); iScheduleSend->SaveSysAgentActionsL(*repository); CleanupStack::PopAndDestroy(repository); } break; case ESetNowOffPeak: case ESetNowNotOffPeak: case ESetFirstOffPeakBest: case ESetLastOffPeakBest: { iScheduleSend->SetupL(aCommand); } break; case ESetIncrementalHeapFailure: { iHeapFailure = ETrue; // drop through } case EResetIncrementalHeapFailure: { iNextFailure = 0; } break; case ENoIncrementalHeapFailure: { iHeapFailure = EFalse; __UHEAP_RESET; } break; case EScheduleFailFirstSend: { SetFailFirstSendL(aSelection); iScheduleSend->ScheduleL(aSelection, package); UpdateProgressL(aSelection); } break; default: User::Panic(_L("pigeon server"), 1); break; } if(iHeapFailure) { __UHEAP_RESET; } }
void CSmsSendRecvTest::DoRunSendingL() { if (iOperation) iSmsTest.SetProgressL(*iOperation); TInt count = iSelection->Count(); TBool wait = EFalse; while (iStatus == KErrNone && count--) { TRAPD(err, iSmsTest.SetEntryL(iSelection->At(count))); if (err == KErrNone) { TMsvEntry entry = MsvEntry().Entry(); iSmsTest.SetEntryL(KMsvGlobalOutBoxIndexEntryId); TBuf<0x100> output; TBuf<0x50> nowBuf; switch (entry.SendingState()) { case KMsvSendStateSending: output.AppendFormat(_L("Message %d Sending with error %d\n"), entry.Id(), entry.iError); wait = ETrue; break; case KMsvSendStateResend: output.AppendFormat(_L("Message %d Resend at "), entry.Id()); entry.iDate.FormatL(nowBuf, _L("%-B%:0%J%:1%T%:2%S%:3%+B")); output.Append(nowBuf); output.Append(_L("\n")); wait = ETrue; break; case KMsvSendStateScheduled: output.AppendFormat(_L("Message %d Scheduled at "), entry.Id()); entry.iDate.FormatL(nowBuf, _L("%-B%:0%J%:1%T%:2%S%:3%+B")); entry.iDate.FormatL(nowBuf, _L("%-B%:0%J%:1%T%:2%S%:3%+B")); output.Append(nowBuf); output.Append(_L("\n")); wait = ETrue; break; case KMsvSendStateFailed: output.AppendFormat(_L("Message %d Failed with error %d\n"), entry.Id(), entry.iError); if (entry.iError) iStatus = entry.iError; else iStatus = KErrGeneral; break; case KMsvSendStateWaiting: output.AppendFormat(_L("Message %d Waiting with error %d\n"), entry.Id(), entry.iError); wait = ETrue; break; case KMsvSendStateSent: default: break; //nothing } iSmsTest.Printf(output); } } if (wait) { iTimer->AfterReq(10000000, iStatus); SetActive(); iState = EStateSending; // CActiveScheduler::Start(); } else { iSmsTest.Printf(_L("Sending completed with %d\n"), iStatus); if (iStatus == KErrNone) { TestWaitForReceiveL(); } else { iState = EStateWaiting; } } }
/** Verifies that the schedule information stored in specified messages is the same as that on the task scheduler. @param aSelection Array of message IDs that need to be checked against the task scheduler. @panic ScheduleSend-DLL 0 The array of message IDs is empty. Debug build only. */ EXPORT_C void CMsvScheduleSend::CheckScheduleL(const CMsvEntrySelection& aSelection) { __ASSERT_DEBUG(aSelection.Count(), gPanic(EMessageSelectionEmpty)); GetMessagesL(aSelection); //Leaves with KErrNotFound if there are no messages returned in iSchEntries TInt entryCount = iSchEntries->Count(); SCHSENDLOG(FLog(_L8("Asked to check schedule for %d msgs"), entryCount)); ConnectAndRegisterL(); while (entryCount--) { TBool found = EFalse; TTsTime schTime; CMsvScheduledEntry& sEntry = *iSchEntries->At(entryCount); if (!sEntry.iData.IsReset()) { TSchedulerItemRef ref; TInt size = 0; TTaskInfo info; TInt err = iScheduler.GetTaskDataSize(sEntry.iData.iTaskId, size); if (!err) { HBufC* buf = HBufC::NewLC(size); TPtr ptr = buf->Des(); User::LeaveIfError(iScheduler.GetTaskInfoL(sEntry.iData.iTaskId, info, ptr, ref, schTime)); CleanupStack::PopAndDestroy(buf); found = ETrue; } else if (err != KErrNotFound) { User::Leave(err); } } if (iServerEntry.SetEntry(sEntry.Id()) == KErrNone) { TMsvEntry entry = iServerEntry.Entry(); TInt sendingState = entry.SendingState(); if (sendingState == KMsvSendStateScheduled || sendingState == KMsvSendStateResend || entry.Scheduled()) { if (found) { entry.SetScheduled(ETrue); entry.iDate = schTime.GetUtcTime(); User::LeaveIfError(iServerEntry.ChangeEntry(entry)); } else { entry.SetScheduled(EFalse); entry.SetSendingState(KMsvSendStateUnknown); entry.iDate.UniversalTime(); User::LeaveIfError(iServerEntry.ChangeEntry(entry)); SendingCompleteL(sEntry, EFalse); } } } } }
// --------------------------------------------------------- // MsgStoreHandler::HandleSessionEventL() // --------------------------------------------------------- // void MsgStoreHandler::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/) { CMsvEntrySelection* selection = NULL; TMsvId parent; //args if (aArg1 == NULL || aArg2 == NULL) { return; } //start, processing the event selection = (CMsvEntrySelection*) aArg1; parent = *(TMsvId*) aArg2; // Return when not (outbox or inbox) and event not EMsvEntriesChanged if (!(parent == KMsvGlobalOutBoxIndexEntryIdValue || parent == KMsvGlobalInBoxIndexEntryIdValue) && aEvent != EMsvEntriesChanged) { return; } // check for incoming class 0 sms if (parent == KMsvGlobalInBoxIndexEntryIdValue && aEvent == EMsvEntriesChanged) { CMsvEntry* inboxEntry = iMsvSession->GetEntryL(KMsvGlobalInBoxIndexEntryId); for (TInt i = 0; i < selection->Count(); ++i) { TMsvEntry entry = inboxEntry->ChildDataL(selection->At(i)); if (KSenduiMtmSmsUidValue == entry.iMtm.iUid) { CMsvEntry* msgEntry = iMsvSession->GetEntryL(entry.Id()); TMsvSmsEntry smsEntry = msgEntry->Entry(); TSmsDataCodingScheme::TSmsClass classType(TSmsDataCodingScheme::ESmsClass0); if (smsEntry.Class(classType) && smsEntry.Unread()) { HandleClass0SmsL(msgEntry, smsEntry.Id()); } else { delete msgEntry; msgEntry = NULL; } } } // for (TInt i = 0; i < selection->Count(); ++i) delete inboxEntry; } //Handling for outbox entries else if (parent == KMsvGlobalOutBoxIndexEntryIdValue) { CMsvEntry* rootEntry = iMsvSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId); for (TInt i = 0; i < selection->Count(); ++i) { TMsvEntry entry = rootEntry->ChildDataL(selection->At(i)); if ((entry.iMtm == KSenduiMtmSmsUid) || (entry.iMtm == KSenduiMtmMmsUid)) { TUint sendingState = entry.SendingState(); TInt index = iFailedMessages->Find(entry.Id()); if (sendingState == KMsvSendStateFailed && KErrNotFound == index) { iFailedMessages->AppendL(entry.Id()); MsgInfo aInfo; ProcessIndicatorDataL(entry.Id(), aInfo); iNotifier->displayFailedNote(aInfo); } else if (sendingState != KMsvSendStateFailed && KErrNotFound != index) { iFailedMessages->Delete(index); iFailedMessages->Compress(); } } }//end for } else { TMsvEntry entry; TMsvId service; TInt error = KErrNone; for (TInt i = 0; i < selection->Count(); ++i) { error = iMsvSession->GetEntry(selection->At(i), service, entry); if (error == KErrNone && entry.iMtm == KUidMsgMMSNotification && MmsNotificationStatus(entry) == EMsgStatusFailed) { TInt index = iFailedMessages->Find(entry.Id()); if (KErrNotFound == index) { iFailedMessages->AppendL(entry.Id()); MsgInfo aInfo; //Fill aInfo with appropriate data aInfo.mMessageType = ECsMmsNotification; ProcessIndicatorDataL(entry.Id(), aInfo); iNotifier->displayFailedNote(aInfo); }// end of if } else if (error == KErrNone && entry.iMtm == KUidMsgMMSNotification && MmsNotificationStatus(entry) == EMsgStatusRetrieving) { TInt index = iFailedMessages->Find(entry.Id()); if (KErrNotFound != index) { iFailedMessages->Delete(index); iFailedMessages->Compress(); }// end of KErrNotFound != index if block } // end of 2nd if } // for loop } }