zapit/src/bouquets.cpp: add getChannels() with mode param, add fopen error check

Origin commit data
------------------
Branch: ni/coolstream
Commit: c605141b98
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2014-10-10 (Fri, 10 Oct 2014)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
[CST] Focus
2014-10-10 14:57:34 +04:00
parent 512c89f559
commit fea41bc944
2 changed files with 21 additions and 0 deletions

View File

@@ -60,6 +60,7 @@ class CZapitBouquet
void sortBouquetByNumber(void);
bool getTvChannels(ZapitChannelList &list, int flags = CZapitChannel::PRESENT);
bool getRadioChannels(ZapitChannelList &list, int flags = CZapitChannel::PRESENT);
bool getChannels(ZapitChannelList &list, bool tv, int flags = CZapitChannel::PRESENT);
};
typedef vector<CZapitBouquet *> BouquetList;

View File

@@ -183,6 +183,16 @@ bool CZapitBouquet::getRadioChannels(ZapitChannelList &list, int flags)
return (!list.empty());
}
bool CZapitBouquet::getChannels(ZapitChannelList &list, bool tv, int flags)
{
list.clear();
ZapitChannelList *current = tv ? &tvChannels : &radioChannels;
for (ZapitChannelList::iterator it = current->begin(); it != current->end(); ++it) {
if ((*it)->flags & flags)
list.push_back(*it);
}
return (!list.empty());
}
#if 0
size_t CZapitBouquet::recModeRadioSize(const transponder_id_t transponder_id)
{
@@ -248,7 +258,12 @@ void CBouquetManager::saveBouquets(void)
{
FILE * bouq_fd;
printf("CBouquetManager::saveBouquets: %s\n", BOUQUETS_XML);
bouq_fd = fopen(BOUQUETS_XML, "w");
if (!bouq_fd) {
perror(BOUQUETS_XML);
return;
}
fprintf(bouq_fd, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<zapit>\n");
for (unsigned int i = 0; i < Bouquets.size(); i++) {
if (Bouquets[i] != remainChannels) {
@@ -268,7 +283,12 @@ void CBouquetManager::saveUBouquets(void)
{
FILE * ubouq_fd;
printf("CBouquetManager::saveUBouquets: %s\n", UBOUQUETS_XML);
ubouq_fd = fopen(UBOUQUETS_XML, "w");
if (!ubouq_fd) {
perror(BOUQUETS_XML);
return;
}
fprintf(ubouq_fd, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<zapit>\n");
for (unsigned int i = 0; i < Bouquets.size(); i++) {
if (Bouquets[i] != remainChannels) {