Ticket #6862: 6862-v2.patch
File 6862-v2.patch, 92.8 KB (added by , 14 years ago) |
---|
-
libs/libmythtv/recordinglist.h
9 9 // of the list while the linked list erase() is always O(1), but all other 10 10 // operations are faster with the deque. 11 11 12 #define PGLIST_USE_LINKED_LIST12 //#define PGLIST_USE_LINKED_LIST 13 13 14 14 // C++ headers 15 15 #ifdef PGLIST_USE_LINKED_LIST … … 29 29 // MythTV headers 30 30 #include "mythexp.h" 31 31 #include "mythdbcon.h" 32 #include "programinfo.h" // for ProgramDetailList33 32 33 class RecordingList; 34 MPUBLIC bool LoadFromScheduler( 35 RecordingList &destination, 36 bool &hasConflicts, 37 QString altTable = "", 38 int recordid = -1); 39 34 40 /** \class RecordingList 35 41 * \brief List of RecordingInfo instances, with helper functions. 36 42 */ … … 45 51 46 52 RecordingInfo *operator[](uint index); 47 53 const RecordingInfo *operator[](uint index) const; 48 bool operator==(const RecordingList &b) const;49 54 50 bool FromScheduler(bool &hasConflicts,51 QString altTable = "",52 int recordid = -1);53 54 bool FromScheduler(void)55 {56 bool dummyConflicts;57 return FromScheduler(dummyConflicts, "", -1);58 };59 60 bool FromProgram(const QString &sql, MSqlBindings &bindings,61 RecordingList &schedList, bool oneChanid = false);62 63 bool FromProgram(const QString &sql, MSqlBindings &bindings)64 {65 RecordingList dummySched;66 return FromProgram(sql, bindings, dummySched);67 }68 69 bool FromRecorded( bool bDescending, RecordingList *pSchedList);70 71 bool FromOldRecorded(const QString &sql, MSqlBindings &bindings);72 73 static bool GetProgramDetailList(74 QDateTime &nextRecordingStart,75 bool *hasConflicts = NULL,76 ProgramDetailList *list = NULL);77 78 55 RecordingInfo *take(uint i); 79 56 iterator erase(iterator it); 80 57 void clear(void); … … 91 68 void push_back(RecordingInfo *pginfo) { pglist.push_back(pginfo); } 92 69 93 70 // compatibility with old Q3PtrList 94 bool isEmpty(void) const { return empty(); }95 size_t count(void) const { return size(); }96 RecordingInfo *at(uint index) { return (*this)[index]; }97 void prepend(RecordingInfo *pginfo) { push_front(pginfo); }98 void append(RecordingInfo *pginfo) { push_back(pginfo); }99 71 void setAutoDelete(bool auto_delete) { autodelete = auto_delete; } 100 72 101 73 protected: -
libs/libmythtv/programdetail.cpp
1 #include "programdetail.h" 2 #include "programlist.h" 3 #include "programinfo.h" 4 5 bool GetProgramDetailList( 6 QDateTime &nextRecordingStart, bool *hasConflicts, ProgramDetailList *list) 7 { 8 nextRecordingStart = QDateTime(); 9 10 bool dummy; 11 bool *conflicts = (hasConflicts) ? hasConflicts : &dummy; 12 13 ProgramList progList; 14 if (!LoadFromScheduler(progList, *conflicts)) 15 return false; 16 17 // find the earliest scheduled recording 18 ProgramList::const_iterator it = progList.begin(); 19 for (; it != progList.end(); ++it) 20 { 21 if (((*it)->recstatus == rsWillRecord) && 22 (nextRecordingStart.isNull() || 23 nextRecordingStart > (*it)->recstartts)) 24 { 25 nextRecordingStart = (*it)->recstartts; 26 } 27 } 28 29 if (!list) 30 return true; 31 32 // save the details of the earliest recording(s) 33 for (it = progList.begin(); it != progList.end(); ++it) 34 { 35 if (((*it)->recstatus == rsWillRecord) && 36 ((*it)->recstartts == nextRecordingStart)) 37 { 38 ProgramDetail prog; 39 prog.channame = (*it)->channame; 40 prog.title = (*it)->title; 41 prog.subtitle = (*it)->subtitle; 42 prog.startTime = (*it)->recstartts; 43 prog.endTime = (*it)->recendts; 44 list->push_back(prog); 45 } 46 } 47 48 return true; 49 } -
libs/libmythtv/programdetail.h
1 #ifndef _PROGRAM_DETAIL_H_ 2 #define _PROGRAM_DETAIL_H_ 3 4 // C++ headers 5 #include <vector> 6 using namespace std; 7 8 // Qt headers 9 #include <QString> 10 #include <QDateTime> 11 12 // MythTV headers 13 #include "mythexp.h" 14 15 class MPUBLIC ProgramDetail 16 { 17 public: 18 QString channame; 19 QString title; 20 QString subtitle; 21 QDateTime startTime; 22 QDateTime endTime; 23 }; 24 typedef vector<ProgramDetail> ProgramDetailList; 25 26 bool GetProgramDetailList( 27 QDateTime &nextRecordingStart, 28 bool *hasConflicts = NULL, 29 ProgramDetailList *list = NULL); 30 31 #endif // _PROGRAM_DETAIL_H_ -
libs/libmythtv/libmythtv.pro
155 155 HEADERS += transporteditor.h listingsources.h 156 156 HEADERS += myth_imgconvert.h 157 157 HEADERS += channelgroup.h channelgroupsettings.h 158 HEADERS += recordingrule.h 158 HEADERS += recordingrule.h programdetail.h 159 159 160 160 SOURCES += recordinginfo.cpp recordinglist.cpp 161 161 SOURCES += RingBuffer.cpp avfringbuffer.cpp … … 176 176 SOURCES += transporteditor.cpp 177 177 SOURCES += channelgroup.cpp channelgroupsettings.cpp 178 178 SOURCES += myth_imgconvert.cpp 179 SOURCES += recordingrule.cpp 179 SOURCES += recordingrule.cpp programdetail.cpp 180 180 181 181 # DiSEqC 182 182 HEADERS += diseqc.h diseqcsettings.h -
libs/libmythtv/viewschdiff.cpp
397 397 } 398 398 } 399 399 400 recListBefore.FromScheduler(conflictBool);401 recListAfter.FromScheduler(conflictBool, altTable, recordid);400 LoadFromScheduler(recListBefore, conflictBool); 401 LoadFromScheduler(recListAfter, conflictBool, altTable, recordid); 402 402 403 403 recListBefore.sort(comp_recstart_less_than); 404 404 recListAfter.sort(comp_recstart_less_than); -
libs/libmythtv/recordinginfo.h
21 21 22 22 class MPUBLIC RecordingInfo : public ProgramInfo 23 23 { 24 friend class RecordingList; 25 24 26 public: 25 27 RecordingInfo(void) : record(NULL) {} 26 28 RecordingInfo(const RecordingInfo &other) : 27 29 ProgramInfo(other), record(NULL) {} 28 30 RecordingInfo(const ProgramInfo &other) : 29 31 ProgramInfo(other), record(NULL) {} 32 33 protected: 34 RecordingInfo(const MSqlQuery &query, 35 const ProgramList &schedList, 36 bool oneChanid) : 37 ProgramInfo(query, schedList, oneChanid), record(NULL) {} 38 39 public: 30 40 RecordingInfo &operator=(const RecordingInfo &other) {return clone(other);} 31 41 RecordingInfo &operator=(const ProgramInfo &other) { return clone(other); } 32 42 -
libs/libmythtv/tv_play.cpp
7681 7681 }; 7682 7682 7683 7683 ProgramList progList; 7684 progList.FromProgram(querystr, bindings); 7684 ProgramList dummySched; 7685 LoadFromProgram(progList, querystr, bindings, dummySched, false); 7685 7686 7686 if (progList. isEmpty())7687 if (progList.empty()) 7687 7688 { 7688 7689 infoMap["dbstarttime"] = ""; 7689 7690 return; … … 11521 11522 for (Iprog = progLists.begin(); Iprog != progLists.end(); Iprog++) 11522 11523 { 11523 11524 const ProgramList &plist = *Iprog; 11524 int progIndex = plist.count();11525 uint progIndex = (uint) plist.size(); 11525 11526 11526 11527 if (plist[0]->recgroup != currecgroup) 11527 11528 { -
libs/libmythtv/recordinglist.cpp
4 4 #include "mythcontext.h" 5 5 #include "mythdb.h" 6 6 #include "util.h" 7 #include "recordinginfo.h"8 7 #include "recordinglist.h" 8 #include "recordinginfo.h" 9 9 #include "jobqueue.h" 10 10 11 11 RecordingList::~RecordingList(void) … … 37 37 return (*(const_cast<RecordingList*>(this)))[index]; 38 38 } 39 39 40 bool RecordingList::operator==(const RecordingList &b) const41 {42 const_iterator it_a = pglist.begin();43 const_iterator it_b = b.pglist.begin();44 const_iterator end_a = pglist.end();45 const_iterator end_b = b.pglist.end();46 47 for (; it_a != end_a && it_b != end_b; ++it_a, ++it_b)48 {49 if (*it_a != *it_b)50 return false;51 }52 53 return (it_a == end_a) && (it_b == end_b);54 }55 56 40 RecordingInfo *RecordingList::take(uint index) 57 41 { 58 42 #ifndef PGLIST_USE_LINKED_LIST … … 112 96 #endif 113 97 } 114 98 115 bool RecordingList::FromScheduler(bool &hasConflicts, QString tmptable, 116 int recordid) 99 bool LoadFromScheduler( 100 RecordingList &destination, bool &hasConflicts, 101 QString tmptable, int recordid) 117 102 { 118 clear();103 destination.clear(); 119 104 hasConflicts = false; 120 105 121 106 if (gContext->IsBackend()) 122 107 return false; 123 108 124 109 QString query; 125 if ( tmptable != "")110 if (!tmptable.isEmpty()) 126 111 { 127 112 query = QString("QUERY_GETALLPENDING %1 %2") 128 .arg(tmptable).arg(recordid); 129 } else { 113 .arg(tmptable).arg(recordid); 114 } 115 else 116 { 130 117 query = QString("QUERY_GETALLPENDING"); 131 118 } 132 119 … … 134 121 if (!gContext->SendReceiveStringList(slist) || slist.size() < 2) 135 122 { 136 123 VERBOSE(VB_IMPORTANT, 137 " RecordingList::FromScheduler(): Error querying master.");124 "LoadFromScheduler(): Error querying master."); 138 125 return false; 139 126 } 140 127 … … 148 135 RecordingInfo *p = new RecordingInfo(); 149 136 result = p->FromStringList(sit, slist.end()); 150 137 if (result) 151 pglist.push_back(p);138 destination.push_back(p); 152 139 else 153 140 delete p; 154 141 } 155 142 156 if ( pglist.size() != slist[1].toUInt())143 if (destination.size() != slist[1].toUInt()) 157 144 { 158 145 VERBOSE(VB_IMPORTANT, 159 " RecordingList::FromScheduler(): Length mismatch");160 clear();146 "LoadFromScheduler(): Length mismatch."); 147 destination.clear(); 161 148 result = false; 162 149 } 163 150 164 151 return result; 165 152 } 166 153 167 bool RecordingList::FromProgram(const QString &sql, MSqlBindings &bindings,168 RecordingList &schedList, bool oneChanid)169 {170 clear();171 172 QString querystr = QString(173 "SELECT DISTINCT program.chanid, program.starttime, program.endtime, "174 " program.title, program.subtitle, program.description, "175 " program.category, channel.channum, channel.callsign, "176 " channel.name, program.previouslyshown, channel.commmethod, "177 " channel.outputfilters, program.seriesid, program.programid, "178 " program.airdate, program.stars, program.originalairdate, "179 " program.category_type, oldrecstatus.recordid, "180 " oldrecstatus.rectype, oldrecstatus.recstatus, "181 " oldrecstatus.findid "182 "FROM program "183 "LEFT JOIN channel ON program.chanid = channel.chanid "184 "LEFT JOIN oldrecorded AS oldrecstatus ON "185 " program.title = oldrecstatus.title AND "186 " channel.callsign = oldrecstatus.station AND "187 " program.starttime = oldrecstatus.starttime "188 ) + sql;189 190 if (!sql.contains(" GROUP BY "))191 querystr += " GROUP BY program.starttime, channel.channum, "192 " channel.callsign, program.title ";193 if (!sql.contains(" ORDER BY "))194 {195 querystr += " ORDER BY program.starttime, ";196 QString chanorder = gContext->GetSetting("ChannelOrdering", "channum");197 if (chanorder != "channum")198 querystr += chanorder + " ";199 else // approximation which the DB can handle200 querystr += "atsc_major_chan,atsc_minor_chan,channum,callsign ";201 }202 if (!sql.contains(" LIMIT "))203 querystr += " LIMIT 20000 ";204 205 MSqlQuery query(MSqlQuery::InitCon());206 query.prepare(querystr);207 MSqlBindings::const_iterator it;208 for (it = bindings.begin(); it != bindings.end(); ++it)209 if (querystr.contains(it.key()))210 query.bindValue(it.key(), it.value());211 212 if (!query.exec())213 {214 MythDB::DBError("RecordingList::FromProgram", query);215 return false;216 }217 218 while (query.next())219 {220 RecordingInfo *p = new RecordingInfo;221 p->chanid = query.value(0).toString();222 p->startts = QDateTime::fromString(query.value(1).toString(),223 Qt::ISODate);224 p->endts = QDateTime::fromString(query.value(2).toString(),225 Qt::ISODate);226 p->recstartts = p->startts;227 p->recendts = p->endts;228 p->lastmodified = p->startts;229 p->title = query.value(3).toString();230 p->subtitle = query.value(4).toString();231 p->description = query.value(5).toString();232 p->category = query.value(6).toString();233 p->chanstr = query.value(7).toString();234 p->chansign = query.value(8).toString();235 p->channame = query.value(9).toString();236 p->repeat = query.value(10).toInt();237 p->chancommfree = COMM_DETECT_COMMFREE == query.value(11).toInt();238 p->chanOutputFilters = query.value(12).toString();239 p->seriesid = query.value(13).toString();240 p->programid = query.value(14).toString();241 p->year = query.value(15).toString();242 p->stars = query.value(16).toString().toFloat();243 244 if (query.value(17).isNull() || query.value(17).toString().isEmpty())245 {246 p->originalAirDate = QDate (0, 1, 1);247 p->hasAirDate = false;248 }249 else250 {251 p->originalAirDate =252 QDate::fromString(query.value(17).toString(),Qt::ISODate);253 254 if (p->originalAirDate > QDate(1940, 1, 1))255 p->hasAirDate = true;256 else257 p->hasAirDate = false;258 }259 p->catType = query.value(18).toString();260 p->recordid = query.value(19).toInt();261 p->rectype = RecordingType(query.value(20).toInt());262 p->recstatus = RecStatusType(query.value(21).toInt());263 p->findid = query.value(22).toInt();264 265 iterator it = schedList.pglist.begin();266 for (; it != schedList.pglist.end(); ++it)267 {268 RecordingInfo *s = *it;269 if (p->IsSameTimeslot(*s))270 {271 p->recordid = s->recordid;272 p->recstatus = s->recstatus;273 p->rectype = s->rectype;274 p->recpriority = s->recpriority;275 p->recstartts = s->recstartts;276 p->recendts = s->recendts;277 p->cardid = s->cardid;278 p->inputid = s->inputid;279 p->dupin = s->dupin;280 p->dupmethod = s->dupmethod;281 p->findid = s->findid;282 283 if (s->recstatus == rsWillRecord ||284 s->recstatus == rsRecording)285 {286 if (oneChanid)287 {288 p->chanid = s->chanid;289 p->chanstr = s->chanstr;290 p->chansign = s->chansign;291 p->channame = s->channame;292 }293 else if ((p->chanid != s->chanid) &&294 (p->chanstr != s->chanstr))295 {296 p->recstatus = rsOtherShowing;297 }298 }299 }300 }301 302 pglist.push_back(p);303 }304 305 return true;306 }307 308 bool RecordingList::FromRecorded( bool bDescending, RecordingList *pSchedList )309 {310 clear();311 312 QString fs_db_name = "";313 QDateTime rectime = QDateTime::currentDateTime().addSecs(314 -gContext->GetNumSetting("RecordOverTime"));315 316 QString ip = gContext->GetSetting("BackendServerIP");317 QString port = gContext->GetSetting("BackendServerPort");318 319 // ----------------------------------------------------------------------320 321 QMap<QString, int> inUseMap;322 323 QString inUseKey;324 QString inUseForWhat;325 QDateTime oneHourAgo = QDateTime::currentDateTime().addSecs(-61 * 60);326 327 MSqlQuery query(MSqlQuery::InitCon());328 329 query.prepare("SELECT DISTINCT chanid, starttime, recusage "330 " FROM inuseprograms WHERE lastupdatetime >= :ONEHOURAGO ;");331 query.bindValue(":ONEHOURAGO", oneHourAgo);332 333 if (query.exec())334 {335 while (query.next())336 {337 inUseKey = query.value(0).toString() + " " +338 query.value(1).toDateTime().toString(Qt::ISODate);339 inUseForWhat = query.value(2).toString();340 341 if (!inUseMap.contains(inUseKey))342 inUseMap[inUseKey] = 0;343 344 if ((inUseForWhat == "player") ||345 (inUseForWhat == "preview player") ||346 (inUseForWhat == "PIP player"))347 inUseMap[inUseKey] = inUseMap[inUseKey] | FL_INUSEPLAYING;348 else if (inUseForWhat == "recorder")349 inUseMap[inUseKey] = inUseMap[inUseKey] | FL_INUSERECORDING;350 }351 }352 353 // ----------------------------------------------------------------------354 355 QMap<QString,bool> is_job_running;356 query.prepare("SELECT chanid, starttime, status FROM jobqueue "357 "WHERE type = :TYPE");358 query.bindValue(":TYPE", JOB_COMMFLAG);359 if (query.exec())360 {361 while (query.next())362 {363 uint chanid = query.value(0).toUInt();364 QDateTime recstartts = query.value(1).toDateTime();365 int tmpStatus = query.value(2).toInt();366 if ((tmpStatus != JOB_UNKNOWN) &&367 (tmpStatus != JOB_QUEUED) &&368 (!(tmpStatus & JOB_DONE)))369 {370 is_job_running[371 QString("%1###%2")372 .arg(chanid).arg(recstartts.toString())] = true;373 }374 }375 }376 377 // ----------------------------------------------------------------------378 379 QString thequery =380 "SELECT recorded.chanid,recorded.starttime,recorded.endtime,"381 "recorded.title,recorded.subtitle,recorded.description,"382 "recorded.hostname,channum,name,callsign,commflagged,cutlist,"383 "recorded.autoexpire,editing,bookmark,recorded.category,"384 "recorded.recgroup,record.dupin,record.dupmethod,"385 "record.recordid,outputfilters,"386 "recorded.seriesid,recorded.programid,recorded.filesize, "387 "recorded.lastmodified, recorded.findid, "388 "recorded.originalairdate, recorded.playgroup, "389 "recorded.basename, recorded.progstart, "390 "recorded.progend, recorded.stars, "391 "recordedprogram.audioprop+0, recordedprogram.videoprop+0, "392 "recordedprogram.subtitletypes+0, recorded.watched, "393 "recorded.storagegroup "394 "FROM recorded "395 "LEFT JOIN record ON recorded.recordid = record.recordid "396 "LEFT JOIN channel ON recorded.chanid = channel.chanid "397 "LEFT JOIN recordedprogram ON "398 " ( recorded.chanid = recordedprogram.chanid AND "399 " recorded.progstart = recordedprogram.starttime ) "400 "WHERE ( recorded.deletepending = 0 OR "401 " recorded.lastmodified <= DATE_SUB(NOW(), INTERVAL 5 MINUTE) "402 " ) "403 "ORDER BY recorded.starttime";404 405 if ( bDescending )406 thequery += " DESC";407 408 QString chanorder = gContext->GetSetting("ChannelOrdering", "channum");409 if (chanorder != "channum")410 thequery += ", " + chanorder;411 else // approximation which the DB can handle412 thequery += ",atsc_major_chan,atsc_minor_chan,channum,callsign";413 414 query.prepare(thequery);415 416 if (!query.exec())417 {418 MythDB::DBError("RecordingList::FromRecorded", query);419 return true;420 }421 422 while (query.next())423 {424 RecordingInfo *proginfo = new RecordingInfo;425 426 proginfo->chanid = query.value(0).toString();427 proginfo->startts = query.value(29).toDateTime();428 proginfo->endts = query.value(30).toDateTime();429 proginfo->recstartts = query.value(1).toDateTime();430 proginfo->recendts = query.value(2).toDateTime();431 proginfo->title = query.value(3).toString();432 proginfo->subtitle = query.value(4).toString();433 proginfo->description = query.value(5).toString();434 proginfo->hostname = query.value(6).toString();435 436 proginfo->dupin = RecordingDupInType(query.value(17).toInt());437 proginfo->dupmethod = RecordingDupMethodType(query.value(18).toInt());438 proginfo->recordid = query.value(19).toInt();439 proginfo->chanOutputFilters = query.value(20).toString();440 proginfo->seriesid = query.value(21).toString();441 proginfo->programid = query.value(22).toString();442 proginfo->filesize = stringToLongLong(query.value(23).toString());443 proginfo->lastmodified = QDateTime::fromString(query.value(24).toString(), Qt::ISODate);444 proginfo->findid = query.value(25).toInt();445 446 if (query.value(26).isNull() ||447 query.value(26).toString().isEmpty())448 {449 proginfo->originalAirDate = QDate (0, 1, 1);450 proginfo->hasAirDate = false;451 }452 else453 {454 proginfo->originalAirDate =455 QDate::fromString(query.value(26).toString(),Qt::ISODate);456 457 if (proginfo->originalAirDate > QDate(1940, 1, 1))458 proginfo->hasAirDate = true;459 else460 proginfo->hasAirDate = false;461 }462 463 proginfo->pathname = query.value(28).toString();464 465 466 if (proginfo->hostname.isEmpty() || proginfo->hostname.isNull())467 proginfo->hostname = gContext->GetHostName();468 469 if (!query.value(7).toString().isEmpty())470 {471 proginfo->chanstr = query.value(7).toString();472 proginfo->channame = query.value(8).toString();473 proginfo->chansign = query.value(9).toString();474 }475 else476 {477 proginfo->chanstr = "#" + proginfo->chanid;478 proginfo->channame = "#" + proginfo->chanid;479 proginfo->chansign = "#" + proginfo->chanid;480 }481 482 int flags = 0;483 484 flags |= (query.value(10).toInt() == 1) ? FL_COMMFLAG : 0;485 flags |= query.value(11).toString().length() > 1 ? FL_CUTLIST : 0;486 flags |= query.value(12).toInt() ? FL_AUTOEXP : 0;487 flags |= query.value(14).toString().length() > 1 ? FL_BOOKMARK : 0;488 flags |= (query.value(35).toInt() == 1) ? FL_WATCHED : 0;489 490 inUseKey = query.value(0).toString() + " " +491 query.value(1).toDateTime().toString(Qt::ISODate);492 493 if (inUseMap.contains(inUseKey))494 flags |= inUseMap[inUseKey];495 496 if (query.value(13).toInt())497 {498 flags |= FL_EDITING;499 }500 else if (query.value(10).toInt() == COMM_FLAG_PROCESSING)501 {502 bool running =503 is_job_running.find(504 QString("%1###%2")505 .arg(proginfo->chanid)506 .arg(proginfo->recstartts.toString())) !=507 is_job_running.end();508 if (running)509 flags |= FL_EDITING;510 else511 proginfo->SetCommFlagged(COMM_FLAG_NOT_FLAGGED);512 }513 514 proginfo->programflags = flags;515 516 proginfo->audioproperties = query.value(32).toInt();517 proginfo->videoproperties = query.value(33).toInt();518 proginfo->subtitleType = query.value(34).toInt();519 520 proginfo->category = query.value(15).toString();521 proginfo->recgroup = query.value(16).toString();522 proginfo->playgroup = query.value(27).toString();523 proginfo->storagegroup = query.value(36).toString();524 proginfo->recstatus = rsRecorded;525 526 if ((pSchedList != NULL) && (proginfo->recendts > rectime))527 {528 iterator it = pSchedList->pglist.begin();529 for (; it != pSchedList->pglist.end(); ++it)530 {531 ProgramInfo *s = *it;532 if (s && s->recstatus == rsRecording &&533 proginfo->chanid == s->chanid &&534 proginfo->recstartts == s->recstartts)535 {536 proginfo->recstatus = rsRecording;537 break;538 }539 }540 }541 542 proginfo->stars = query.value(31).toDouble();543 544 pglist.push_back(proginfo);545 }546 547 return true;548 }549 550 551 bool RecordingList::FromOldRecorded(const QString &sql, MSqlBindings &bindings)552 {553 clear();554 MSqlQuery query(MSqlQuery::InitCon());555 556 query.prepare("SELECT oldrecorded.chanid, starttime, endtime, "557 " title, subtitle, description, category, seriesid, "558 " programid, channel.channum, channel.callsign, "559 " channel.name, findid, rectype, recstatus, recordid, "560 " duplicate "561 " FROM oldrecorded "562 " LEFT JOIN channel ON oldrecorded.chanid = channel.chanid "563 + sql);564 query.bindValues(bindings);565 566 if (!query.exec() || !query.isActive())567 {568 MythDB::DBError("RecordingList::FromOldRecorded", query);569 return false;570 }571 572 while (query.next())573 {574 RecordingInfo *p = new RecordingInfo;575 p->chanid = query.value(0).toString();576 p->startts = QDateTime::fromString(query.value(1).toString(),577 Qt::ISODate);578 p->endts = QDateTime::fromString(query.value(2).toString(),579 Qt::ISODate);580 p->recstartts = p->startts;581 p->recendts = p->endts;582 p->lastmodified = p->startts;583 p->title = query.value(3).toString();584 p->subtitle = query.value(4).toString();585 p->description = query.value(5).toString();586 p->category = query.value(6).toString();587 p->seriesid = query.value(7).toString();588 p->programid = query.value(8).toString();589 p->chanstr = query.value(9).toString();590 p->chansign = query.value(10).toString();591 p->channame = query.value(11).toString();592 p->findid = query.value(12).toInt();593 p->rectype = RecordingType(query.value(13).toInt());594 p->recstatus = RecStatusType(query.value(14).toInt());595 p->recordid = query.value(15).toInt();596 p->duplicate = query.value(16).toInt();597 598 pglist.push_back(p);599 }600 601 return true;602 }603 604 bool RecordingList::GetProgramDetailList(605 QDateTime &nextRecordingStart, bool *hasConflicts, ProgramDetailList *list)606 {607 nextRecordingStart = QDateTime();608 609 bool dummy;610 bool *conflicts = (hasConflicts) ? hasConflicts : &dummy;611 612 RecordingList progList;613 if (!progList.FromScheduler(*conflicts))614 return false;615 616 // find the earliest scheduled recording617 RecordingList::const_iterator it = progList.begin();618 for (; it != progList.end(); ++it)619 {620 if (((*it)->recstatus == rsWillRecord) &&621 (nextRecordingStart.isNull() ||622 nextRecordingStart > (*it)->recstartts))623 {624 nextRecordingStart = (*it)->recstartts;625 }626 }627 628 if (!list)629 return true;630 631 // save the details of the earliest recording(s)632 for (it = progList.begin(); it != progList.end(); ++it)633 {634 if (((*it)->recstatus == rsWillRecord) &&635 ((*it)->recstartts == nextRecordingStart))636 {637 ProgramDetail prog;638 prog.channame = (*it)->channame;639 prog.title = (*it)->title;640 prog.subtitle = (*it)->subtitle;641 prog.startTime = (*it)->recstartts;642 prog.endTime = (*it)->recendts;643 list->push_back(prog);644 }645 }646 647 return true;648 } -
libs/libmyth/programinfo.h
213 213 * view or record. 214 214 */ 215 215 216 class MSqlQuery; 217 class ProgramList; 218 216 219 class MPUBLIC ProgramInfo 217 220 { 221 friend class ProgramList; 222 218 223 public: 219 // Constructors and bulk set methods.224 // Constructors 220 225 ProgramInfo(void); 221 226 ProgramInfo(const ProgramInfo &other); 227 ProgramInfo(const MSqlQuery &query, 228 const ProgramList &schedList, 229 bool oneChanid); 230 // Bulk set methods 231 public: 222 232 223 233 typedef enum { 224 234 kNoProgram = 0, … … 462 472 463 473 Q_DECLARE_METATYPE(ProgramInfo*) 464 474 465 class MPUBLIC ProgramDetail466 {467 public:468 QString channame;469 QString title;470 QString subtitle;471 QDateTime startTime;472 QDateTime endTime;473 };474 typedef vector<ProgramDetail> ProgramDetailList;475 476 475 #endif // MYTHPROGRAM_H_ 477 476 478 477 /* vim: set expandtab tabstop=4 shiftwidth=4: */ -
libs/libmyth/programlist.h
9 9 // of the list while the linked list erase() is always O(1), but all other 10 10 // operations are faster with the deque. 11 11 12 #define PGLIST_USE_LINKED_LIST12 //#define PGLIST_USE_LINKED_LIST 13 13 14 14 // C++ headers 15 15 #ifdef PGLIST_USE_LINKED_LIST … … 29 29 // MythTV headers 30 30 #include "mythexp.h" 31 31 #include "mythdbcon.h" 32 #include "programinfo.h" // for ProgramDetailList33 32 33 class ProgramList; 34 MPUBLIC bool LoadFromProgram( 35 ProgramList &destination, 36 const QString &sql, 37 const MSqlBindings &bindings, 38 const ProgramList &schedList, 39 bool oneChanid); 40 41 42 MPUBLIC bool LoadFromOldRecorded( 43 ProgramList &destination, 44 const QString &sql, 45 const MSqlBindings &bindings); 46 47 MPUBLIC bool LoadFromRecorded( 48 ProgramList &destination, 49 bool orderDescending, 50 bool possiblyInProgressRecordingsOnly, 51 const ProgramList &schedList); 52 53 MPUBLIC bool LoadFromScheduler( 54 ProgramList &destination, 55 bool &hasConflicts, 56 QString altTable = "", 57 int recordid = -1); 58 59 MPUBLIC bool LoadFromScheduler(ProgramList &destination); 60 34 61 /** \class ProgramList 35 62 * \brief List of ProgramInfo instances, with helper functions. 36 63 */ 37 64 class MPUBLIC ProgramList 38 65 { 66 friend class RecordingList; 39 67 public: 40 68 ProgramList(bool auto_delete = true) : autodelete(auto_delete) {} 41 69 ~ProgramList(); … … 45 73 46 74 ProgramInfo *operator[](uint index); 47 75 const ProgramInfo *operator[](uint index) const; 48 bool operator==(const ProgramList &b) const;49 76 50 bool FromScheduler(bool &hasConflicts,51 QString altTable = "",52 int recordid = -1);53 54 bool FromScheduler(void)55 {56 bool dummyConflicts;57 return FromScheduler(dummyConflicts, "", -1);58 };59 60 bool FromProgram(const QString &sql, MSqlBindings &bindings,61 ProgramList &schedList, bool oneChanid = false);62 63 bool FromProgram(const QString &sql, MSqlBindings &bindings)64 {65 ProgramList dummySched;66 return FromProgram(sql, bindings, dummySched);67 }68 69 bool FromRecorded( bool bDescending, ProgramList *pSchedList);70 71 bool FromOldRecorded(const QString &sql, MSqlBindings &bindings);72 73 static bool GetProgramDetailList(74 QDateTime &nextRecordingStart,75 bool *hasConflicts = NULL,76 ProgramDetailList *list = NULL);77 78 77 ProgramInfo *take(uint i); 79 78 iterator erase(iterator it); 80 79 void clear(void); … … 91 90 void push_back(ProgramInfo *pginfo) { pglist.push_back(pginfo); } 92 91 93 92 // compatibility with old Q3PtrList 94 bool isEmpty(void) const { return empty(); }95 size_t count(void) const { return size(); }96 ProgramInfo *at(uint index) { return (*this)[index]; }97 void prepend(ProgramInfo *pginfo) { push_front(pginfo); }98 void append(ProgramInfo *pginfo) { push_back(pginfo); }99 93 void setAutoDelete(bool auto_delete) { autodelete = auto_delete; } 100 94 101 95 protected: -
libs/libmyth/programinfo.cpp
224 224 { 225 225 } 226 226 227 ProgramInfo::ProgramInfo( 228 const MSqlQuery &query, const ProgramList &schedList, bool oneChanid) 229 { 230 if (!query.isValid()) 231 { 232 ProgramInfo blank; 233 *this = blank; 234 } 235 236 chanid = query.value(0).toString(); 237 startts = QDateTime::fromString(query.value(1).toString(), 238 Qt::ISODate); 239 endts = QDateTime::fromString(query.value(2).toString(), 240 Qt::ISODate); 241 recstartts = startts; 242 recendts = endts; 243 lastmodified = startts; 244 title = query.value(3).toString(); 245 subtitle = query.value(4).toString(); 246 description = query.value(5).toString(); 247 category = query.value(6).toString(); 248 chanstr = query.value(7).toString(); 249 chansign = query.value(8).toString(); 250 channame = query.value(9).toString(); 251 repeat = query.value(10).toInt(); 252 chancommfree = COMM_DETECT_COMMFREE == query.value(11).toInt(); 253 chanOutputFilters = query.value(12).toString(); 254 seriesid = query.value(13).toString(); 255 programid = query.value(14).toString(); 256 year = query.value(15).toString(); 257 stars = query.value(16).toString().toFloat(); 258 259 if (query.value(17).isNull() || query.value(17).toString().isEmpty()) 260 { 261 originalAirDate = QDate (0, 1, 1); 262 hasAirDate = false; 263 } 264 else 265 { 266 originalAirDate = 267 QDate::fromString(query.value(17).toString(),Qt::ISODate); 268 269 if (originalAirDate > QDate(1940, 1, 1)) 270 hasAirDate = true; 271 else 272 hasAirDate = false; 273 } 274 catType = query.value(18).toString(); 275 recordid = query.value(19).toInt(); 276 rectype = RecordingType(query.value(20).toInt()); 277 recstatus = RecStatusType(query.value(21).toInt()); 278 findid = query.value(22).toInt(); 279 280 281 ProgramList::const_iterator it = schedList.begin(); 282 for (; it != schedList.end(); ++it) 283 { 284 if (!IsSameTimeslot(**it)) 285 continue; 286 287 const ProgramInfo &s = **it; 288 recordid = s.recordid; 289 recstatus = s.recstatus; 290 rectype = s.rectype; 291 recpriority = s.recpriority; 292 recstartts = s.recstartts; 293 recendts = s.recendts; 294 cardid = s.cardid; 295 inputid = s.inputid; 296 dupin = s.dupin; 297 dupmethod = s.dupmethod; 298 findid = s.findid; 299 300 if (s.recstatus == rsWillRecord || s.recstatus == rsRecording) 301 { 302 if (oneChanid) 303 { 304 chanid = s.chanid; 305 chanstr = s.chanstr; 306 chansign = s.chansign; 307 channame = s.channame; 308 } 309 else if ((chanid != s.chanid) && (chanstr != s.chanstr)) 310 { 311 recstatus = rsOtherShowing; 312 } 313 } 314 } 315 } 316 227 317 /** \fn ProgramInfo::operator=(const ProgramInfo &other) 228 318 * \brief Copies important fields from other ProgramInfo. 229 319 */ … … 932 1022 bindings[":STARTTS1"] = str_startts; 933 1023 bindings[":STARTTS2"] = str_startts; 934 1024 935 schedList.FromScheduler();936 progList.FromProgram(querystr, bindings, schedList);1025 LoadFromScheduler(schedList); 1026 LoadFromProgram(progList, querystr, bindings, schedList, false); 937 1027 938 if (!progList. isEmpty())1028 if (!progList.empty()) 939 1029 { 940 1030 ProgramInfo *pginfo = progList[0]; 941 1031 … … 1012 1102 bindings[":CHANID"] = QString::number(_chanid); 1013 1103 bindings[":STARTTS"] = dtime.toString("yyyy-MM-ddThh:mm:50"); 1014 1104 1015 progList.FromProgram(querystr, bindings, schedList);1105 LoadFromProgram(progList, querystr, bindings, schedList, false); 1016 1106 1017 if (!progList. isEmpty())1107 if (!progList.empty()) 1018 1108 nextstart = (*progList.begin())->startts; 1019 1109 1020 1110 if (nextstart > startts && nextstart < recendts) -
libs/libmyth/programlist.cpp
5 5 #include "mythdb.h" 6 6 #include "util.h" 7 7 #include "programlist.h" 8 #include "programinfo.h" 8 9 9 10 ProgramList::~ProgramList(void) 10 11 { … … 35 36 return (*(const_cast<ProgramList*>(this)))[index]; 36 37 } 37 38 38 bool ProgramList::operator==(const ProgramList &b) const39 {40 const_iterator it_a = pglist.begin();41 const_iterator it_b = b.pglist.begin();42 const_iterator end_a = pglist.end();43 const_iterator end_b = b.pglist.end();44 45 for (; it_a != end_a && it_b != end_b; ++it_a, ++it_b)46 {47 if (*it_a != *it_b)48 return false;49 }50 51 return (it_a == end_a) && (it_b == end_b);52 }53 54 39 ProgramInfo *ProgramList::take(uint index) 55 40 { 56 41 #ifndef PGLIST_USE_LINKED_LIST … … 110 95 #endif 111 96 } 112 97 113 bool ProgramList::FromScheduler(bool &hasConflicts, QString tmptable, 114 int recordid) 115 { 116 clear(); 117 hasConflicts = false; 98 ////////////////////////////////////////////////////////////////////// 118 99 119 if (gContext->IsBackend()) 120 return false; 121 122 QString query; 123 if (tmptable != "") 124 { 125 query = QString("QUERY_GETALLPENDING %1 %2") 126 .arg(tmptable).arg(recordid); 127 } else { 128 query = QString("QUERY_GETALLPENDING"); 129 } 130 131 QStringList slist( query ); 132 if (!gContext->SendReceiveStringList(slist) || slist.size() < 2) 133 { 134 VERBOSE(VB_IMPORTANT, 135 "ProgramList::FromScheduler(): Error querying master."); 136 return false; 137 } 138 139 hasConflicts = slist[0].toInt(); 140 141 bool result = true; 142 QStringList::const_iterator sit = slist.begin()+2; 143 144 while (result && sit != slist.end()) 145 { 146 ProgramInfo *p = new ProgramInfo(); 147 result = p->FromStringList(sit, slist.end()); 148 if (result) 149 pglist.push_back(p); 150 else 151 delete p; 152 } 153 154 if (pglist.size() != slist[1].toUInt()) 155 { 156 VERBOSE(VB_IMPORTANT, 157 "ProgramList::FromScheduler(): Length mismatch"); 158 clear(); 159 result = false; 160 } 161 162 return result; 163 } 164 165 bool ProgramList::FromProgram(const QString &sql, MSqlBindings &bindings, 166 ProgramList &schedList, bool oneChanid) 100 static bool FromProgramQuery( 101 const QString &sql, const MSqlBindings &bindings, MSqlQuery &query) 167 102 { 168 clear();169 170 103 QString querystr = QString( 171 104 "SELECT DISTINCT program.chanid, program.starttime, program.endtime, " 172 105 " program.title, program.subtitle, program.description, " … … 200 133 if (!sql.contains(" LIMIT ")) 201 134 querystr += " LIMIT 20000 "; 202 135 136 query.prepare(querystr); 137 MSqlBindings::const_iterator it; 138 for (it = bindings.begin(); it != bindings.end(); ++it) 139 { 140 if (querystr.contains(it.key())) 141 query.bindValue(it.key(), it.value()); 142 } 143 144 if (!query.exec()) 145 { 146 MythDB::DBError("LoadFromProgramQuery", query); 147 return false; 148 } 149 150 return true; 151 } 152 153 bool LoadFromProgram( 154 ProgramList &destination, 155 const QString &sql, const MSqlBindings &bindings, 156 const ProgramList &schedList, bool oneChanid) 157 { 158 destination.clear(); 159 203 160 MSqlQuery query(MSqlQuery::InitCon()); 161 if (!FromProgramQuery(sql, bindings, query)) 162 return false; 163 164 while (query.next()) 165 destination.push_back(new ProgramInfo(query, schedList, oneChanid)); 166 167 return true; 168 } 169 170 bool LoadFromOldRecorded( 171 ProgramList &destination, const QString &sql, const MSqlBindings &bindings) 172 { 173 destination.clear(); 174 175 MSqlQuery query(MSqlQuery::InitCon()); 176 177 QString querystr = 178 "SELECT oldrecorded.chanid, starttime, endtime, " 179 " title, subtitle, description, category, seriesid, " 180 " programid, channel.channum, channel.callsign, " 181 " channel.name, findid, rectype, recstatus, recordid, " 182 " duplicate " 183 " FROM oldrecorded " 184 " LEFT JOIN channel ON oldrecorded.chanid = channel.chanid " 185 + sql; 186 204 187 query.prepare(querystr); 205 188 MSqlBindings::const_iterator it; 206 189 for (it = bindings.begin(); it != bindings.end(); ++it) 190 { 207 191 if (querystr.contains(it.key())) 208 192 query.bindValue(it.key(), it.value()); 193 } 209 194 210 195 if (!query.exec()) 211 196 { 212 MythDB::DBError(" ProgramList::FromProgram", query);197 MythDB::DBError("LoadFromOldRecorded", query); 213 198 return false; 214 199 } 215 200 … … 228 213 p->subtitle = query.value(4).toString(); 229 214 p->description = query.value(5).toString(); 230 215 p->category = query.value(6).toString(); 231 p-> chanstr= query.value(7).toString();232 p-> chansign= query.value(8).toString();233 p->chan name= query.value(9).toString();234 p-> repeat = query.value(10).toInt();235 p->chan commfree = COMM_DETECT_COMMFREE == query.value(11).toInt();236 p-> chanOutputFilters = query.value(12).toString();237 p-> seriesid = query.value(13).toString();238 p-> programid = query.value(14).toString();239 p-> year = query.value(15).toString();240 p-> stars = query.value(16).toString().toFloat();216 p->seriesid = query.value(7).toString(); 217 p->programid = query.value(8).toString(); 218 p->chanstr = query.value(9).toString(); 219 p->chansign = query.value(10).toString(); 220 p->channame = query.value(11).toString(); 221 p->findid = query.value(12).toInt(); 222 p->rectype = RecordingType(query.value(13).toInt()); 223 p->recstatus = RecStatusType(query.value(14).toInt()); 224 p->recordid = query.value(15).toInt(); 225 p->duplicate = query.value(16).toInt(); 241 226 242 if (query.value(17).isNull() || query.value(17).toString().isEmpty()) 243 { 244 p->originalAirDate = QDate (0, 1, 1); 245 p->hasAirDate = false; 246 } 247 else 248 { 249 p->originalAirDate = 250 QDate::fromString(query.value(17).toString(),Qt::ISODate); 251 252 if (p->originalAirDate > QDate(1940, 1, 1)) 253 p->hasAirDate = true; 254 else 255 p->hasAirDate = false; 256 } 257 p->catType = query.value(18).toString(); 258 p->recordid = query.value(19).toInt(); 259 p->rectype = RecordingType(query.value(20).toInt()); 260 p->recstatus = RecStatusType(query.value(21).toInt()); 261 p->findid = query.value(22).toInt(); 262 263 iterator it = schedList.pglist.begin(); 264 for (; it != schedList.pglist.end(); ++it) 265 { 266 ProgramInfo *s = *it; 267 if (p->IsSameTimeslot(*s)) 268 { 269 p->recordid = s->recordid; 270 p->recstatus = s->recstatus; 271 p->rectype = s->rectype; 272 p->recpriority = s->recpriority; 273 p->recstartts = s->recstartts; 274 p->recendts = s->recendts; 275 p->cardid = s->cardid; 276 p->inputid = s->inputid; 277 p->dupin = s->dupin; 278 p->dupmethod = s->dupmethod; 279 p->findid = s->findid; 280 281 if (s->recstatus == rsWillRecord || 282 s->recstatus == rsRecording) 283 { 284 if (oneChanid) 285 { 286 p->chanid = s->chanid; 287 p->chanstr = s->chanstr; 288 p->chansign = s->chansign; 289 p->channame = s->channame; 290 } 291 else if ((p->chanid != s->chanid) && 292 (p->chanstr != s->chanstr)) 293 { 294 p->recstatus = rsOtherShowing; 295 } 296 } 297 } 298 } 299 300 pglist.push_back(p); 227 destination.push_back(p); 301 228 } 302 229 303 230 return true; 304 231 } 305 232 306 bool ProgramList::FromRecorded( bool bDescending, ProgramList *pSchedList ) 233 bool LoadFromRecorded( 234 ProgramList &destination, 235 bool orderDescending, 236 bool possiblyInProgressTecordingsOnly, 237 const ProgramList &schedList) 307 238 { 308 clear();239 destination.clear(); 309 240 310 241 QString fs_db_name = ""; 311 242 QDateTime rectime = QDateTime::currentDateTime().addSecs( … … 317 248 // ---------------------------------------------------------------------- 318 249 319 250 QMap<QString, int> inUseMap; 251 QString inUseKey; 252 QString inUseForWhat; 253 QDateTime oneHourAgo = QDateTime::currentDateTime().addSecs(-61 * 60); 320 254 321 QString inUseKey; 322 QString inUseForWhat; 323 QDateTime oneHourAgo = QDateTime::currentDateTime().addSecs(-61 * 60); 255 MSqlQuery query(MSqlQuery::InitCon()); 324 256 325 MSqlQuery query(MSqlQuery::InitCon());326 327 257 query.prepare("SELECT DISTINCT chanid, starttime, recusage " 328 258 " FROM inuseprograms WHERE lastupdatetime >= :ONEHOURAGO ;"); 329 259 query.bindValue(":ONEHOURAGO", oneHourAgo); … … 341 271 342 272 if ((inUseForWhat == "player") || 343 273 (inUseForWhat == "preview player") || 344 (inUseForWhat == "PIP player")) 274 (inUseForWhat == "pipplayer") || 275 (inUseForWhat == "pbpplayer")) 345 276 inUseMap[inUseKey] = inUseMap[inUseKey] | FL_INUSEPLAYING; 346 277 else if (inUseForWhat == "recorder") 347 278 inUseMap[inUseKey] = inUseMap[inUseKey] | FL_INUSERECORDING; … … 380 311 "recorded.hostname,channum,name,callsign,commflagged,cutlist," 381 312 "recorded.autoexpire,editing,bookmark,recorded.category," 382 313 "recorded.recgroup,record.dupin,record.dupmethod," 383 "record .recordid,outputfilters,"314 "recorded.recordid,channel.outputfilters," 384 315 "recorded.seriesid,recorded.programid,recorded.filesize, " 385 316 "recorded.lastmodified, recorded.findid, " 386 317 "recorded.originalairdate, recorded.playgroup, " … … 388 319 "recorded.progend, recorded.stars, " 389 320 "recordedprogram.audioprop+0, recordedprogram.videoprop+0, " 390 321 "recordedprogram.subtitletypes+0, recorded.watched, " 391 "recorded.storagegroup " 322 "recorded.storagegroup, " 323 "recorded.transcoded, recorded.recpriority, " 324 "recorded.preserve, recordedprogram.airdate " 392 325 "FROM recorded " 393 326 "LEFT JOIN record ON recorded.recordid = record.recordid " 394 327 "LEFT JOIN channel ON recorded.chanid = channel.chanid " … … 396 329 " ( recorded.chanid = recordedprogram.chanid AND " 397 330 " recorded.progstart = recordedprogram.starttime ) " 398 331 "WHERE ( recorded.deletepending = 0 OR " 399 " recorded.lastmodified <= DATE_SUB(NOW(), INTERVAL 5 MINUTE) " 400 " ) " 401 "ORDER BY recorded.starttime"; 332 " DATE_ADD(recorded.lastmodified, INTERVAL 5 MINUTE) <= NOW() " 333 " ) "; 402 334 403 if ( bDescending ) 404 thequery += " DESC"; 335 if (possiblyInProgressTecordingsOnly) 336 { 337 thequery += 338 " AND recorded.endtime >= NOW() " 339 " AND recorded.starttime <= NOW() "; 340 } 405 341 342 thequery += "ORDER BY recorded.starttime"; 343 thequery += (orderDescending) ? " DESC " : ""; 344 406 345 QString chanorder = gContext->GetSetting("ChannelOrdering", "channum"); 407 346 if (chanorder != "channum") 408 347 thequery += ", " + chanorder; … … 460 399 461 400 proginfo->pathname = query.value(28).toString(); 462 401 463 464 if (proginfo->hostname.isEmpty() || proginfo->hostname.isNull()) 402 if (proginfo->hostname.isEmpty()) 465 403 proginfo->hostname = gContext->GetHostName(); 466 404 467 405 if (!query.value(7).toString().isEmpty()) … … 484 422 flags |= query.value(12).toInt() ? FL_AUTOEXP : 0; 485 423 flags |= query.value(14).toString().length() > 1 ? FL_BOOKMARK : 0; 486 424 flags |= (query.value(35).toInt() == 1) ? FL_WATCHED : 0; 425 flags |= (query.value(37).toInt() == TRANSCODING_COMPLETE) ? 426 FL_TRANSCODED : 0; 427 flags |= (query.value(39).toInt() == 1) ? FL_PRESERVED: 0; 487 428 488 429 inUseKey = query.value(0).toString() + " " + 489 430 query.value(1).toDateTime().toString(Qt::ISODate); … … 520 461 proginfo->playgroup = query.value(27).toString(); 521 462 proginfo->storagegroup = query.value(36).toString(); 522 463 proginfo->recstatus = rsRecorded; 464 proginfo->recpriority = query.value(38).toInt(); 465 proginfo->year = query.value(40).toString(); 523 466 524 if ( (pSchedList != NULL) && (proginfo->recendts > rectime))467 if (proginfo->recendts > rectime) 525 468 { 526 iterator it = pSchedList->pglist.begin();527 for (; it != pSchedList->pglist.end(); ++it)469 ProgramList::const_iterator it = schedList.begin(); 470 for (; it != schedList.end(); ++it) 528 471 { 529 ProgramInfo *s =*it;530 if (s && s->recstatus== rsRecording &&531 proginfo->chanid == s ->chanid&&532 proginfo->recstartts == s ->recstartts)472 const ProgramInfo &s = **it; 473 if (s.recstatus == rsRecording && 474 proginfo->chanid == s.chanid && 475 proginfo->recstartts == s.recstartts) 533 476 { 534 477 proginfo->recstatus = rsRecording; 535 478 break; … … 539 482 540 483 proginfo->stars = query.value(31).toDouble(); 541 484 542 pglist.push_back(proginfo);485 destination.push_back(proginfo); 543 486 } 544 487 545 488 return true; 546 489 } 547 490 548 549 bool ProgramList::FromOldRecorded(const QString &sql, MSqlBindings &bindings) 491 bool LoadFromScheduler( 492 ProgramList &destination, bool &hasConflicts, 493 QString tmptable, int recordid) 550 494 { 551 clear();552 MSqlQuery query(MSqlQuery::InitCon());495 destination.clear(); 496 hasConflicts = false; 553 497 554 query.prepare("SELECT oldrecorded.chanid, starttime, endtime, " 555 " title, subtitle, description, category, seriesid, " 556 " programid, channel.channum, channel.callsign, " 557 " channel.name, findid, rectype, recstatus, recordid, " 558 " duplicate " 559 " FROM oldrecorded " 560 " LEFT JOIN channel ON oldrecorded.chanid = channel.chanid " 561 + sql); 562 query.bindValues(bindings); 498 if (gContext->IsBackend()) 499 return false; 563 500 564 if (!query.exec() || !query.isActive()) 501 QString query; 502 if (!tmptable.isEmpty()) 565 503 { 566 MythDB::DBError("ProgramList::FromOldRecorded", query);567 return false;504 query = QString("QUERY_GETALLPENDING %1 %2") 505 .arg(tmptable).arg(recordid); 568 506 } 569 570 while (query.next()) 507 else 571 508 { 572 ProgramInfo *p = new ProgramInfo; 573 p->chanid = query.value(0).toString(); 574 p->startts = QDateTime::fromString(query.value(1).toString(), 575 Qt::ISODate); 576 p->endts = QDateTime::fromString(query.value(2).toString(), 577 Qt::ISODate); 578 p->recstartts = p->startts; 579 p->recendts = p->endts; 580 p->lastmodified = p->startts; 581 p->title = query.value(3).toString(); 582 p->subtitle = query.value(4).toString(); 583 p->description = query.value(5).toString(); 584 p->category = query.value(6).toString(); 585 p->seriesid = query.value(7).toString(); 586 p->programid = query.value(8).toString(); 587 p->chanstr = query.value(9).toString(); 588 p->chansign = query.value(10).toString(); 589 p->channame = query.value(11).toString(); 590 p->findid = query.value(12).toInt(); 591 p->rectype = RecordingType(query.value(13).toInt()); 592 p->recstatus = RecStatusType(query.value(14).toInt()); 593 p->recordid = query.value(15).toInt(); 594 p->duplicate = query.value(16).toInt(); 509 query = QString("QUERY_GETALLPENDING"); 510 } 595 511 596 pglist.push_back(p); 512 QStringList slist( query ); 513 if (!gContext->SendReceiveStringList(slist) || slist.size() < 2) 514 { 515 VERBOSE(VB_IMPORTANT, 516 "LoadFromScheduler(): Error querying master."); 517 return false; 597 518 } 598 519 599 return true; 600 } 520 hasConflicts = slist[0].toInt(); 601 521 602 bool ProgramList::GetProgramDetailList( 603 QDateTime &nextRecordingStart, bool *hasConflicts, ProgramDetailList *list) 604 { 605 nextRecordingStart = QDateTime(); 522 bool result = true; 523 QStringList::const_iterator sit = slist.begin()+2; 606 524 607 bool dummy; 608 bool *conflicts = (hasConflicts) ? hasConflicts : &dummy; 609 610 ProgramList progList; 611 if (!progList.FromScheduler(*conflicts)) 612 return false; 613 614 // find the earliest scheduled recording 615 ProgramList::const_iterator it = progList.begin(); 616 for (; it != progList.end(); ++it) 525 while (result && sit != slist.end()) 617 526 { 618 if (((*it)->recstatus == rsWillRecord) &&619 (nextRecordingStart.isNull() ||620 nextRecordingStart > (*it)->recstartts))621 {622 nextRecordingStart = (*it)->recstartts;623 }527 ProgramInfo *p = new ProgramInfo(); 528 result = p->FromStringList(sit, slist.end()); 529 if (result) 530 destination.push_back(p); 531 else 532 delete p; 624 533 } 625 534 626 if (!list) 627 return true; 628 629 // save the details of the earliest recording(s) 630 for (it = progList.begin(); it != progList.end(); ++it) 535 if (destination.size() != slist[1].toUInt()) 631 536 { 632 if (((*it)->recstatus == rsWillRecord) && 633 ((*it)->recstartts == nextRecordingStart)) 634 { 635 ProgramDetail prog; 636 prog.channame = (*it)->channame; 637 prog.title = (*it)->title; 638 prog.subtitle = (*it)->subtitle; 639 prog.startTime = (*it)->recstartts; 640 prog.endTime = (*it)->recendts; 641 list->push_back(prog); 642 } 537 VERBOSE(VB_IMPORTANT, 538 "LoadFromScheduler(): Length mismatch."); 539 destination.clear(); 540 result = false; 643 541 } 644 542 645 return true;543 return result; 646 544 } 545 546 bool LoadFromScheduler(ProgramList &destination) 547 { 548 bool dummyConflicts; 549 return LoadFromScheduler(destination, dummyConflicts, "", -1); 550 } -
programs/mythfrontend/playbackbox.cpp
1102 1102 1103 1103 if (m_noRecordingsText) 1104 1104 { 1105 if (!progList. isEmpty())1105 if (!progList.empty()) 1106 1106 m_noRecordingsText->SetVisible(false); 1107 1107 else 1108 1108 { … … 1249 1249 1250 1250 if (m_viewMask != VIEW_NONE && 1251 1251 (p->recgroup != "LiveTV" || m_recGroup == "LiveTV")) 1252 m_progLists[""].p repend(p);1252 m_progLists[""].push_front(p); 1253 1253 1254 1254 asKey = p->MakeUniqueKey(); 1255 1255 if (asCache.contains(asKey)) … … 1263 1263 { 1264 1264 QString tmpTitle = tr("LiveTV"); 1265 1265 sortedList[tmpTitle.toLower()] = tmpTitle; 1266 m_progLists[tmpTitle.toLower()].p repend(p);1266 m_progLists[tmpTitle.toLower()].push_front(p); 1267 1267 m_progLists[tmpTitle.toLower()].setAutoDelete(false); 1268 1268 continue; 1269 1269 } … … 1277 1277 1278 1278 if (!sortedList.contains(sTitle)) 1279 1279 sortedList[sTitle] = p->title; 1280 m_progLists[sortedList[sTitle].toLower()].p repend(p);1280 m_progLists[sortedList[sTitle].toLower()].push_front(p); 1281 1281 m_progLists[sortedList[sTitle].toLower()].setAutoDelete(false); 1282 1282 } 1283 1283 … … 1285 1285 !p->recgroup.isEmpty()) // Show recording groups 1286 1286 { 1287 1287 sortedList[p->recgroup.toLower()] = p->recgroup; 1288 m_progLists[p->recgroup.toLower()].p repend(p);1288 m_progLists[p->recgroup.toLower()].push_front(p); 1289 1289 m_progLists[p->recgroup.toLower()].setAutoDelete(false); 1290 1290 } 1291 1291 … … 1293 1293 !p->category.isEmpty()) // Show categories 1294 1294 { 1295 1295 sortedList[p->category.toLower()] = p->category; 1296 m_progLists[p->category.toLower()].p repend(p);1296 m_progLists[p->category.toLower()].push_front(p); 1297 1297 m_progLists[p->category.toLower()].setAutoDelete(false); 1298 1298 } 1299 1299 … … 1304 1304 QString tmpTitle = QString("(%1)") 1305 1305 .arg(searchRule[p->recordid]); 1306 1306 sortedList[tmpTitle.toLower()] = tmpTitle; 1307 m_progLists[tmpTitle.toLower()].p repend(p);1307 m_progLists[tmpTitle.toLower()].push_front(p); 1308 1308 m_progLists[tmpTitle.toLower()].setAutoDelete(false); 1309 1309 } 1310 1310 … … 1329 1329 if (recidEpisodes[p->recordid] == 1 || 1330 1330 p->recordid == 0 ) 1331 1331 { 1332 m_progLists[m_watchGroupLabel].p repend(p);1332 m_progLists[m_watchGroupLabel].push_front(p); 1333 1333 m_progLists[m_watchGroupLabel].setAutoDelete(false); 1334 1334 } 1335 1335 else … … 4064 4064 } 4065 4065 4066 4066 // Create and add the "All Programs" entry 4067 displayNames.p repend(tr("%1 [%n item(s)]", 0, totalItems)4068 .arg(ProgramInfo::i18n("All Programs")));4069 groupNames.p repend("All Programs");4067 displayNames.push_front(tr("%1 [%n item(s)]", 0, totalItems) 4068 .arg(ProgramInfo::i18n("All Programs"))); 4069 groupNames.push_front("All Programs"); 4070 4070 m_recGroupType["All Programs"] = "recgroup"; 4071 4071 4072 4072 // Find each category, and the number of recordings in each -
programs/mythfrontend/guidegrid.cpp
283 283 m_channelCount = min(m_channelCount, maxchannel + 1); 284 284 updateChannels(); 285 285 286 m_recList.FromScheduler();286 LoadFromScheduler(m_recList); 287 287 fillProgramInfos(); 288 288 updateInfo(); 289 289 … … 611 611 bindings[":CHANID"] = chanid; 612 612 613 613 ProgramList dummy; 614 proglist.FromProgram(querystr, bindings, dummy);614 LoadFromProgram(proglist,querystr, bindings, dummy, false); 615 615 616 616 return proglist; 617 617 } … … 1001 1001 bindings[":STARTTS"] = m_currentStartTime.toString("yyyy-MM-ddThh:mm:00"); 1002 1002 bindings[":ENDTS"] = m_currentEndTime.toString("yyyy-MM-ddThh:mm:00"); 1003 1003 1004 proglist->FromProgram(querystr, bindings, m_recList);1004 LoadFromProgram(*proglist, querystr, bindings, m_recList, false); 1005 1005 1006 1006 QDateTime ts = m_currentStartTime; 1007 1007 … … 1073 1073 1074 1074 vector<ProgramInfo*>::iterator it = unknownlist.begin(); 1075 1075 for (; it != unknownlist.end(); ++it) 1076 proglist-> append(*it);1076 proglist->push_back(*it); 1077 1077 1078 1078 MythRect programRect = m_guideGrid->GetArea(); 1079 1079 … … 1217 1217 1218 1218 if (message == "SCHEDULE_CHANGE") 1219 1219 { 1220 m_recList.FromScheduler();1220 LoadFromScheduler(m_recList); 1221 1221 fillProgramInfos(); 1222 1222 updateInfo(); 1223 1223 } … … 1515 1515 maxchannel = max((int)GetChannelCount() - 1, 0); 1516 1516 m_channelCount = min(m_guideGrid->getChannelCount(), maxchannel + 1); 1517 1517 1518 m_recList.FromScheduler();1518 LoadFromScheduler(m_recList); 1519 1519 fillProgramInfos(); 1520 1520 } 1521 1521 … … 1901 1901 ri.ToggleRecord(); 1902 1902 *pginfo = ri; 1903 1903 1904 m_recList.FromScheduler();1904 LoadFromScheduler(m_recList); 1905 1905 fillProgramInfos(); 1906 1906 updateInfo(); 1907 1907 } -
programs/mythfrontend/progfind.h
1 1 #ifndef PROGFIND_H_ 2 2 #define PROGFIND_H_ 3 3 4 // qt4 // Qt 5 5 #include <QDateTime> 6 6 #include <QEvent> 7 7 8 // myth8 // MythTV 9 9 #include "mythscreentype.h" 10 10 #include "programlist.h" 11 11 #include "mythdialogbox.h" 12 #include "playercontext.h" 12 13 13 14 // mythfrontend 14 15 #include "schedulecommon.h" -
programs/mythfrontend/viewscheduled.cpp
240 240 241 241 m_recgroupList.clear(); 242 242 243 m_recList.FromScheduler(m_conflictBool);243 LoadFromScheduler(m_recList, m_conflictBool); 244 244 245 245 ProgramList::iterator pit = m_recList.begin(); 246 246 QString currentDate; … … 268 268 m_maxinput = pginfo->inputid; 269 269 270 270 QDate date = (pginfo->recstartts).date(); 271 m_recgroupList[date]. append(pginfo);271 m_recgroupList[date].push_back(pginfo); 272 272 m_recgroupList[date].setAutoDelete(false); 273 273 274 m_recgroupList[m_defaultGroup]. append(pginfo);274 m_recgroupList[m_defaultGroup].push_back(pginfo); 275 275 276 276 ++pit; 277 277 } … … 313 313 314 314 plist = m_recgroupList[m_currentGroup]; 315 315 316 int listPos = plist.count() - 1;316 int listPos = ((int) plist.size()) - 1; 317 317 int i; 318 318 for (i = listPos; i >= 0; --i) 319 319 { … … 337 337 338 338 void ViewScheduled::ChangeGroup(MythUIButtonListItem* item) 339 339 { 340 if (!item || m_recList. isEmpty())340 if (!item || m_recList.empty()) 341 341 return; 342 342 343 343 QDate group = qVariantValue<QDate>(item->GetData()); … … 356 356 (GetChild("norecordings_info")); 357 357 358 358 if (norecordingText) 359 norecordingText->SetVisible(m_recList. isEmpty());359 norecordingText->SetVisible(m_recList.empty()); 360 360 361 if (m_recList. isEmpty())361 if (m_recList.empty()) 362 362 return; 363 363 364 364 ProgramList plist; -
programs/mythfrontend/statusbox.cpp
624 624 } 625 625 626 626 ProgramList schedList; 627 schedList.FromScheduler();627 LoadFromScheduler(schedList); 628 628 629 tmpstr = tr("%n matching showing(s)", "", schedList. count());629 tmpstr = tr("%n matching showing(s)", "", schedList.size()); 630 630 AddLogLine(tmpstr, tmpstr); 631 631 632 632 ProgramList::const_iterator it = schedList.begin(); -
programs/mythfrontend/programrecpriority.cpp
1243 1243 m_nowMatch.clear(); 1244 1244 m_recMatch.clear(); 1245 1245 ProgramList schedList; 1246 schedList.FromScheduler();1246 LoadFromScheduler(schedList); 1247 1247 QDateTime now = QDateTime::currentDateTime(); 1248 1248 1249 1249 ProgramList::const_iterator it = schedList.begin(); -
programs/mythfrontend/proglist.cpp
8 8 #include <algorithm> 9 9 using namespace std; 10 10 11 // qt11 // Qt 12 12 #include <QApplication> 13 13 #include <QRegExp> 14 14 15 // libmyth15 // MythTV 16 16 #include "mythcontext.h" 17 17 #include "remoteutil.h" 18 19 // libmythtv20 18 #include "scheduledrecording.h" 21 19 #include "recordingrule.h" 22 20 #include "channelutil.h" 23 21 #include "recordinginfo.h" 24 25 // libmythdb26 22 #include "mythdb.h" 27 23 #include "mythdbcon.h" 28 24 #include "mythverbose.h" 29 30 // libmythui31 25 #include "mythuitext.h" 32 26 #include "mythuibutton.h" 33 27 #include "mythuibuttonlist.h" … … 282 276 menuPopup->AddButton(tr("Upcoming")); 283 277 menuPopup->AddButton(tr("Custom Edit")); 284 278 285 ProgramInfo *pi = m_itemList .at(m_progList->GetCurrentPos());279 ProgramInfo *pi = m_itemList[m_progList->GetCurrentPos()]; 286 280 if (m_type != plPreviouslyRecorded) 287 281 { 288 282 if (pi && pi->recordid > 0) … … 605 599 606 600 void ProgLister::quickRecord() 607 601 { 608 ProgramInfo *pi = m_itemList .at(m_progList->GetCurrentPos());602 ProgramInfo *pi = m_itemList[m_progList->GetCurrentPos()]; 609 603 610 604 if (!pi) 611 605 return; … … 617 611 618 612 void ProgLister::select() 619 613 { 620 ProgramInfo *pi = m_itemList .at(m_progList->GetCurrentPos());614 ProgramInfo *pi = m_itemList[m_progList->GetCurrentPos()]; 621 615 622 616 if (!pi) 623 617 return; … … 630 624 631 625 void ProgLister::edit() 632 626 { 633 ProgramInfo *pi = m_itemList .at(m_progList->GetCurrentPos());627 ProgramInfo *pi = m_itemList[m_progList->GetCurrentPos()]; 634 628 635 629 EditScheduled(pi); 636 630 } 637 631 638 632 void ProgLister::customEdit() 639 633 { 640 ProgramInfo *pi = m_itemList .at(m_progList->GetCurrentPos());634 ProgramInfo *pi = m_itemList[m_progList->GetCurrentPos()]; 641 635 642 636 EditCustom(pi); 643 637 } … … 652 646 653 647 void ProgLister::deleteRule() 654 648 { 655 ProgramInfo *pi = m_itemList .at(m_progList->GetCurrentPos());649 ProgramInfo *pi = m_itemList[m_progList->GetCurrentPos()]; 656 650 657 651 if (!pi || pi->recordid <= 0) 658 652 return; … … 683 677 684 678 void ProgLister::deleteOldEpisode() 685 679 { 686 ProgramInfo *pi = m_itemList .at(m_progList->GetCurrentPos());680 ProgramInfo *pi = m_itemList[m_progList->GetCurrentPos()]; 687 681 688 682 if (!pi) 689 683 return; … … 698 692 if (!ok) 699 693 return; 700 694 701 ProgramInfo *pi = m_itemList .at(m_progList->GetCurrentPos());695 ProgramInfo *pi = m_itemList[m_progList->GetCurrentPos()]; 702 696 703 697 if (!pi) 704 698 return; … … 717 711 718 712 void ProgLister::deleteOldTitle() 719 713 { 720 ProgramInfo *pi = m_itemList .at(m_progList->GetCurrentPos());714 ProgramInfo *pi = m_itemList[m_progList->GetCurrentPos()]; 721 715 722 716 if (!pi) 723 717 return; … … 732 726 if (!ok) 733 727 return; 734 728 735 ProgramInfo *pi = m_itemList .at(m_progList->GetCurrentPos());729 ProgramInfo *pi = m_itemList[m_progList->GetCurrentPos()]; 736 730 737 731 if (!pi) 738 732 return; … … 749 743 750 744 void ProgLister::oldRecordedActions() 751 745 { 752 ProgramInfo *pi = m_itemList .at(m_progList->GetCurrentPos());746 ProgramInfo *pi = m_itemList[m_progList->GetCurrentPos()]; 753 747 754 748 if (!pi) 755 749 return; … … 790 784 791 785 void ProgLister::upcoming() 792 786 { 793 ProgramInfo *pi = m_itemList .at(m_progList->GetCurrentPos());787 ProgramInfo *pi = m_itemList[m_progList->GetCurrentPos()]; 794 788 795 789 if (!pi || m_type == plTitle) 796 790 return; … … 800 794 801 795 void ProgLister::details() 802 796 { 803 ProgramInfo *pi = m_itemList .at(m_progList->GetCurrentPos());797 ProgramInfo *pi = m_itemList[m_progList->GetCurrentPos()]; 804 798 805 799 ShowDetails(pi); 806 800 } … … 1411 1405 } 1412 1406 1413 1407 if (m_type == plPreviouslyRecorded) 1414 m_itemList.FromOldRecorded(where, bindings); 1408 { 1409 LoadFromOldRecorded(m_itemList, where, bindings); 1410 } 1415 1411 else 1416 1412 { 1417 m_schedList.FromScheduler();1418 m_itemList.FromProgram(where, bindings, m_schedList, oneChanid);1413 LoadFromScheduler(m_schedList); 1414 LoadFromProgram(m_itemList, where, bindings, m_schedList, oneChanid); 1419 1415 } 1420 1416 1421 1417 ProgramInfo *s; … … 1469 1465 { 1470 1466 vector<ProgramInfo *>::reverse_iterator r = sortedList.rbegin(); 1471 1467 for (; r != sortedList.rend(); r++) 1472 m_itemList. append(*r);1468 m_itemList.push_back(*r); 1473 1469 } 1474 1470 else 1475 1471 { 1476 1472 vector<ProgramInfo *>::iterator i = sortedList.begin(); 1477 1473 for (; i != sortedList.end(); ++i) 1478 m_itemList. append(*i);1474 m_itemList.push_back(*i); 1479 1475 } 1480 1476 1481 1477 if (m_messageText) 1482 m_messageText->SetVisible( (m_itemList.count() == 0));1478 m_messageText->SetVisible(m_itemList.empty()); 1483 1479 1484 1480 InfoMap infoMap; 1485 1481 ProgramInfo pginfo; … … 1502 1498 comp = new plTitleSort(); 1503 1499 1504 1500 int i; 1505 for (i = m_itemList. count() - 2; i >= 0; i--)1501 for (i = m_itemList.size() - 2; i >= 0; i--) 1506 1502 { 1507 1503 bool dobreak; 1508 1504 if (m_reverseSort) … … 1684 1680 { 1685 1681 if (resulttext == tr("Allow this episode to re-record")) 1686 1682 { 1687 ProgramInfo *pi = m_itemList .at(m_progList->GetCurrentPos());1683 ProgramInfo *pi = m_itemList[m_progList->GetCurrentPos()]; 1688 1684 if (pi) 1689 1685 { 1690 1686 RecordingInfo ri(*pi); … … 1694 1690 } 1695 1691 else if (resulttext == tr("Never record this episode")) 1696 1692 { 1697 ProgramInfo *pi = m_itemList .at(m_progList->GetCurrentPos());1693 ProgramInfo *pi = m_itemList[m_progList->GetCurrentPos()]; 1698 1694 if (pi) 1699 1695 { 1700 1696 RecordingInfo ri(*pi); -
programs/mythfrontend/progfind.cpp
1 2 #include "progfind.h" 3 4 // qt 1 // Qt 5 2 #include <QDateTime> 6 3 #include <QApplication> 7 4 #include <QStringList> … … 9 6 #include <QKeyEvent> 10 7 #include <QEvent> 11 8 12 // libmythdb9 // MythTV 13 10 #include "oldsettings.h" 14 11 #include "mythdb.h" 15 12 #include "mythdbcon.h" 16 13 #include "mythdirs.h" 17 18 // libmyth19 14 #include "mythcontext.h" 20 21 // libmythtv22 15 #include "recordinginfo.h" 23 16 #include "tv.h" 24 25 // libmythui26 17 #include "mythuitext.h" 27 18 #include "mythuitextedit.h" 28 19 #include "mythuibuttonlist.h" … … 33 24 #include "guidegrid.h" 34 25 #include "proglist.h" 35 26 #include "customedit.h" 27 #include "progfind.h" 36 28 37 29 #define LOC QString("ProgFinder: ") 38 30 #define LOC_ERR QString("ProgFinder, Error: ") … … 573 565 574 566 QDateTime progStart = QDateTime::currentDateTime(); 575 567 576 m_schedList.FromScheduler();577 578 568 MSqlBindings bindings; 579 569 QString querystr = "WHERE program.title = :TITLE " 580 570 " AND program.endtime > :ENDTIME "; 581 571 bindings[":TITLE"] = progTitle; 582 572 bindings[":ENDTIME"] = progStart.toString("yyyy-MM-ddThh:mm:50"); 583 573 584 m_showData.FromProgram(querystr, bindings, m_schedList); 574 LoadFromScheduler(m_schedList); 575 LoadFromProgram(m_showData, querystr, bindings, m_schedList, false); 585 576 586 577 updateTimesList(); 587 578 -
programs/mythbackend/mythxml.cpp
571 571 for (RecIter itRecList = recList.begin(); 572 572 itRecList != recList.end(); itRecList++) 573 573 { 574 schedList. append( *itRecList );574 schedList.push_back( *itRecList ); 575 575 } 576 576 577 577 // ---------------------------------------------------------------------- 578 578 579 579 ProgramList progList; 580 LoadFromProgram( progList, sSQL, bindings, schedList, false ); 580 581 581 progList.FromProgram( sSQL, bindings, schedList );582 583 582 // Build Response 584 583 585 584 QDomDocument doc; … … 623 622 list.push_back( NameValue( "NumOfChannels", iChanCount )); 624 623 list.push_back( NameValue( "Details" , bDetails )); 625 624 626 list.push_back( NameValue( "Count" , (int)progList. count() ));625 list.push_back( NameValue( "Count" , (int)progList.size() )); 627 626 list.push_back( NameValue( "AsOf" , QDateTime::currentDateTime() 628 627 .toString( Qt::ISODate ))); 629 628 list.push_back( NameValue( "Version" , MYTH_BINARY_VERSION )); … … 684 683 for (RecIter itRecList = recList.begin(); 685 684 itRecList != recList.end(); itRecList++) 686 685 { 687 schedList. append( *itRecList );686 schedList.push_back( *itRecList ); 688 687 } 689 688 690 689 // ---------------------------------------------------------------------- 691 690 692 691 ProgramList progList; 692 LoadFromProgram( progList, sSQL, bindings, schedList, false ); 693 693 694 progList.FromProgram( sSQL, bindings, schedList );695 696 694 ProgramList::iterator pgit = progList.begin(); 697 695 698 696 if (pgit == progList.end()) … … 971 969 for (RecIter itRecList = recList.begin(); 972 970 itRecList != recList.end(); itRecList++) 973 971 { 974 schedList. append( *itRecList );972 schedList.push_back( *itRecList ); 975 973 } 976 974 977 975 // ---------------------------------------------------------------------- 978 976 979 977 ProgramList progList; 978 LoadFromRecorded( progList, bDescending, false, schedList ); 980 979 981 progList.FromRecorded( bDescending, &schedList );982 983 980 // Build Response XML 984 981 985 982 QDomDocument doc; … … 995 992 996 993 NameValues list; 997 994 998 list.push_back( NameValue( "Count" , (int)progList. count()));995 list.push_back( NameValue( "Count" , (int)progList.size())); 999 996 list.push_back( NameValue( "AsOf" , QDateTime::currentDateTime() 1000 997 .toString( Qt::ISODate ))); 1001 998 list.push_back( NameValue( "Version" , MYTH_BINARY_VERSION )); -
programs/mythbackend/mainserver.cpp
1077 1077 { 1078 1078 if (!pinfo.FromStringList(sit, slist.end())) 1079 1079 break; 1080 slavelist. append(new RecordingInfo(pinfo));1080 slavelist.push_back(new RecordingInfo(pinfo)); 1081 1081 } 1082 1082 m_sched->SlaveConnected(slavelist); 1083 1083 } … … 1276 1276 MythSocket *pbssock = pbs->getSocket(); 1277 1277 QString playbackhost = pbs->getHostname(); 1278 1278 1279 QString fs_db_name = ""; 1280 1281 QDateTime rectime = QDateTime::currentDateTime().addSecs( 1282 -gContext->GetNumSetting("RecordOverTime")); 1283 RecIter ri; 1284 RecList schedList; 1279 RecList rlSchedList; 1285 1280 if (m_sched) 1286 m_sched->getAllPending(&schedList); 1281 m_sched->getAllPending(&rlSchedList); 1282 ProgramList schedList; 1283 while (!rlSchedList.empty()) 1284 { 1285 schedList.push_front(rlSchedList.front()); 1286 rlSchedList.pop_front(); 1287 } 1287 1288 1288 QString ip = gContext->GetSetting("BackendServerIP"); 1289 QString port = gContext->GetSetting("BackendServerPort"); 1289 ProgramList destination; 1290 LoadFromRecorded( 1291 destination, (type == "Delete"), (type == "Recording"), schedList); 1290 1292 1291 QMap<QString, int> inUseMap; 1292 QString inUseKey; 1293 QString inUseForWhat; 1294 QDateTime oneHourAgo = QDateTime::currentDateTime().addSecs(-61 * 60); 1295 1296 MSqlQuery query(MSqlQuery::InitCon()); 1297 1298 query.prepare("SELECT DISTINCT chanid, starttime, recusage " 1299 " FROM inuseprograms WHERE lastupdatetime >= :ONEHOURAGO ;"); 1300 query.bindValue(":ONEHOURAGO", oneHourAgo); 1301 1302 if (query.exec() && query.isActive() && query.size() > 0) 1303 while (query.next()) 1304 { 1305 inUseKey = query.value(0).toString() + " " + 1306 query.value(1).toDateTime().toString(Qt::ISODate); 1307 inUseForWhat = query.value(2).toString(); 1308 1309 if (!inUseMap.contains(inUseKey)) 1310 inUseMap[inUseKey] = 0; 1311 1312 if ((inUseForWhat == "player") || 1313 (inUseForWhat == "preview player") || 1314 (inUseForWhat == "pipplayer") || 1315 (inUseForWhat == "pbpplayer")) 1316 inUseMap[inUseKey] = inUseMap[inUseKey] | FL_INUSEPLAYING; 1317 else if (inUseForWhat == "recorder") 1318 inUseMap[inUseKey] = inUseMap[inUseKey] | FL_INUSERECORDING; 1319 } 1320 1321 1322 QString thequery = 1323 "SELECT recorded.chanid,recorded.starttime,recorded.endtime," 1324 "recorded.title,recorded.subtitle,recorded.description," 1325 "recorded.hostname,channum,name,callsign,commflagged,cutlist," 1326 "recorded.autoexpire,editing,bookmark,recorded.category," 1327 "recorded.recgroup,record.dupin,record.dupmethod," 1328 "recorded.recordid,channel.outputfilters," 1329 "recorded.seriesid,recorded.programid,recorded.filesize, " 1330 "recorded.lastmodified, recorded.findid, " 1331 "recorded.originalairdate, recorded.playgroup, " 1332 "recorded.basename, recorded.progstart, " 1333 "recorded.progend, recorded.stars, " 1334 "recordedprogram.audioprop+0, recordedprogram.videoprop+0, " 1335 "recordedprogram.subtitletypes+0, transcoded, " 1336 "recorded.recpriority, watched, recorded.preserve, " 1337 "recorded.storagegroup, recordedprogram.airdate " 1338 "FROM recorded " 1339 "LEFT JOIN record ON recorded.recordid = record.recordid " 1340 "LEFT JOIN channel ON recorded.chanid = channel.chanid " 1341 "LEFT JOIN recordedprogram ON " 1342 " ( recorded.chanid = recordedprogram.chanid AND " 1343 " recorded.progstart = recordedprogram.starttime ) " 1344 "WHERE ( recorded.deletepending = 0 OR " 1345 " DATE_ADD(recorded.lastmodified, INTERVAL 5 MINUTE) <= NOW() " 1346 " ) "; 1347 1348 if (type == "Recording") 1349 thequery += "AND recorded.endtime >= NOW() AND " 1350 "recorded.starttime <= NOW()"; 1351 1352 thequery += "ORDER BY recorded.starttime"; 1353 1354 if (type == "Delete") 1355 thequery += " DESC"; 1356 1357 QString chanorder = gContext->GetSetting("ChannelOrdering", "channum"); 1358 if (chanorder != "channum") 1359 thequery += ", " + chanorder; 1360 else // approximation which the DB can handle 1361 thequery += ",atsc_major_chan,atsc_minor_chan,channum,callsign"; 1362 1363 QStringList outputlist; 1364 QString fileprefix = gContext->GetFilePrefix(); 1293 QStringList outputlist(QString::number(destination.size())); 1365 1294 QMap<QString, QString> backendIpMap; 1366 1295 QMap<QString, QString> backendPortMap; 1296 QString ip = gContext->GetSetting("BackendServerIP"); 1297 QString port = gContext->GetSetting("BackendServerPort"); 1367 1298 1368 query.prepare(thequery); 1369 1370 if (!query.exec() || !query.isActive()) 1299 ProgramList::iterator it = destination.begin(); 1300 for (it = destination.begin(); it != destination.end(); ++it) 1371 1301 { 1372 MythDB::DBError("ProgramList::FromRecorded", query); 1373 outputlist << "0"; 1374 } 1375 else 1376 { 1377 outputlist << QString::number(query.size()); 1302 ProgramInfo *proginfo = *it; 1303 PlaybackSock *slave = NULL; 1378 1304 1379 while (query.next()) 1380 { 1381 ProgramInfo *proginfo = new ProgramInfo; 1305 if (proginfo->hostname != gContext->GetHostName()) 1306 slave = getSlaveByHostname(proginfo->hostname); 1382 1307 1383 proginfo->chanid = query.value(0).toString(); 1384 proginfo->startts = query.value(29).toDateTime(); 1385 proginfo->endts = query.value(30).toDateTime(); 1386 proginfo->recstartts = query.value(1).toDateTime(); 1387 proginfo->recendts = query.value(2).toDateTime(); 1388 proginfo->title = query.value(3).toString(); 1389 proginfo->subtitle = query.value(4).toString(); 1390 proginfo->description = query.value(5).toString(); 1391 proginfo->hostname = query.value(6).toString(); 1392 1393 proginfo->dupin = RecordingDupInType(query.value(17).toInt()); 1394 proginfo->dupmethod = RecordingDupMethodType(query.value(18).toInt()); 1395 proginfo->recordid = query.value(19).toInt(); 1396 proginfo->chanOutputFilters = query.value(20).toString(); 1397 proginfo->seriesid = query.value(21).toString(); 1398 proginfo->programid = query.value(22).toString(); 1399 proginfo->filesize = stringToLongLong(query.value(23).toString()); 1400 proginfo->lastmodified = 1401 QDateTime::fromString(query.value(24).toString(), 1402 Qt::ISODate); 1403 proginfo->findid = query.value(25).toInt(); 1404 1405 if (query.value(26).isNull() || 1406 query.value(26).toString().isEmpty()) 1308 if ((proginfo->hostname == gContext->GetHostName()) || 1309 (!slave && masterBackendOverride)) 1310 { 1311 proginfo->pathname = QString("myth://") + ip + ":" + port 1312 + "/" + proginfo->pathname; 1313 if (proginfo->filesize == 0) 1407 1314 { 1408 proginfo->originalAirDate = QDate (0, 1, 1); 1409 proginfo->hasAirDate = false; 1410 } 1411 else 1412 { 1413 proginfo->originalAirDate = 1414 QDate::fromString(query.value(26).toString(),Qt::ISODate); 1415 1416 if (proginfo->originalAirDate > QDate(1940, 1, 1)) 1417 proginfo->hasAirDate = true; 1418 else 1419 proginfo->hasAirDate = false; 1420 } 1421 1422 proginfo->pathname = query.value(28).toString(); 1423 1424 if (proginfo->hostname.isEmpty()) 1425 proginfo->hostname = gContext->GetHostName(); 1426 1427 if (!query.value(7).toString().isEmpty()) 1428 { 1429 proginfo->chanstr = query.value(7).toString(); 1430 proginfo->channame = query.value(8).toString(); 1431 proginfo->chansign = query.value(9).toString(); 1432 } 1433 else 1434 { 1435 proginfo->chanstr = "#" + proginfo->chanid; 1436 proginfo->channame = "#" + proginfo->chanid; 1437 proginfo->chansign = "#" + proginfo->chanid; 1438 } 1439 1440 // Taken out of programinfo.cpp just to reduce the number of queries 1441 int flags = 0; 1442 flags |= (query.value(10).toInt() == 1) ? FL_COMMFLAG : 0; 1443 flags |= (query.value(11).toInt() == 1) ? FL_CUTLIST : 0; 1444 flags |= query.value(12).toInt() ? FL_AUTOEXP : 0; 1445 flags |= (query.value(14).toInt() == 1) ? FL_BOOKMARK : 0; 1446 flags |= (query.value(35).toInt() == TRANSCODING_COMPLETE) ? 1447 FL_TRANSCODED : 0; 1448 flags |= (query.value(37).toInt() == 1) ? FL_WATCHED : 0; 1449 flags |= (query.value(38).toInt() == 1) ? FL_PRESERVED : 0; 1450 1451 inUseKey = query.value(0).toString() + " " + 1452 query.value(1).toDateTime().toString(Qt::ISODate); 1453 if (inUseMap.contains(inUseKey)) 1454 flags |= inUseMap[inUseKey]; 1455 1456 if (query.value(13).toInt()) 1457 { 1458 flags |= FL_EDITING; 1459 } 1460 else if (query.value(10).toInt() == COMM_FLAG_PROCESSING) 1461 { 1462 if (JobQueue::IsJobRunning(JOB_COMMFLAG, proginfo)) 1463 flags |= FL_EDITING; 1464 else 1465 proginfo->SetCommFlagged(COMM_FLAG_NOT_FLAGGED); 1466 } 1467 1468 proginfo->audioproperties = query.value(32).toInt(); 1469 proginfo->videoproperties = query.value(33).toInt(); 1470 proginfo->subtitleType = query.value(34).toInt(); 1471 1472 proginfo->programflags = flags; 1473 1474 proginfo->category = query.value(15).toString(); 1475 1476 proginfo->recgroup = query.value(16).toString(); 1477 proginfo->playgroup = query.value(27).toString(); 1478 proginfo->storagegroup = 1479 query.value(39).toString(); 1480 1481 proginfo->recpriority = query.value(36).toInt(); 1482 proginfo->year = query.value(40).toString(); 1483 1484 proginfo->recstatus = rsRecorded; 1485 if (proginfo->recendts > rectime) 1486 { 1487 for (ri = schedList.begin(); ri != schedList.end(); ri++) 1315 QString tmpURL = GetPlaybackURL(proginfo); 1316 QFile checkFile(tmpURL); 1317 if (!tmpURL.isEmpty() && checkFile.exists()) 1488 1318 { 1489 if ((*ri) && (*ri)->recstatus == rsRecording && 1490 proginfo->chanid == (*ri)->chanid && 1491 proginfo->recstartts == (*ri)->recstartts) 1492 { 1493 proginfo->recstatus = rsRecording; 1494 break; 1495 } 1319 proginfo->filesize = checkFile.size(); 1320 if (proginfo->recendts < QDateTime::currentDateTime()) 1321 proginfo->SetFilesize(proginfo->filesize); 1496 1322 } 1497 1323 } 1498 1499 proginfo->stars = query.value(31).toDouble(); 1500 1501 PlaybackSock *slave = NULL; 1502 1503 if (proginfo->hostname != gContext->GetHostName()) 1504 slave = getSlaveByHostname(proginfo->hostname); 1505 1506 if ((proginfo->hostname == gContext->GetHostName()) || 1507 (!slave && masterBackendOverride)) 1324 } 1325 else if (!slave) 1326 { 1327 proginfo->pathname = GetPlaybackURL(proginfo); 1328 if (proginfo->pathname.isEmpty()) 1508 1329 { 1509 proginfo->pathname = QString("myth://") + ip + ":" + port 1510 + "/" + proginfo->pathname; 1511 if (proginfo->filesize == 0) 1512 { 1513 QString tmpURL = GetPlaybackURL(proginfo); 1514 QFile checkFile(tmpURL); 1515 if (!tmpURL.isEmpty() && checkFile.exists()) 1516 { 1517 proginfo->filesize = checkFile.size(); 1518 if (proginfo->recendts < QDateTime::currentDateTime()) 1519 proginfo->SetFilesize(proginfo->filesize); 1520 } 1521 } 1330 VERBOSE(VB_IMPORTANT, 1331 "MainServer::HandleQueryRecordings()" 1332 "\n\t\t\tCouldn't find backend for: " + 1333 QString("\n\t\t\t%1 : \"%2\"") 1334 .arg(proginfo->title).arg(proginfo->subtitle)); 1335 1336 proginfo->filesize = 0; 1337 proginfo->pathname = "file not found"; 1522 1338 } 1523 else if (!slave) 1339 } 1340 else 1341 { 1342 if (proginfo->filesize == 0) 1524 1343 { 1525 proginfo->pathname = GetPlaybackURL(proginfo); 1526 if (proginfo->pathname.isEmpty()) 1344 if (!slave->FillProgramInfo(proginfo, playbackhost)) 1527 1345 { 1528 1346 VERBOSE(VB_IMPORTANT, 1529 1347 "MainServer::HandleQueryRecordings()" 1530 "\n\t\t\tCouldn't find backend for: " + 1531 QString("\n\t\t\t%1 : \"%2\"") 1532 .arg(proginfo->title).arg(proginfo->subtitle)); 1533 1534 proginfo->filesize = 0; 1535 proginfo->pathname = "file not found"; 1348 "\n\t\t\tCould not fill program info " 1349 "from backend"); 1536 1350 } 1537 }1538 else1539 {1540 if (proginfo->filesize == 0)1541 {1542 if (!slave->FillProgramInfo(proginfo, playbackhost))1543 {1544 VERBOSE(VB_IMPORTANT,1545 "MainServer::HandleQueryRecordings()"1546 "\n\t\t\tCould not fill program info "1547 "from backend");1548 }1549 else1550 {1551 if (proginfo->recendts < QDateTime::currentDateTime())1552 proginfo->SetFilesize(proginfo->filesize);1553 }1554 }1555 1351 else 1556 1352 { 1557 ProgramInfo *p = proginfo; 1558 if (!backendIpMap.contains(p->hostname)) 1559 backendIpMap[p->hostname] = 1560 gContext->GetSettingOnHost("BackendServerIp", 1561 p->hostname); 1562 if (!backendPortMap.contains(p->hostname)) 1563 backendPortMap[p->hostname] = 1564 gContext->GetSettingOnHost("BackendServerPort", 1565 p->hostname); 1566 p->pathname = QString("myth://") + 1567 backendIpMap[p->hostname] + ":" + 1568 backendPortMap[p->hostname] + "/" + 1569 p->pathname; 1353 if (proginfo->recendts < QDateTime::currentDateTime()) 1354 proginfo->SetFilesize(proginfo->filesize); 1570 1355 } 1571 1356 } 1357 else 1358 { 1359 ProgramInfo *p = proginfo; 1360 if (!backendIpMap.contains(p->hostname)) 1361 backendIpMap[p->hostname] = 1362 gContext->GetSettingOnHost("BackendServerIp", 1363 p->hostname); 1364 if (!backendPortMap.contains(p->hostname)) 1365 backendPortMap[p->hostname] = 1366 gContext->GetSettingOnHost("BackendServerPort", 1367 p->hostname); 1368 p->pathname = QString("myth://") + 1369 backendIpMap[p->hostname] + ":" + 1370 backendPortMap[p->hostname] + "/" + 1371 p->pathname; 1372 } 1373 } 1572 1374 1573 1574 1375 if (slave) 1376 slave->DownRef(); 1575 1377 1576 proginfo->ToStringList(outputlist); 1577 1578 delete proginfo; 1579 } 1378 proginfo->ToStringList(outputlist); 1580 1379 } 1581 1380 1582 for (ri = schedList.begin(); ri != schedList.end(); ri++)1583 delete (*ri);1584 1585 1381 SendResponse(pbssock, outputlist); 1586 1382 } 1587 1383 -
programs/mythbackend/scheduler.cpp
439 439 void Scheduler::FillRecordListFromMaster(void) 440 440 { 441 441 RecordingList schedList(false); 442 schedList.FromScheduler(); 442 bool dummy; 443 LoadFromScheduler(schedList, dummy); 443 444 444 445 QMutexLocker lockit(reclist_lock); 445 446 -
programs/mythwelcome/welcomedialog.h
6 6 7 7 // myth 8 8 #include "tvremoteutil.h" 9 #include "program info.h"9 #include "programdetail.h" 10 10 #include "mythscreentype.h" 11 11 #include "mythuibutton.h" 12 12 #include "mythuitext.h" -
programs/mythwelcome/welcomedialog.cpp
16 16 #include "mythdbcon.h" 17 17 #include "lcddevice.h" 18 18 #include "tv.h" 19 #include "programlist.h"20 19 #include "uitypes.h" 21 20 #include "compat.h" 22 21 #include "mythdirs.h" … … 520 519 return false; 521 520 } 522 521 523 ProgramList::GetProgramDetailList(522 GetProgramDetailList( 524 523 m_nextRecordingStart, &m_hasConflicts, &m_scheduledList); 525 524 526 525 updateStatus(); -
programs/mythshutdown/main.cpp
13 13 #include "mythsystem.h" 14 14 #include "mythverbose.h" 15 15 #include "mythversion.h" 16 #include "programinfo.h" 17 #include "programlist.h" 16 #include "programdetail.h" 18 17 #include "jobqueue.h" 19 18 #include "tv.h" 20 19 #include "remoteutil.h" … … 412 411 } 413 412 414 413 QDateTime nextRecordingStart; 415 ProgramList::GetProgramDetailList(nextRecordingStart);414 GetProgramDetailList(nextRecordingStart); 416 415 417 416 // set the wakeup time for the next scheduled recording 418 417 if (!nextRecordingStart.isNull())