DTC::ProgramList* Dvr::GetConflictList( int nStartIndex, int nCount, int nRecordId ) { RecordingList recordingList; // Auto-delete deque RecList tmpList; // Standard deque, objects must be deleted if (nRecordId <= 0) nRecordId = -1; // NOTE: Fetching this information directly from the schedule is // significantly faster than using ProgramInfo::LoadFromScheduler() Scheduler *scheduler = dynamic_cast<Scheduler*>(gCoreContext->GetScheduler()); if (scheduler) scheduler->GetAllPending(tmpList, nRecordId); // Sort the upcoming into only those which are conflicts RecList::iterator it = tmpList.begin(); for(; it < tmpList.end(); ++it) { if (((*it)->GetRecordingStatus() == RecStatus::Conflict) && ((*it)->GetRecordingStartTime() >= MythDate::current())) { recordingList.push_back(new RecordingInfo(**it)); } delete *it; *it = NULL; } // ---------------------------------------------------------------------- // Build Response // ---------------------------------------------------------------------- DTC::ProgramList *pPrograms = new DTC::ProgramList(); nStartIndex = min( nStartIndex, (int)recordingList.size() ); nCount = (nCount > 0) ? min( nCount, (int)recordingList.size() ) : recordingList.size(); int nEndIndex = min((nStartIndex + nCount), (int)recordingList.size() ); for( int n = nStartIndex; n < nEndIndex; n++) { ProgramInfo *pInfo = recordingList[ n ]; DTC::Program *pProgram = pPrograms->AddNewProgram(); FillProgramInfo( pProgram, pInfo, true ); } // ---------------------------------------------------------------------- pPrograms->setStartIndex ( nStartIndex ); pPrograms->setCount ( nCount ); pPrograms->setTotalAvailable( recordingList.size() ); pPrograms->setAsOf ( MythDate::current() ); pPrograms->setVersion ( MYTH_BINARY_VERSION ); pPrograms->setProtoVer ( MYTH_PROTO_VERSION ); return pPrograms; }
void JetpackActorCommon::UnregisterReceiver(const nsString& messageName, jsval receiver) { RecList* list; if (!mReceivers.Get(messageName, &list)) return; list->remove(receiver); }
bool JetpackActorCommon::RecvMessage(JSContext* cx, const nsString& messageName, const nsTArray<Variant>& data, nsTArray<Variant>* results) { if (results) results->Clear(); RecList* list; if (!mReceivers.Get(messageName, &list)) return true; nsAutoTArray<jsval, 4> snapshot; list->copyTo(snapshot); if (!snapshot.Length()) return true; nsAutoTArray<jsval, 4> args; PRUint32 argc = data.Length() + 1; jsval* argv = args.AppendElements(argc); if (!argv) return false; for (PRUint32 i = 0; i < argc; ++i) argv[i] = JSVAL_VOID; js::AutoArrayRooter argvRooter(cx, argc, argv); JSString* msgNameStr = JS_NewUCStringCopyN(cx, messageName.get(), messageName.Length()); if (!msgNameStr) return false; argv[0] = STRING_TO_JSVAL(msgNameStr); for (PRUint32 i = 0; i < data.Length(); ++i) if (!jsval_from_Variant(cx, data.ElementAt(i), argv + i + 1)) return false; JSObject* implGlobal = JS_GetGlobalObject(cx); js::AutoValueRooter rval(cx); for (PRUint32 i = 0; i < snapshot.Length(); ++i) { Variant* vp = results ? results->AppendElement() : NULL; rval.set(JSVAL_VOID); if (!JS_CallFunctionValue(cx, implGlobal, snapshot[i], argc, argv, rval.jsval_addr())) { (void) JS_ReportPendingException(cx); if (vp) *vp = void_t(); } else if (vp && !jsval_to_Variant(cx, rval.jsval_value(), vp)) *vp = void_t(); } return true; }
DTC::RecRuleList* Dvr::GetRecordScheduleList( int nStartIndex, int nCount, const QString &Sort, bool Descending ) { Scheduler::SchedSortColumn sortingColumn; if (Sort.toLower() == "lastrecorded") sortingColumn = Scheduler::kSortLastRecorded; else if (Sort.toLower() == "title") sortingColumn = Scheduler::kSortTitle; else if (Sort.toLower() == "priority") sortingColumn = Scheduler::kSortPriority; else if (Sort.toLower() == "type") sortingColumn = Scheduler::kSortType; RecList recList; Scheduler::GetAllScheduled(recList, sortingColumn, !Descending); // ---------------------------------------------------------------------- // Build Response // ---------------------------------------------------------------------- DTC::RecRuleList *pRecRules = new DTC::RecRuleList(); nStartIndex = min( nStartIndex, (int)recList.size() ); nCount = (nCount > 0) ? min( nCount, (int)recList.size() ) : recList.size(); int nEndIndex = min((nStartIndex + nCount), (int)recList.size() ); for( int n = nStartIndex; n < nEndIndex; n++) { RecordingInfo *info = recList[n]; if (info != NULL) { DTC::RecRule *pRecRule = pRecRules->AddNewRecRule(); FillRecRuleInfo( pRecRule, info->GetRecordingRule() ); } } // ---------------------------------------------------------------------- pRecRules->setStartIndex ( nStartIndex ); pRecRules->setCount ( nCount ); pRecRules->setTotalAvailable( recList.size() ); pRecRules->setAsOf ( MythDate::current() ); pRecRules->setVersion ( MYTH_BINARY_VERSION ); pRecRules->setProtoVer ( MYTH_PROTO_VERSION ); while (!recList.empty()) { delete recList.back(); recList.pop_back(); } return pRecRules; }
DTC::RecRuleList* Dvr::GetRecordScheduleList( int nStartIndex, int nCount ) { RecList recList; Scheduler::GetAllScheduled(recList); // ---------------------------------------------------------------------- // Build Response // ---------------------------------------------------------------------- DTC::RecRuleList *pRecRules = new DTC::RecRuleList(); nStartIndex = min( nStartIndex, (int)recList.size() ); nCount = (nCount > 0) ? min( nCount, (int)recList.size() ) : recList.size(); int nEndIndex = min((nStartIndex + nCount), (int)recList.size() ); for( int n = nStartIndex; n < nEndIndex; n++) { RecordingInfo *info = recList[n]; if (info != NULL) { DTC::RecRule *pRecRule = pRecRules->AddNewRecRule(); FillRecRuleInfo( pRecRule, info->GetRecordingRule() ); delete info; } } // ---------------------------------------------------------------------- pRecRules->setStartIndex ( nStartIndex ); pRecRules->setCount ( nCount ); pRecRules->setTotalAvailable( recList.size() ); pRecRules->setAsOf ( QDateTime::currentDateTime() ); pRecRules->setVersion ( MYTH_BINARY_VERSION ); pRecRules->setProtoVer ( MYTH_PROTO_VERSION ); return pRecRules; }
nsresult JetpackActorCommon::RegisterReceiver(JSContext* cx, const nsString& messageName, jsval receiver) { if (!JSVAL_IS_OBJECT(receiver) || !JS_ObjectIsFunction(cx, JSVAL_TO_OBJECT(receiver))) return NS_ERROR_INVALID_ARG; RecList* list; if (!mReceivers.Get(messageName, &list)) { list = new RecList(cx); if (!list || !mReceivers.Put(messageName, list)) { delete list; return NS_ERROR_OUT_OF_MEMORY; } } list->add(receiver); return NS_OK; }