zapit/src/bouquets.cpp: dont clear user-bouquets in 'erase' mode;

add helpers to get filtered channel lists;
add channels not present in services.xml with NOT_FOUND flag


Origin commit data
------------------
Commit: a4005bc75c
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2013-01-28 (Mon, 28 Jan 2013)
This commit is contained in:
[CST] Focus
2013-01-28 12:03:03 +04:00
parent dfd836c915
commit 158b8adb83
2 changed files with 42 additions and 6 deletions

View File

@@ -57,6 +57,8 @@ class CZapitBouquet
CZapitChannel* getChannelByChannelID(const t_channel_id channel_id, const unsigned char serviceType = ST_RESERVED);
void sortBouquet(void);
void sortBouquetByNumber(void);
bool getTvChannels(ZapitChannelList &list, int flags = CZapitChannel::PRESENT);
bool getRadioChannels(ZapitChannelList &list, int flags = CZapitChannel::PRESENT);
};
typedef vector<CZapitBouquet *> BouquetList;
@@ -115,7 +117,7 @@ class CBouquetManager
void moveBouquet(const unsigned int oldId, const unsigned int newId);
bool existsChannelInBouquet(unsigned int bq_id, const t_channel_id channel_id);
void clearAll();
void clearAll(bool user = true);
void sortBouquets(void);
};

View File

@@ -157,6 +157,26 @@ void CZapitBouquet::moveService(const unsigned int oldPosition, const unsigned i
}
}
bool CZapitBouquet::getTvChannels(ZapitChannelList &list, int flags)
{
list.clear();
for (ZapitChannelList::iterator it = tvChannels.begin(); it != tvChannels.end(); ++it) {
if ((*it)->flags & flags)
list.push_back(*it);
}
return (!list.empty());
}
bool CZapitBouquet::getRadioChannels(ZapitChannelList &list, int flags)
{
list.clear();
for (ZapitChannelList::iterator it = tvChannels.begin(); it != tvChannels.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)
{
@@ -262,7 +282,7 @@ void CBouquetManager::saveBouquets(const CZapitClient::bouquetMode bouquetMode,
if (bouquetMode == CZapitClient::BM_DELETEBOUQUETS) {
INFO("removing existing bouquets");
//unlink(BOUQUETS_XML);
g_bouquetManager->clearAll();
g_bouquetManager->clearAll(false);
}
if (bouquetMode == CZapitClient::BM_DONTTOUCHBOUQUETS)
return;
@@ -279,7 +299,7 @@ void CBouquetManager::saveBouquets(const CZapitClient::bouquetMode bouquetMode,
Bouquets[0]->Name = providerName;
}
if ((bouquetMode == CZapitClient::BM_UPDATEBOUQUETS) || (bouquetMode == CZapitClient::BM_CREATESATELLITEBOUQUET)) {
if ((bouquetMode == CZapitClient::BM_UPDATEBOUQUETS) || (bouquetMode == CZapitClient::BM_DELETEBOUQUETS)) {
while (!(Bouquets.empty())) {
CZapitBouquet* bouquet;
int dest = g_bouquetManager->existsBouquet(Bouquets[0]->Name.c_str());
@@ -378,6 +398,13 @@ void CBouquetManager::parseBouquetsXml(const char *fname, bool bUser)
chan->bAlwaysLocked = newBouquet->bLocked;
newBouquet->addService(chan);
} else if (bUser) {
chan = new CZapitChannel(name2, CREATE_CHANNEL_ID64, 1 /*service_type*/,
satellitePosition, freq);
CServiceManager::getInstance()->AddChannel(chan);
chan->flags = CZapitChannel::NOT_FOUND;
chan->bAlwaysLocked = newBouquet->bLocked;
newBouquet->addService(chan);
}
channel_node = channel_node->xmlNextNode;
@@ -616,12 +643,19 @@ void CBouquetManager::moveBouquet(const unsigned int oldId, const unsigned int n
}
}
void CBouquetManager::clearAll()
void CBouquetManager::clearAll(bool user)
{
for (unsigned int i =0; i < Bouquets.size(); i++)
delete Bouquets[i];
BouquetList tmplist;
for (unsigned int i =0; i < Bouquets.size(); i++) {
if (!user || !Bouquets[i]->bFav)
delete Bouquets[i];
else
tmplist.push_back(Bouquets[i]);
}
Bouquets.clear();
if (!user)
Bouquets = tmplist;
remainChannels = NULL;
}