bool CHTSPDirectory::GetChannels( const CURL &base , CFileItemList &items , SChannels channels , int tag) { CURL url(base); SEvent event; for(SChannels::iterator it = channels.begin(); it != channels.end(); it++) { if(!m_session->GetEvent(event, it->second.event)) event.Clear(); CFileItemPtr item(new CFileItem("", true)); url.SetFileName(""); item->SetPath(url.Get()); CHTSPSession::ParseItem(it->second, tag, event, *item); item->m_bIsFolder = false; item->SetLabel(item->m_strTitle); item->m_strTitle = StringUtils::Format("%d", it->second.num); items.Add(item); } items.AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS("%K[ - %B]", "%Z", "%L", "")); items.AddSortMethod(SortByAlbum, 558, LABEL_MASKS("%B", "%Z", "%L", ""), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); items.AddSortMethod(SortByLabel, 551, LABEL_MASKS("%Z", "%B", "%L", ""), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); items.SetContent("livetv"); return !channels.empty(); }
bool CHTSPDirectorySession::GetEvent(SEvent& event, uint32_t id) { if(id == 0) { event.Clear(); return false; } SEvents::iterator it = m_events.find(id); if(it != m_events.end()) { event = it->second; return true; } htsmsg_t *msg = htsmsg_create_map(); htsmsg_add_str(msg, "method", "getEvent"); htsmsg_add_u32(msg, "eventId", id); if((msg = ReadResult(msg)) == NULL) { CLog::Log(LOGDEBUG, "CHTSPSession::GetEvent - failed to get event %u", id); return false; } if(!CHTSPSession::ParseEvent(msg, id, event)) return false; m_events[id] = event; return true; }
PVR_ERROR CHTSPData::GetEvent(SEvent& ev, uint32_t id) { if(id == 0) { ev.Clear(); return PVR_ERROR_UNKNOWN; } SEvents::iterator it = m_events.find(id); if(it != m_events.end()) { ev = it->second; return PVR_ERROR_NO_ERROR; } htsmsg_t *msg = htsmsg_create_map(); htsmsg_add_str(msg, "method", "getEvent"); htsmsg_add_u32(msg, "eventId", id); CHTSResult result; ReadResult(msg, result); if(result.status != PVR_ERROR_NO_ERROR) { XBMC->Log(LOG_DEBUG, "%s - failed to get event %d", __FUNCTION__, id); return result.status; } if (ParseEvent(result.message, id, ev)) { m_events[id] = ev; return PVR_ERROR_NO_ERROR; } return PVR_ERROR_SERVER_ERROR; }
bool CHTSPData::GetEvent(SEvent& event, uint32_t id) { if(id == 0) { event.Clear(); return false; } SEvents::iterator it = m_events.find(id); if(it != m_events.end()) { event = it->second; return true; } htsmsg_t *msg = htsmsg_create_map(); htsmsg_add_str(msg, "method", "getEvent"); htsmsg_add_u32(msg, "eventId", id); if((msg = ReadResult(msg)) == NULL) { XBMC->Log(LOG_DEBUG, "%s - failed to get event %d", __FUNCTION__, id); return false; } if (m_session->ParseEvent(msg, id, event)) { m_events[id] = event; return true; } return false; }
bool CHTSPDirectory::GetChannels( const CURL &base , CFileItemList &items , SChannels channels , int tag) { CURL url(base); SEvent event; for(SChannels::iterator it = channels.begin(); it != channels.end(); it++) { if(!m_session->GetEvent(event, it->second.event)) event.Clear(); CFileItemPtr item(new CFileItem("", true)); url.SetFileName(""); item->SetPath(url.Get()); CHTSPSession::ParseItem(it->second, tag, event, *item); item->m_bIsFolder = false; item->SetLabel(item->m_strTitle); item->m_strTitle.Format("%d", it->second.num); items.Add(item); } items.AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS("%K[ - %B]", "%Z", "%L", "")); if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) items.AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B", "%Z", "%L", "")); else items.AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B", "%Z", "%L", "")); if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) items.AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%Z", "%B", "%L", "")); else items.AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%Z", "%B", "%L", "")); items.SetContent("livetv"); return !channels.empty(); }
void SActivityThread::processEvents() { SPostEventList postEventList; bool copyOk = true;; mPostEventListMutex.lock(); try { postEventList = mPostEventList; mPostEventList.clear(); } catch(...) { copyOk = false; } mPostEventListMutex.unlock(); if(!copyOk) { mExit = true; mRetCode = PROCESS_EVENT_ERROR; return; } SPostEventList eventHasNotHandle; STimeMS currTime = STime::getCurrentTimeMS(); for(SPostEventList::iterator it = postEventList.begin(); it != postEventList.end(); it++) { SPostEvent* pe = *it; SEvent* e = pe->event; SObject* r = pe->receiver; if(e->getTriggerTime() <= currTime) sendEvent(r, e); else eventHasNotHandle.push_back(pe); } releasePostEventList(postEventList); mPostEventListMutex.lock(); for(SPostEventList::iterator it = eventHasNotHandle.begin() ; it != eventHasNotHandle.end() ; it++) { mPostEventList.push_back(*it); } mPostEventListMutex.unlock(); }
/* Запустить часы */ void CClock::Start(const std::function<void ()> &WaitFunc) { SEvent *CurEvent = NULL; Terminated = false; for (;;) { if (CurEvent == NULL) { WaitFunc(); if (Terminated) break; Time = NextEventTime; CurEvent = First; } SafeNext = CurEvent->Next; if (CurEvent->Data->Time > Time) { if ((NextEventTime > CurEvent->Data->Time) || (NextEventTime == Time)) NextEventTime = CurEvent->Data->Time; } else CurEvent->Execute(); CurEvent = SafeNext; } }
bool cHTSPSession::ParseEvent(htsmsg_t* msg, uint32_t id, SEvent &event) { uint32_t start, stop, next, chan_id, content; const char *title, *desc; if( htsmsg_get_u32(msg, "start", &start) || htsmsg_get_u32(msg, "stop" , &stop) || (title = htsmsg_get_str(msg, "title")) == NULL) { XBMC->Log(LOG_DEBUG, "%s - malformed event", __FUNCTION__); htsmsg_print(msg); htsmsg_destroy(msg); return false; } event.Clear(); event.id = id; event.start = start; event.stop = stop; event.title = title; if((desc = htsmsg_get_str(msg, "ext_text")) || (desc = htsmsg_get_str(msg, "description"))) event.descs = desc; if(htsmsg_get_u32(msg, "nextEventId", &next)) event.next = 0; else event.next = next; if(htsmsg_get_u32(msg, "channelId", &chan_id)) event.chan_id = -1; else event.chan_id = chan_id; if(htsmsg_get_u32(msg, "contentType", &content)) event.content = -1; else event.content = content; XBMC->Log(LOG_DEBUG, "%s - id:%u, chan_id:%u, title:'%s', genre_type:%u, genre_sub_type:%u, desc:'%s', start:%u, stop:%u, next:%u" , __FUNCTION__ , event.id , event.chan_id , event.title.c_str() , event.content & 0x0F , event.content & 0xF0 , event.descs.c_str() , event.start , event.stop , event.next); return true; }
bool cHTSPSession::GetEvent(SEvent& event, uint32_t id) { if(id == 0) { event.Clear(); return false; } htsmsg_t *msg = htsmsg_create_map(); htsmsg_add_str(msg, "method", "getEvent"); htsmsg_add_u32(msg, "eventId", id); if((msg = ReadResult(msg, true)) == NULL) { XBMC->Log(LOG_DEBUG, "%s - failed to get event %d", __FUNCTION__, id); return false; } return ParseEvent(msg, id, event); }