예제 #1
0
const char *cRecDone::ToText(void)
{
    char* tmpDescr = description?strdup(description):NULL;
    if (tmpDescr)
	strreplace(tmpDescr, '\n', '|');

    char* tmpInfo = aux?strdup(aux):NULL;
    if (tmpInfo)
	strreplace(tmpInfo, '\n', '|');

    if (buffer)
	free(buffer);
    buffer = NULL;

    cChannel *channel = Channels.GetByChannelID(channelID, true, true);
    if (!channel)
	LogFile.Log(3,"invalid channel in recs done!");

    msprintf(&buffer, "R %ld %d %d\nC %s\n%s%s%s%s%s%s%s%s%s%s%s%sr",
	     startTime, duration, searchID,
	     channel?CHANNELSTRING(channel):"",
	     title?"T ":"",title?title:"", title?"\n":"",
	     shortText?"S ":"",shortText?shortText:"", shortText?"\n":"",
	     tmpDescr?"D ":"",tmpDescr?tmpDescr:"", tmpDescr?"\n":"",
	     tmpInfo?"@ ":"",tmpInfo?tmpInfo:"", tmpInfo?"\n":"");

    if (tmpDescr)
	free(tmpDescr);
    if (tmpInfo)
	free(tmpInfo);
    return buffer;
}
const char *cPendingNotification::ToText(void) const
{
  char* tmpFormatted = formatted!=""?strdup(formatted.c_str()):NULL;
    if (tmpFormatted)
	strreplace(tmpFormatted, '\n', '|');

    if (buffer)
	free(buffer);
    buffer = NULL;

#if VDRVERSNUM > 20300
    LOCK_CHANNELS_READ;
    const cChannels *vdrchannels = Channels;
#else
    cChannels *vdrchannels = &Channels;
#endif
    const cChannel *channel = vdrchannels->GetByChannelID(channelID, true, true);
    if (!channel)
	LogFile.Log(3,"invalid channel in pending notifications!");

    msprintf(&buffer, "N %d %u %d %d %ld\nC %s\n%s%s%sn",
	     type, eventID, timerMod, searchID, start,
	     channel?CHANNELSTRING(channel):"",
	     tmpFormatted?"F ":"",tmpFormatted?tmpFormatted:"", tmpFormatted?"\n":"");

    if (tmpFormatted)
	free(tmpFormatted);

    return buffer;
}
예제 #3
0
std::list<std::string> cEpgsearchServiceHandler::TranslateResults(cSearchResults* pCompleteSearchResults)
{
   std::list<std::string> list;

   if (pCompleteSearchResults)
   {
      // transfer to result list
      pCompleteSearchResults->SortBy(CompareEventTime);
      cSearchResult *result = pCompleteSearchResults->First();
      while (result && result->search)
      {
         const cEvent* pEvent = result->event;
         cTimer* Timer = new cTimer(pEvent);

         static char bufStart[25];
         static char bufEnd[25];

         struct tm tm_r;    time_t eStart = pEvent->StartTime();
         time_t eStop = pEvent->EndTime();
         time_t start = eStart - (result->search->MarginStart * 60);
         time_t stop  = eStop + (result->search->MarginStop * 60);
         if (result->search->useVPS && pEvent->Vps() && Setup.UseVps)
         {
            start = pEvent->Vps();
            stop = start + pEvent->Duration();
         }

         strftime(bufStart, sizeof(bufStart), "%H%M", localtime_r(&start, &tm_r));
         strftime(bufEnd, sizeof(bufEnd), "%H%M", localtime_r(&stop, &tm_r));

         eTimerMatch timerMatch;
         bool hasTimer = false;
         if (Timers.GetMatch(pEvent, &timerMatch))
            hasTimer = (timerMatch == tmFull);

         if (!result->search->useAsSearchTimer)
            result->needsTimer = false;

         cChannel *channel = Channels.GetByChannelID(pEvent->ChannelID(), true, true);
         int timerMode = hasTimer?1:(result->needsTimer?2:0);

         std::string title = pEvent->Title()?ReplaceAll(pEvent->Title(), "|", "!^pipe!^"):"";
         title = ReplaceAll(title, ":", "|");
         std::string shorttext = pEvent->ShortText()?ReplaceAll(pEvent->ShortText(), "|", "!^pipe!^"):"";
         shorttext = ReplaceAll(shorttext, ":", "|");
         std::string description = pEvent->Description()?ReplaceAll(pEvent->Description(), "|", "!^pipe!^"):"";
         description = ReplaceAll(description, ":", "|");

         cString cmdbuf = cString::sprintf("%d:%u:%s:%s:%s:%ld:%ld:%s:%ld:%ld:%s:%d",
                  result->search->ID,
                  pEvent->EventID(),
                  title.c_str(),
                  shorttext.c_str(),
                  description.c_str(),
                  pEvent->StartTime(),
                  pEvent->EndTime(),
                  CHANNELSTRING(channel),
                  timerMode>0?start:-1,
                  timerMode>0?stop:-1,
                  timerMode>0?result->search->BuildFile(pEvent):"",
                  timerMode);

         list.push_back(*cmdbuf);

         delete(Timer);
         result = pCompleteSearchResults->Next(result);
      }
   }
   return list;
}