Advertisement
Guest User

Untitled

a guest
May 12th, 2013
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.19 KB | None | 0 0
  1. --- addons/pvr.mythtv.cmyth/src/cppmyth/MythDatabase.cpp
  2. +++ addons/pvr.mythtv.cmyth/src/cppmyth/MythDatabase.cpp
  3. @@ -94,6 +94,13 @@ bool MythDatabase::FindProgram(time_t st
  4. return retval > 0;
  5. }
  6.  
  7. +bool MythDatabase::FindCurrentProgram(int channelid, MythProgram* program)
  8. +{
  9. + int retval = 0;
  10. + CMYTH_DB_CALL(retval, retval < 0, cmyth_mysql_get_prog_finder_chan(*m_database_t, program, channelid));
  11. + return retval > 0;
  12. +}
  13. +
  14. ProgramList MythDatabase::GetGuide(int channelid, time_t starttime, time_t endtime)
  15. {
  16. MythProgram *programs = 0;
  17.  
  18. --- addons/pvr.mythtv.cmyth/src/cppmyth/MythDatabase.h
  19. +++ addons/pvr.mythtv.cmyth/src/cppmyth/MythDatabase.h
  20. @@ -71,6 +71,7 @@ public:
  21. CStdString GetSetting(const CStdString &setting);
  22.  
  23. bool FindProgram(time_t starttime, int channelid, const CStdString &title, MythProgram* pprogram);
  24. + bool FindCurrentProgram(int channelid, MythProgram* pprogram);
  25. ProgramList GetGuide(int channelid, time_t starttime, time_t endtime);
  26.  
  27. ChannelIdMap GetChannels();
  28.  
  29. --- addons/pvr.mythtv.cmyth/src/pvrclient-mythtv.cpp
  30. +++ addons/pvr.mythtv.cmyth/src/pvrclient-mythtv.cpp
  31. @@ -1155,7 +1155,12 @@ PVR_ERROR PVRClientMythTV::DeleteTimer(c
  32. void PVRClientMythTV::PVRtoMythRecordingRule(const PVR_TIMER timer, MythRecordingRule &rule)
  33. {
  34. MythProgram program;
  35. - bool programFound = m_db.FindProgram(timer.startTime, timer.iClientChannelUid, "%", &program);
  36. + bool programFound;
  37. +
  38. + if (timer.startTime == 0)
  39. + programFound = m_db.FindCurrentProgram(timer.iClientChannelUid, &program);
  40. + else
  41. + programFound = m_db.FindProgram(timer.startTime, timer.iClientChannelUid, "%", &program);
  42.  
  43. // Load rule template from selected provider
  44. switch (g_iRecTemplateType)
  45. @@ -1195,11 +1200,20 @@ void PVRClientMythTV::PVRtoMythRecording
  46. }
  47. }
  48.  
  49. + // Set end time to EPG end if found, otherwise set to the timer end time
  50. + if (programFound)
  51. + rule.SetEndTime(program.endtime);
  52. + else
  53. + rule.SetEndTime(timer.endTime);
  54. +
  55. // If we have an entry in the EPG for the timer, we use it to set title and subtitle from it
  56. // PVR_TIMER has no subtitle thus might send it encoded within the title.
  57. if (programFound)
  58. {
  59. - rule.SetSearchType(MythRecordingRule::NoSearch);
  60. + if(timer.startTime == 0)
  61. + rule.SetSearchType(MythRecordingRule::ManualSearch);
  62. + else
  63. + rule.SetSearchType(MythRecordingRule::NoSearch);
  64. rule.SetTitle(program.title);
  65. rule.SetSubtitle(program.subtitle);
  66. rule.SetCategory(program.category);
  67. @@ -1214,7 +1228,6 @@ void PVRClientMythTV::PVRtoMythRecording
  68. rule.SetDescription(timer.strSummary);
  69. rule.SetChannelID(timer.iClientChannelUid);
  70. rule.SetStartTime((timer.startTime == 0 ? time(NULL) : timer.startTime));
  71. - rule.SetEndTime(timer.endTime);
  72. rule.SetInactive(timer.state == PVR_TIMER_STATE_ABORTED || timer.state == PVR_TIMER_STATE_CANCELLED);
  73.  
  74. ChannelIdMap::iterator channelIt = m_channelsById.find(timer.iClientChannelUid);
  75.  
  76. --- lib/cmyth/libcmyth/mythtv_mysql.c
  77. +++ lib/cmyth/libcmyth/mythtv_mysql.c
  78. @@ -1702,6 +1702,63 @@ cmyth_mysql_get_recorder_source_channum(
  79. }
  80.  
  81. int
  82. +cmyth_mysql_get_prog_finder_chan(cmyth_database_t db, cmyth_program_t *prog, uint32_t chanid)
  83. +{
  84. + MYSQL_RES *res = NULL;
  85. + MYSQL_ROW row;
  86. + 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";
  87. + int rows = 0;
  88. + cmyth_mysql_query_t * query;
  89. +
  90. + if (cmyth_database_check_version(db) < 0)
  91. + return -1;
  92. +
  93. + query = cmyth_mysql_query_create(db, query_str);
  94. +
  95. + if (cmyth_mysql_query_param_str(query, db->db_tz_name) < 0
  96. + || cmyth_mysql_query_param_str(query, db->db_tz_name) < 0
  97. + || cmyth_mysql_query_param_uint32(query, chanid) < 0
  98. + || cmyth_mysql_query_param_str(query, db->db_tz_name) < 0
  99. + || cmyth_mysql_query_param_str(query, db->db_tz_name) < 0) {
  100. + cmyth_dbg(CMYTH_DBG_ERROR, "%s, binding of query parameters failed! Maybe we're out of memory?\n", __FUNCTION__);
  101. + ref_release(query);
  102. + return -1;
  103. + }
  104. +
  105. + res = cmyth_mysql_query_result(query);
  106. + ref_release(query);
  107. +
  108. + if (res == NULL) {
  109. + cmyth_dbg(CMYTH_DBG_ERROR, "%s, finalisation/execution of query failed!\n", __FUNCTION__);
  110. + return -1;
  111. + }
  112. +
  113. + if ((row = mysql_fetch_row(res))) {
  114. + rows++;
  115. + if (prog) {
  116. + prog->chanid = safe_atol(row[0]);
  117. + prog->starttime = (time_t)safe_atol(row[1]);
  118. + prog->endtime = (time_t)safe_atol(row[2]);
  119. + sizeof_strncpy(prog->title, row[3]);
  120. + sizeof_strncpy(prog->description, row[4]);
  121. + sizeof_strncpy(prog->subtitle, row[5]);
  122. + sizeof_strncpy(prog->programid, row[6]);
  123. + sizeof_strncpy(prog->seriesid, row[7]);
  124. + sizeof_strncpy(prog->category, row[8]);
  125. + sizeof_strncpy(prog->category_type, row[9]);
  126. + prog->channum = safe_atol(row[10]);
  127. + sizeof_strncpy(prog->callsign, row[11]);
  128. + sizeof_strncpy(prog->name, row[12]);
  129. + prog->sourceid = safe_atol(row[13]);
  130. + }
  131. + }
  132. +
  133. + mysql_free_result(res);
  134. + cmyth_dbg(CMYTH_DBG_DEBUG, "%s: rows= %d\n", __FUNCTION__, rows);
  135. + return rows;
  136. +}
  137. +
  138. +int
  139. 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)
  140. {
  141. MYSQL_RES *res = NULL;
  142.  
  143. --- lib/cmyth/include/cmyth/cmyth.h
  144. +++ lib/cmyth/include/cmyth/cmyth.h
  145. @@ -1186,6 +1186,7 @@ extern int cmyth_mysql_get_recgroups(cmy
  146.  
  147. extern int cmyth_mysql_get_prog_finder_char_title(cmyth_database_t db, cmyth_program_t **prog, time_t starttime, char *program_name);
  148. extern int cmyth_mysql_get_prog_finder_time(cmyth_database_t db, cmyth_program_t **prog, time_t starttime, char *program_name);
  149. +extern int cmyth_mysql_get_prog_finder_chan(cmyth_database_t db, cmyth_program_t *prog, uint32_t chanid);
  150. 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);
  151. extern int cmyth_mysql_get_guide(cmyth_database_t db, cmyth_program_t **prog, uint32_t chanid, time_t starttime, time_t endtime);
  152. extern int cmyth_mysql_testdb_connection(cmyth_database_t db,char **message);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement