Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- addons/pvr.mythtv.cmyth/src/cppmyth/MythDatabase.cpp
- +++ addons/pvr.mythtv.cmyth/src/cppmyth/MythDatabase.cpp
- @@ -94,6 +94,13 @@ bool MythDatabase::FindProgram(time_t st
- return retval > 0;
- }
- +bool MythDatabase::FindCurrentProgram(int channelid, MythProgram* program)
- +{
- + int retval = 0;
- + CMYTH_DB_CALL(retval, retval < 0, cmyth_mysql_get_prog_finder_chan(*m_database_t, program, channelid));
- + return retval > 0;
- +}
- +
- ProgramList MythDatabase::GetGuide(int channelid, time_t starttime, time_t endtime)
- {
- MythProgram *programs = 0;
- --- addons/pvr.mythtv.cmyth/src/cppmyth/MythDatabase.h
- +++ addons/pvr.mythtv.cmyth/src/cppmyth/MythDatabase.h
- @@ -71,6 +71,7 @@ public:
- CStdString GetSetting(const CStdString &setting);
- bool FindProgram(time_t starttime, int channelid, const CStdString &title, MythProgram* pprogram);
- + bool FindCurrentProgram(int channelid, MythProgram* pprogram);
- ProgramList GetGuide(int channelid, time_t starttime, time_t endtime);
- ChannelIdMap GetChannels();
- --- addons/pvr.mythtv.cmyth/src/pvrclient-mythtv.cpp
- +++ addons/pvr.mythtv.cmyth/src/pvrclient-mythtv.cpp
- @@ -1155,7 +1155,12 @@ PVR_ERROR PVRClientMythTV::DeleteTimer(c
- void PVRClientMythTV::PVRtoMythRecordingRule(const PVR_TIMER timer, MythRecordingRule &rule)
- {
- MythProgram program;
- - bool programFound = m_db.FindProgram(timer.startTime, timer.iClientChannelUid, "%", &program);
- + bool programFound;
- +
- + if (timer.startTime == 0)
- + programFound = m_db.FindCurrentProgram(timer.iClientChannelUid, &program);
- + else
- + programFound = m_db.FindProgram(timer.startTime, timer.iClientChannelUid, "%", &program);
- // Load rule template from selected provider
- switch (g_iRecTemplateType)
- @@ -1195,11 +1200,20 @@ void PVRClientMythTV::PVRtoMythRecording
- }
- }
- + // Set end time to EPG end if found, otherwise set to the timer end time
- + if (programFound)
- + rule.SetEndTime(program.endtime);
- + else
- + rule.SetEndTime(timer.endTime);
- +
- // If we have an entry in the EPG for the timer, we use it to set title and subtitle from it
- // PVR_TIMER has no subtitle thus might send it encoded within the title.
- if (programFound)
- {
- - rule.SetSearchType(MythRecordingRule::NoSearch);
- + if(timer.startTime == 0)
- + rule.SetSearchType(MythRecordingRule::ManualSearch);
- + else
- + rule.SetSearchType(MythRecordingRule::NoSearch);
- rule.SetTitle(program.title);
- rule.SetSubtitle(program.subtitle);
- rule.SetCategory(program.category);
- @@ -1214,7 +1228,6 @@ void PVRClientMythTV::PVRtoMythRecording
- rule.SetDescription(timer.strSummary);
- rule.SetChannelID(timer.iClientChannelUid);
- rule.SetStartTime((timer.startTime == 0 ? time(NULL) : timer.startTime));
- - rule.SetEndTime(timer.endTime);
- rule.SetInactive(timer.state == PVR_TIMER_STATE_ABORTED || timer.state == PVR_TIMER_STATE_CANCELLED);
- ChannelIdMap::iterator channelIt = m_channelsById.find(timer.iClientChannelUid);
- --- lib/cmyth/libcmyth/mythtv_mysql.c
- +++ lib/cmyth/libcmyth/mythtv_mysql.c
- @@ -1702,6 +1702,63 @@ cmyth_mysql_get_recorder_source_channum(
- }
- int
- +cmyth_mysql_get_prog_finder_chan(cmyth_database_t db, cmyth_program_t *prog, uint32_t chanid)
- +{
- + MYSQL_RES *res = NULL;
- + MYSQL_ROW row;
- + const char *query_str = "SELECT program.chanid,UNIX_TIMESTAMP(CONVERT_TZ(program.starttime,?,'SYSTEM')),UNIX_TIMESTAMP(CONVERT_TZ(program.endtime,?,'SYSTEM')),program.title,program.description,program.subtitle,program.programid,program.seriesid,program.category,program.category_type,channel.channum,channel.callsign,channel.name,channel.sourceid FROM program INNER JOIN channel ON program.chanid=channel.chanid WHERE program.chanid = ? AND UNIX_TIMESTAMP(NOW())>=UNIX_TIMESTAMP(CONVERT_TZ(program.starttime,?,'SYSTEM')) AND UNIX_TIMESTAMP(NOW())<=UNIX_TIMESTAMP(CONVERT_TZ(program.endtime,?,'SYSTEM')) AND program.manualid = 0 ORDER BY (channel.channum + 0), program.starttime ASC";
- + int rows = 0;
- + cmyth_mysql_query_t * query;
- +
- + if (cmyth_database_check_version(db) < 0)
- + return -1;
- +
- + query = cmyth_mysql_query_create(db, query_str);
- +
- + if (cmyth_mysql_query_param_str(query, db->db_tz_name) < 0
- + || cmyth_mysql_query_param_str(query, db->db_tz_name) < 0
- + || cmyth_mysql_query_param_uint32(query, chanid) < 0
- + || cmyth_mysql_query_param_str(query, db->db_tz_name) < 0
- + || cmyth_mysql_query_param_str(query, db->db_tz_name) < 0) {
- + cmyth_dbg(CMYTH_DBG_ERROR, "%s, binding of query parameters failed! Maybe we're out of memory?\n", __FUNCTION__);
- + ref_release(query);
- + return -1;
- + }
- +
- + res = cmyth_mysql_query_result(query);
- + ref_release(query);
- +
- + if (res == NULL) {
- + cmyth_dbg(CMYTH_DBG_ERROR, "%s, finalisation/execution of query failed!\n", __FUNCTION__);
- + return -1;
- + }
- +
- + if ((row = mysql_fetch_row(res))) {
- + rows++;
- + if (prog) {
- + prog->chanid = safe_atol(row[0]);
- + prog->starttime = (time_t)safe_atol(row[1]);
- + prog->endtime = (time_t)safe_atol(row[2]);
- + sizeof_strncpy(prog->title, row[3]);
- + sizeof_strncpy(prog->description, row[4]);
- + sizeof_strncpy(prog->subtitle, row[5]);
- + sizeof_strncpy(prog->programid, row[6]);
- + sizeof_strncpy(prog->seriesid, row[7]);
- + sizeof_strncpy(prog->category, row[8]);
- + sizeof_strncpy(prog->category_type, row[9]);
- + prog->channum = safe_atol(row[10]);
- + sizeof_strncpy(prog->callsign, row[11]);
- + sizeof_strncpy(prog->name, row[12]);
- + prog->sourceid = safe_atol(row[13]);
- + }
- + }
- +
- + mysql_free_result(res);
- + cmyth_dbg(CMYTH_DBG_DEBUG, "%s: rows= %d\n", __FUNCTION__, rows);
- + return rows;
- +}
- +
- +int
- cmyth_mysql_get_prog_finder_time_title_chan(cmyth_database_t db, cmyth_program_t *prog, time_t starttime, char *program_name, uint32_t chanid)
- {
- MYSQL_RES *res = NULL;
- --- lib/cmyth/include/cmyth/cmyth.h
- +++ lib/cmyth/include/cmyth/cmyth.h
- @@ -1186,6 +1186,7 @@ extern int cmyth_mysql_get_recgroups(cmy
- extern int cmyth_mysql_get_prog_finder_char_title(cmyth_database_t db, cmyth_program_t **prog, time_t starttime, char *program_name);
- extern int cmyth_mysql_get_prog_finder_time(cmyth_database_t db, cmyth_program_t **prog, time_t starttime, char *program_name);
- +extern int cmyth_mysql_get_prog_finder_chan(cmyth_database_t db, cmyth_program_t *prog, uint32_t chanid);
- extern int cmyth_mysql_get_prog_finder_time_title_chan(cmyth_database_t db, cmyth_program_t *prog, time_t starttime, char *program_name, uint32_t chanid);
- extern int cmyth_mysql_get_guide(cmyth_database_t db, cmyth_program_t **prog, uint32_t chanid, time_t starttime, time_t endtime);
- extern int cmyth_mysql_testdb_connection(cmyth_database_t db,char **message);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement