00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00021
00022 #include <QList>
00023
00024 #include <math.h>
00025
00026 #include "channel.h"
00027
00028 #include "compat.h"
00029 #include "mythdbcon.h"
00030 #include "mythdirs.h"
00031 #include "mythversion.h"
00032 #include "mythcorecontext.h"
00033 #include "channelutil.h"
00034 #include "sourceutil.h"
00035 #include "cardutil.h"
00036 #include "datadirect.h"
00037
00038 #include "serviceUtil.h"
00039
00041
00043
00044 DTC::ChannelInfoList* Channel::GetChannelInfoList( int nSourceID,
00045 int nStartIndex,
00046 int nCount )
00047 {
00048 vector<uint> chanList;
00049
00050 chanList = ChannelUtil::GetChanIDs(nSourceID);
00051
00052
00053
00054
00055
00056 DTC::ChannelInfoList *pChannelInfos = new DTC::ChannelInfoList();
00057
00058 nStartIndex = min( nStartIndex, (int)chanList.size() );
00059 nCount = (nCount > 0) ? min( nCount, (int)chanList.size() ) : chanList.size();
00060 int nEndIndex = min((nStartIndex + nCount), (int)chanList.size() );
00061
00062 for( int n = nStartIndex; n < nEndIndex; n++)
00063 {
00064 DTC::ChannelInfo *pChannelInfo = pChannelInfos->AddNewChannelInfo();
00065
00066 int chanid = chanList.at(n);
00067 QString channum = ChannelUtil::GetChanNum(chanid);
00068 QString format, modulation, freqtable, freqid, dtv_si_std,
00069 xmltvid, default_authority, icon;
00070 int finetune, program_number;
00071 uint64_t frequency;
00072 uint atscmajor, atscminor, transportid, networkid, mplexid;
00073 bool commfree = false;
00074 bool eit = false;
00075 bool visible = true;
00076
00077 if (ChannelUtil::GetExtendedChannelData( nSourceID, channum, format, modulation,
00078 freqtable, freqid, finetune, frequency,
00079 dtv_si_std, program_number, atscmajor,
00080 atscminor, transportid, networkid, mplexid,
00081 commfree, eit, visible, xmltvid, default_authority, icon ))
00082 {
00083 pChannelInfo->setChanId(chanid);
00084 pChannelInfo->setChanNum(channum);
00085 pChannelInfo->setCallSign(ChannelUtil::GetCallsign(chanid));
00086 pChannelInfo->setIconURL(icon);
00087 pChannelInfo->setChannelName(ChannelUtil::GetServiceName(chanid));
00088 pChannelInfo->setMplexId(mplexid);
00089 pChannelInfo->setServiceId(program_number);
00090 pChannelInfo->setATSCMajorChan(atscmajor);
00091 pChannelInfo->setATSCMinorChan(atscminor);
00092 pChannelInfo->setFormat(format);
00093 pChannelInfo->setModulation(modulation);
00094 pChannelInfo->setFrequencyTable(freqtable);
00095 pChannelInfo->setFineTune(finetune);
00096 pChannelInfo->setFrequency((long)frequency);
00097 pChannelInfo->setFrequencyId(freqid);
00098 pChannelInfo->setSIStandard(dtv_si_std);
00099 pChannelInfo->setTransportId(transportid);
00100 pChannelInfo->setNetworkId(networkid);
00101 pChannelInfo->setChanFilters(ChannelUtil::GetVideoFilters(nSourceID, channum));
00102 pChannelInfo->setSourceId(nSourceID);
00103 pChannelInfo->setCommFree(commfree);
00104 pChannelInfo->setUseEIT(eit);
00105 pChannelInfo->setVisible(visible);
00106 pChannelInfo->setXMLTVID(xmltvid);
00107 pChannelInfo->setDefaultAuth(default_authority);
00108 }
00109 }
00110
00111 int curPage = 0, totalPages = 0;
00112 if (nCount == 0)
00113 totalPages = 1;
00114 else
00115 totalPages = (int)ceil((float)chanList.size() / nCount);
00116
00117 if (totalPages == 1)
00118 curPage = 1;
00119 else
00120 {
00121 curPage = (int)ceil((float)nStartIndex / nCount) + 1;
00122 }
00123
00124 pChannelInfos->setStartIndex ( nStartIndex );
00125 pChannelInfos->setCount ( nCount );
00126 pChannelInfos->setCurrentPage ( curPage );
00127 pChannelInfos->setTotalPages ( totalPages );
00128 pChannelInfos->setTotalAvailable( chanList.size() );
00129 pChannelInfos->setAsOf ( QDateTime::currentDateTime() );
00130 pChannelInfos->setVersion ( MYTH_BINARY_VERSION );
00131 pChannelInfos->setProtoVer ( MYTH_PROTO_VERSION );
00132
00133 return pChannelInfos;
00134 }
00135
00137
00139
00140 DTC::ChannelInfo* Channel::GetChannelInfo( int nChanID )
00141 {
00142 if (nChanID == 0)
00143 throw( QString("Channel ID appears invalid."));
00144
00145 DTC::ChannelInfo *pChannelInfo = new DTC::ChannelInfo();
00146
00147 QString channum = ChannelUtil::GetChanNum(nChanID);
00148 uint sourceid = ChannelUtil::GetSourceIDForChannel(nChanID);
00149 QString format, modulation, freqtable, freqid, dtv_si_std,
00150 xmltvid, default_authority, icon;
00151 int finetune, program_number;
00152 uint64_t frequency;
00153 uint atscmajor, atscminor, transportid, networkid, mplexid;
00154 bool commfree = false;
00155 bool eit = false;
00156 bool visible = true;
00157
00158 if (ChannelUtil::GetExtendedChannelData( sourceid, channum, format, modulation,
00159 freqtable, freqid, finetune, frequency,
00160 dtv_si_std, program_number, atscmajor,
00161 atscminor, transportid, networkid, mplexid,
00162 commfree, eit, visible, xmltvid, default_authority, icon ))
00163 {
00164 pChannelInfo->setChanId(nChanID);
00165 pChannelInfo->setChanNum(channum);
00166 pChannelInfo->setCallSign(ChannelUtil::GetCallsign(nChanID));
00167 pChannelInfo->setIconURL(icon);
00168 pChannelInfo->setChannelName(ChannelUtil::GetServiceName(nChanID));
00169 pChannelInfo->setMplexId(mplexid);
00170 pChannelInfo->setServiceId(program_number);
00171 pChannelInfo->setATSCMajorChan(atscmajor);
00172 pChannelInfo->setATSCMinorChan(atscminor);
00173 pChannelInfo->setFormat(format);
00174 pChannelInfo->setModulation(modulation);
00175 pChannelInfo->setFrequencyTable(freqtable);
00176 pChannelInfo->setFineTune(finetune);
00177 pChannelInfo->setFrequency((long)frequency);
00178 pChannelInfo->setFrequencyId(freqid);
00179 pChannelInfo->setSIStandard(dtv_si_std);
00180 pChannelInfo->setTransportId(transportid);
00181 pChannelInfo->setNetworkId(networkid);
00182 pChannelInfo->setChanFilters(ChannelUtil::GetVideoFilters(sourceid, channum));
00183 pChannelInfo->setSourceId(sourceid);
00184 pChannelInfo->setCommFree(commfree);
00185 pChannelInfo->setUseEIT(eit);
00186 pChannelInfo->setVisible(visible);
00187 pChannelInfo->setXMLTVID(xmltvid);
00188 pChannelInfo->setDefaultAuth(default_authority);
00189 }
00190 else
00191 throw( QString("Channel ID appears invalid."));
00192
00193 return pChannelInfo;
00194 }
00195
00196 bool Channel::UpdateDBChannel( uint MplexID,
00197 uint SourceID,
00198 uint ChannelID,
00199 const QString &CallSign,
00200 const QString &ChannelName,
00201 const QString &ChannelNumber,
00202 uint ServiceID,
00203 uint ATSCMajorChannel,
00204 uint ATSCMinorChannel,
00205 bool UseEIT,
00206 bool visible,
00207 const QString &FrequencyID,
00208 const QString &Icon,
00209 const QString &Format,
00210 const QString &XMLTVID,
00211 const QString &DefaultAuthority )
00212 {
00213 bool bResult = false;
00214
00215 bResult = ChannelUtil::UpdateChannel( MplexID, SourceID, ChannelID,
00216 CallSign, ChannelName, ChannelNumber,
00217 ServiceID, ATSCMajorChannel, ATSCMinorChannel,
00218 UseEIT, !visible, false, FrequencyID,
00219 Icon, Format, XMLTVID, DefaultAuthority );
00220
00221 return bResult;
00222 }
00223
00224 bool Channel::AddDBChannel( uint MplexID,
00225 uint SourceID,
00226 uint ChannelID,
00227 const QString &CallSign,
00228 const QString &ChannelName,
00229 const QString &ChannelNumber,
00230 uint ServiceID,
00231 uint ATSCMajorChannel,
00232 uint ATSCMinorChannel,
00233 bool UseEIT,
00234 bool visible,
00235 const QString &FrequencyID,
00236 const QString &Icon,
00237 const QString &Format,
00238 const QString &XMLTVID,
00239 const QString &DefaultAuthority )
00240 {
00241 bool bResult = false;
00242
00243 bResult = ChannelUtil::CreateChannel( MplexID, SourceID, ChannelID,
00244 CallSign, ChannelName, ChannelNumber,
00245 ServiceID, ATSCMajorChannel, ATSCMinorChannel,
00246 UseEIT, !visible, false, FrequencyID,
00247 Icon, Format, XMLTVID, DefaultAuthority );
00248
00249 return bResult;
00250 }
00251
00252 bool Channel::RemoveDBChannel( uint nChannelID )
00253 {
00254 bool bResult = false;
00255
00256 bResult = ChannelUtil::DeleteChannel( nChannelID );
00257
00258 return bResult;
00259 }
00260
00262
00264
00265 DTC::VideoSourceList* Channel::GetVideoSourceList()
00266 {
00267 MSqlQuery query(MSqlQuery::InitCon());
00268
00269 if (!query.isConnected())
00270 throw( QString("Database not open while trying to list "
00271 "Video Sources."));
00272
00273 query.prepare("SELECT sourceid, name, xmltvgrabber, userid, "
00274 "freqtable, lineupid, password, useeit, configpath, "
00275 "dvb_nit_id FROM videosource "
00276 "ORDER BY sourceid" );
00277
00278 if (!query.exec())
00279 {
00280 MythDB::DBError("MythAPI::GetVideoSourceList()", query);
00281
00282 throw( QString( "Database Error executing query." ));
00283 }
00284
00285
00286
00287
00288
00289 DTC::VideoSourceList* pList = new DTC::VideoSourceList();
00290
00291 while (query.next())
00292 {
00293
00294 DTC::VideoSource *pVideoSource = pList->AddNewVideoSource();
00295
00296 pVideoSource->setId ( query.value(0).toInt() );
00297 pVideoSource->setSourceName ( query.value(1).toString() );
00298 pVideoSource->setGrabber ( query.value(2).toString() );
00299 pVideoSource->setUserId ( query.value(3).toString() );
00300 pVideoSource->setFreqTable ( query.value(4).toString() );
00301 pVideoSource->setLineupId ( query.value(5).toString() );
00302 pVideoSource->setPassword ( query.value(6).toString() );
00303 pVideoSource->setUseEIT ( query.value(7).toBool() );
00304 pVideoSource->setConfigPath ( query.value(8).toString() );
00305 pVideoSource->setNITId ( query.value(9).toInt() );
00306 }
00307
00308 pList->setAsOf ( QDateTime::currentDateTime() );
00309 pList->setVersion ( MYTH_BINARY_VERSION );
00310 pList->setProtoVer ( MYTH_PROTO_VERSION );
00311
00312 return pList;
00313 }
00314
00316
00318
00319 DTC::VideoSource* Channel::GetVideoSource( uint nSourceID )
00320 {
00321 MSqlQuery query(MSqlQuery::InitCon());
00322
00323 if (!query.isConnected())
00324 throw( QString("Database not open while trying to list "
00325 "Video Sources."));
00326
00327 query.prepare("SELECT name, xmltvgrabber, userid, "
00328 "freqtable, lineupid, password, useeit, configpath, "
00329 "dvb_nit_id FROM videosource WHERE sourceid = :SOURCEID "
00330 "ORDER BY sourceid" );
00331 query.bindValue(":SOURCEID", nSourceID);
00332
00333 if (!query.exec())
00334 {
00335 MythDB::DBError("MythAPI::GetVideoSource()", query);
00336
00337 throw( QString( "Database Error executing query." ));
00338 }
00339
00340
00341
00342
00343
00344 DTC::VideoSource *pVideoSource = new DTC::VideoSource();
00345
00346 if (query.next())
00347 {
00348 pVideoSource->setId ( nSourceID );
00349 pVideoSource->setSourceName ( query.value(0).toString() );
00350 pVideoSource->setGrabber ( query.value(1).toString() );
00351 pVideoSource->setUserId ( query.value(2).toString() );
00352 pVideoSource->setFreqTable ( query.value(3).toString() );
00353 pVideoSource->setLineupId ( query.value(4).toString() );
00354 pVideoSource->setPassword ( query.value(5).toString() );
00355 pVideoSource->setUseEIT ( query.value(6).toBool() );
00356 pVideoSource->setConfigPath ( query.value(7).toString() );
00357 pVideoSource->setNITId ( query.value(8).toInt() );
00358 }
00359
00360 return pVideoSource;
00361 }
00362
00364
00366
00367 bool Channel::UpdateVideoSource( uint nSourceId,
00368 const QString &sSourceName,
00369 const QString &sGrabber,
00370 const QString &sUserId,
00371 const QString &sFreqTable,
00372 const QString &sLineupId,
00373 const QString &sPassword,
00374 bool bUseEIT,
00375 const QString &sConfigPath,
00376 int nNITId )
00377 {
00378 bool bResult = false;
00379
00380 bResult = SourceUtil::UpdateSource(nSourceId, sSourceName, sGrabber, sUserId, sFreqTable,
00381 sLineupId, sPassword, bUseEIT, sConfigPath,
00382 nNITId);
00383
00384 return bResult;
00385 }
00386
00388
00390
00391 int Channel::AddVideoSource( const QString &sSourceName,
00392 const QString &sGrabber,
00393 const QString &sUserId,
00394 const QString &sFreqTable,
00395 const QString &sLineupId,
00396 const QString &sPassword,
00397 bool bUseEIT,
00398 const QString &sConfigPath,
00399 int nNITId )
00400 {
00401 int nResult = SourceUtil::CreateSource(sSourceName, sGrabber, sUserId, sFreqTable,
00402 sLineupId, sPassword, bUseEIT, sConfigPath,
00403 nNITId);
00404
00405 return nResult;
00406 }
00407
00409
00411
00412 bool Channel::RemoveVideoSource( uint nSourceID )
00413 {
00414 bool bResult = false;
00415
00416 bResult = SourceUtil::DeleteSource( nSourceID );
00417
00418 return bResult;
00419 }
00420
00422
00424
00425 DTC::LineupList* Channel::GetDDLineupList( const QString &sSource,
00426 const QString &sUserId,
00427 const QString &sPassword )
00428 {
00429 int source = 0;
00430
00431 DTC::LineupList *pLineups = new DTC::LineupList();
00432
00433 if (sSource.toLower() == "schedulesdirect1" ||
00434 sSource.toLower() == "schedulesdirect" ||
00435 sSource.isEmpty())
00436 {
00437 source = 1;
00438 DataDirectProcessor ddp(source, sUserId, sPassword);
00439 if (!ddp.GrabLineupsOnly())
00440 {
00441 throw( QString("Unable to grab lineups. Check info."));
00442 }
00443 const DDLineupList lineups = ddp.GetLineups();
00444
00445 DDLineupList::const_iterator it;
00446 for (it = lineups.begin(); it != lineups.end(); ++it)
00447 {
00448 DTC::Lineup *pLineup = pLineups->AddNewLineup();
00449
00450 pLineup->setLineupId((*it).lineupid);
00451 pLineup->setName((*it).name);
00452 pLineup->setDisplayName((*it).displayname);
00453 pLineup->setType((*it).type);
00454 pLineup->setPostal((*it).postal);
00455 pLineup->setDevice((*it).device);
00456 }
00457 }
00458
00459 return pLineups;
00460 }
00461
00463
00465
00466 int Channel::FetchChannelsFromSource( const uint nSourceId,
00467 const uint nCardId,
00468 bool bWaitForFinish )
00469 {
00470 if ( nSourceId < 1 || nCardId < 1)
00471 throw( QString("A source ID and card ID are both required."));
00472
00473 int nResult = 0;
00474
00475 QString cardtype = CardUtil::GetRawCardType(nCardId);
00476
00477 if (!CardUtil::IsUnscanable(cardtype) &&
00478 !CardUtil::IsEncoder(cardtype))
00479 {
00480 throw( QString("This device is incompatible with channel fetching.") );
00481 }
00482
00483 SourceUtil::UpdateChannelsFromListings(nSourceId, cardtype, bWaitForFinish);
00484
00485 if (bWaitForFinish)
00486 nResult = SourceUtil::GetChannelCount(nSourceId);
00487
00488 return nResult;
00489 }
00490
00492
00494
00495 DTC::VideoMultiplexList* Channel::GetVideoMultiplexList( int nSourceID,
00496 int nStartIndex,
00497 int nCount )
00498 {
00499 MSqlQuery query(MSqlQuery::InitCon());
00500
00501 if (!query.isConnected())
00502 throw( QString("Database not open while trying to list "
00503 "Video Sources."));
00504
00505 query.prepare("SELECT mplexid, sourceid, transportid, networkid, "
00506 "frequency, inversion, symbolrate, fec, polarity, "
00507 "modulation, bandwidth, lp_code_rate, transmission_mode, "
00508 "guard_interval, visible, constellation, hierarchy, hp_code_rate, "
00509 "mod_sys, rolloff, sistandard, serviceversion, updatetimestamp, "
00510 "default_authority FROM dtv_multiplex WHERE sourceid = :SOURCEID "
00511 "ORDER BY mplexid" );
00512 query.bindValue(":SOURCEID", nSourceID);
00513
00514 if (!query.exec())
00515 {
00516 MythDB::DBError("MythAPI::GetVideoMultiplexList()", query);
00517
00518 throw( QString( "Database Error executing query." ));
00519 }
00520
00521 int muxCount = query.size();
00522
00523
00524
00525
00526
00527 DTC::VideoMultiplexList *pVideoMultiplexes = new DTC::VideoMultiplexList();
00528
00529 nStartIndex = min( nStartIndex, muxCount );
00530 nCount = (nCount > 0) ? min( nCount, muxCount ) : muxCount;
00531 int nEndIndex = min((nStartIndex + nCount), muxCount );
00532
00533 for( int n = nStartIndex; n < nEndIndex; n++)
00534 {
00535 if (query.seek(n))
00536 {
00537 DTC::VideoMultiplex *pVideoMultiplex = pVideoMultiplexes->AddNewVideoMultiplex();
00538
00539 pVideoMultiplex->setMplexId( query.value(0).toInt() );
00540 pVideoMultiplex->setSourceId( query.value(1).toInt() );
00541 pVideoMultiplex->setTransportId( query.value(2).toInt() );
00542 pVideoMultiplex->setNetworkId( query.value(3).toInt() );
00543 pVideoMultiplex->setFrequency( query.value(4).toLongLong() );
00544 pVideoMultiplex->setInversion( query.value(5).toString() );
00545 pVideoMultiplex->setSymbolRate( query.value(6).toLongLong() );
00546 pVideoMultiplex->setFEC( query.value(7).toString() );
00547 pVideoMultiplex->setPolarity( query.value(8).toString() );
00548 pVideoMultiplex->setModulation( query.value(9).toString() );
00549 pVideoMultiplex->setBandwidth( query.value(10).toString() );
00550 pVideoMultiplex->setLPCodeRate( query.value(11).toString() );
00551 pVideoMultiplex->setTransmissionMode( query.value(12).toString() );
00552 pVideoMultiplex->setGuardInterval( query.value(13).toString() );
00553 pVideoMultiplex->setVisible( query.value(14).toBool() );
00554 pVideoMultiplex->setConstellation( query.value(15).toString() );
00555 pVideoMultiplex->setHierarchy( query.value(16).toString() );
00556 pVideoMultiplex->setHPCodeRate( query.value(17).toString() );
00557 pVideoMultiplex->setModulationSystem( query.value(18).toString() );
00558 pVideoMultiplex->setRollOff( query.value(19).toString() );
00559 pVideoMultiplex->setSIStandard( query.value(20).toString() );
00560 pVideoMultiplex->setServiceVersion( query.value(21).toInt() );
00561 pVideoMultiplex->setUpdateTimeStamp( query.value(22).toDateTime() );
00562 pVideoMultiplex->setDefaultAuthority( query.value(23).toString() );
00563 }
00564 }
00565
00566 int curPage = 0, totalPages = 0;
00567 if (nCount == 0)
00568 totalPages = 1;
00569 else
00570 totalPages = (int)ceil((float)muxCount / nCount);
00571
00572 if (totalPages == 1)
00573 curPage = 1;
00574 else
00575 {
00576 curPage = (int)ceil((float)nStartIndex / nCount) + 1;
00577 }
00578
00579 pVideoMultiplexes->setStartIndex ( nStartIndex );
00580 pVideoMultiplexes->setCount ( nCount );
00581 pVideoMultiplexes->setCurrentPage ( curPage );
00582 pVideoMultiplexes->setTotalPages ( totalPages );
00583 pVideoMultiplexes->setTotalAvailable( muxCount );
00584 pVideoMultiplexes->setAsOf ( QDateTime::currentDateTime() );
00585 pVideoMultiplexes->setVersion ( MYTH_BINARY_VERSION );
00586 pVideoMultiplexes->setProtoVer ( MYTH_PROTO_VERSION );
00587
00588 return pVideoMultiplexes;
00589 }
00590
00591 DTC::VideoMultiplex* Channel::GetVideoMultiplex( int nMplexID )
00592 {
00593 MSqlQuery query(MSqlQuery::InitCon());
00594
00595 if (!query.isConnected())
00596 throw( QString("Database not open while trying to list "
00597 "Video Multiplex."));
00598
00599 query.prepare("SELECT sourceid, transportid, networkid, "
00600 "frequency, inversion, symbolrate, fec, polarity, "
00601 "modulation, bandwidth, lp_code_rate, transmission_mode, "
00602 "guard_interval, visible, constellation, hierarchy, hp_code_rate, "
00603 "mod_sys, rolloff, sistandard, serviceversion, updatetimestamp, "
00604 "default_authority FROM dtv_multiplex WHERE mplexid = :MPLEXID "
00605 "ORDER BY mplexid" );
00606 query.bindValue(":MPLEXID", nMplexID);
00607
00608 if (!query.exec())
00609 {
00610 MythDB::DBError("MythAPI::GetVideoMultiplex()", query);
00611
00612 throw( QString( "Database Error executing query." ));
00613 }
00614
00615 DTC::VideoMultiplex *pVideoMultiplex = new DTC::VideoMultiplex();
00616
00617 if (query.next())
00618 {
00619 pVideoMultiplex->setMplexId( nMplexID );
00620 pVideoMultiplex->setSourceId( query.value(0).toInt() );
00621 pVideoMultiplex->setTransportId( query.value(1).toInt() );
00622 pVideoMultiplex->setNetworkId( query.value(2).toInt() );
00623 pVideoMultiplex->setFrequency( query.value(3).toLongLong() );
00624 pVideoMultiplex->setInversion( query.value(4).toString() );
00625 pVideoMultiplex->setSymbolRate( query.value(5).toLongLong() );
00626 pVideoMultiplex->setFEC( query.value(6).toString() );
00627 pVideoMultiplex->setPolarity( query.value(7).toString() );
00628 pVideoMultiplex->setModulation( query.value(8).toString() );
00629 pVideoMultiplex->setBandwidth( query.value(9).toString() );
00630 pVideoMultiplex->setLPCodeRate( query.value(10).toString() );
00631 pVideoMultiplex->setTransmissionMode( query.value(11).toString() );
00632 pVideoMultiplex->setGuardInterval( query.value(12).toString() );
00633 pVideoMultiplex->setVisible( query.value(13).toBool() );
00634 pVideoMultiplex->setConstellation( query.value(14).toString() );
00635 pVideoMultiplex->setHierarchy( query.value(15).toString() );
00636 pVideoMultiplex->setHPCodeRate( query.value(16).toString() );
00637 pVideoMultiplex->setModulationSystem( query.value(17).toString() );
00638 pVideoMultiplex->setRollOff( query.value(18).toString() );
00639 pVideoMultiplex->setSIStandard( query.value(19).toString() );
00640 pVideoMultiplex->setServiceVersion( query.value(20).toInt() );
00641 pVideoMultiplex->setUpdateTimeStamp( query.value(21).toDateTime() );
00642 pVideoMultiplex->setDefaultAuthority( query.value(22).toString() );
00643 }
00644
00645 return pVideoMultiplex;
00646 }
00647
00649
00651
00652 QStringList Channel::GetXMLTVIdList( int SourceID )
00653 {
00654 MSqlQuery query(MSqlQuery::InitCon());
00655
00656 if (!query.isConnected())
00657 throw( QString("Database not open while trying to get source name."));
00658
00659 query.prepare("SELECT name FROM videosource WHERE sourceid = :SOURCEID ");
00660 query.bindValue(":SOURCEID", SourceID);
00661
00662 if (!query.exec())
00663 {
00664 MythDB::DBError("MythAPI::GetXMLTVIdList()", query);
00665
00666 throw( QString( "Database Error executing query." ));
00667 }
00668
00669 QStringList idList;
00670
00671 if (query.next())
00672 {
00673 QString sourceName = query.value(0).toString();
00674
00675 QString xmltvFile = GetConfDir() + '/' + sourceName + ".xmltv";
00676
00677 if (QFile::exists(xmltvFile))
00678 {
00679 QFile file(xmltvFile);
00680 if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
00681 return idList;
00682
00683 while (!file.atEnd())
00684 {
00685 QByteArray line = file.readLine();
00686
00687 if (line.startsWith("channel="))
00688 {
00689 QString id = line.mid(8, -1).trimmed();
00690 idList.append(id);
00691 }
00692 }
00693
00694 idList.sort();
00695 }
00696 }
00697 else
00698 throw(QString("SourceID (%1) not found").arg(SourceID));
00699
00700 return idList;
00701 }