+void eDVBDB::loadBouquet(const char *path)
+{
+ std::string bouquet_name = path;
+ if (!bouquet_name.length())
+ {
+ eDebug("Bouquet load failed.. no path given..");
+ return;
+ }
+ unsigned int pos = bouquet_name.rfind('/');
+ if ( pos != std::string::npos )
+ bouquet_name.erase(0, pos+1);
+ if (bouquet_name.empty())
+ {
+ eDebug("Bouquet load failed.. no filename given..");
+ return;
+ }
+ eBouquet &bouquet = m_bouquets[bouquet_name];
+ bouquet.m_path = path;
+ std::list<eServiceReference> &list = bouquet.m_services;
+ list.clear();
+
+ eDebug("loading bouquet... %s", path);
+ FILE *fp=fopen(path, "rt");
+ int entries=0;
+ if (!fp)
+ {
+ eDebug("failed to open.");
+ return;
+ }
+ char line[256];
+ bool read_descr=false;
+ eServiceReference *e = NULL;
+ while (1)
+ {
+ if (!fgets(line, 256, fp))
+ break;
+ line[strlen(line)-1]=0;
+ if (strlen(line) && line[strlen(line)-1]=='\r')
+ line[strlen(line)-1]=0;
+ if (!line[0])
+ break;
+ if (line[0]=='#')
+ {
+ if (!strncmp(line, "#SERVICE ", 9) || !strncmp(line, "#SERVICE: ", 10))
+ {
+ int offs = line[8] == ':' ? 10 : 9;
+ eServiceReference tmp(line+offs);
+ if (tmp.type != eServiceReference::idDVB)
+ {
+ eDebug("only DVB Bouquets supported");
+ continue;
+ }
+ if ( (tmp.flags&eServiceReference::flagDirectory) == eServiceReference::flagDirectory )
+ {
+ std::string str = tmp.path;
+ unsigned int pos = str.rfind('/');
+ if ( pos != std::string::npos )
+ str.erase(0, pos+1);
+ if (str.empty())
+ {
+ eDebug("Bouquet load failed.. no filename given..");
+ continue;
+ }
+ loadBouquet(tmp.path.c_str());
+ char buf[256];
+ snprintf(buf, 256, "(type == %d) FROM BOUQUET \"%s\" ORDER BY bouquet", tmp.data[0], str.c_str());
+ tmp.path = buf;
+ }
+ list.push_back(tmp);
+ e = &list.back();
+ read_descr=true;
+ ++entries;
+ }
+ else if (read_descr && !strncmp(line, "#DESCRIPTION ", 13))
+ {
+ e->name = line+13;
+ read_descr=false;
+ }
+ else if (!strncmp(line, "#NAME ", 6))
+ bouquet.m_bouquet_name=line+6;
+ continue;
+ }
+ }
+ fclose(fp);
+ eDebug("%d entries in Bouquet %s", entries, bouquet_name.c_str());
+}
+
+void eDVBDB::saveBouquet(const char *path)
+{
+
+}
+
+void eDVBDB::loadBouquets()
+{
+ loadBouquet("bouquets.tv");
+ loadBouquet("bouquets.radio");
+}
+
+void eDVBDB::saveBouquets()
+{
+
+}
+