// for when the tables need to be updated void RSSManager::updateDatabaseFormat() { // create tables if not already there int createRC = simpleSQL(db, "CREATE TABLE \"FeedItems\" (\n\t`guid`\tTEXT NOT NULL UNIQUE,\n\t`title`\tTEXT NOT NULL,\n\t`description`\tTEXT NOT NULL,\n\t`feedid`\tINTEGER NOT NULL,\n\t`date`\tTEXT NOT NULL,\n\t`actualdate`\tTEXT,\n\t`status`\tINTEGER NOT NULL DEFAULT 0,\n\t`link`\tTEXT,\n\t`contentencoded`\tTEXT,\n\tPRIMARY KEY(guid)\n);"); simpleSQL(db, "CREATE TABLE IF NOT EXISTS \"FeedInfo\" (\n\t`id`\tINTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n\t`name`\tTEXT NOT NULL,\n\t`url`\tTEXT NOT NULL UNIQUE\n)"); simpleSQL(db, "CREATE TABLE IF NOT EXISTS `ProgramInfo` (\n\t`infoname`\tTEXT NOT NULL UNIQUE,\n\t`value`\tTEXT,\n\tPRIMARY KEY(infoname)\n);"); // these statements need to be created first std::string feedStr = "select value from ProgramInfo where infoname=?1;"; int rc = sqlite3_prepare_v2(db, feedStr.c_str(), feedStr.length() + 1, &getProgramInfoStmt, NULL); feedStr = "insert or replace into ProgramInfo (infoname, value) values (?1, ?2);"; rc = sqlite3_prepare_v2(db, feedStr.c_str(), feedStr.length() + 1, &setProgramInfoStmt, NULL); // when the tables already exist, update the table format if (createRC == SQLITE_ERROR) { // get version of databse std::string version = getProgramInfo("version", "0.0"); if (!version.compare("0.0")) // version 0, before content encoded, and ProgramInfo { simpleSQL(db, "alter table FeedItems add column `contentencoded` TEXT;"); } } // current version setProgramInfo("version", "0.1"); }
void eDVBServicePMTHandler::getCaIds(std::vector<int> &caids, std::vector<int> &ecmpids) { program prog; if (!getProgramInfo(prog)) { for (std::list<program::capid_pair>::iterator it = prog.caids.begin(); it != prog.caids.end(); ++it) { caids.push_back(it->caid); ecmpids.push_back(it->capid); } } }
PyObject *eDVBServicePMTHandler::getCaIds(bool pair) { ePyObject ret; program prog; if ( !getProgramInfo(prog) ) { if (pair) { int cnt=prog.caids.size(); if (cnt) { ret=PyList_New(cnt); std::list<program::capid_pair>::iterator it(prog.caids.begin()); while(cnt--) { ePyObject tuple = PyTuple_New(2); PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(it->caid)); PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong((it++)->capid)); PyList_SET_ITEM(ret, cnt, tuple); } } } else { std::set<program::capid_pair> set(prog.caids.begin(), prog.caids.end()); std::set<program::capid_pair>::iterator it(set.begin()); int cnt=set.size(); ret=PyList_New(cnt); while(cnt--) PyList_SET_ITEM(ret, cnt, PyInt_FromLong((it++)->caid)); } } return ret ? (PyObject*)ret : (PyObject*)PyList_New(0); }