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)); } }
/** 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); } } } } }