MythTV  master
jobutils.cpp
Go to the documentation of this file.
1 // C++ includes
2 #include <iostream>
3 
4 // libmyth* includes
5 #include "exitcodes.h"
6 #include "jobqueue.h"
7 #include "mythlogging.h"
8 
9 // Local includes
10 #include "jobutils.h"
11 
13 {
14  ProgramInfo pginfo;
15  if (!GetProgramInfo(cmdline, pginfo))
17 
18  bool rebuildSeektable = false;
19  int jobType = JOB_NONE;
20 
21  if (cmdline.toString("queuejob") == "transcode")
22  jobType = JOB_TRANSCODE;
23  else if (cmdline.toString("queuejob") == "commflag")
24  jobType = JOB_COMMFLAG;
25  else if (cmdline.toString("queuejob") == "rebuild")
26  {
27  jobType = JOB_COMMFLAG;
28  rebuildSeektable = true;
29  }
30  else if (cmdline.toString("queuejob") == "metadata")
31  jobType = JOB_METADATA;
32  else if (cmdline.toString("queuejob") == "userjob1")
33  jobType = JOB_USERJOB1;
34  else if (cmdline.toString("queuejob") == "userjob2")
35  jobType = JOB_USERJOB2;
36  else if (cmdline.toString("queuejob") == "userjob3")
37  jobType = JOB_USERJOB3;
38  else if (cmdline.toString("queuejob") == "userjob4")
39  jobType = JOB_USERJOB4;
40  else if (cmdline.toInt("queuejob") > 0)
41  jobType = cmdline.toInt("queuejob");
42 
43  if (jobType == JOB_NONE)
44  {
45  LOG(VB_GENERAL, LOG_ERR,
46  "Error, invalid job type given with queuejob option");
48  }
49 
50  bool result = JobQueue::QueueJob(jobType,
51  pginfo.GetChanID(), pginfo.GetRecordingStartTime(), "", "", "",
52  rebuildSeektable, JOB_QUEUED, QDateTime());
53 
54  if (result)
55  {
56  QString tmp = QString("%1 Job Queued for chanid %2 @ %3")
57  .arg(cmdline.toString("queuejob"))
58  .arg(pginfo.GetChanID())
59  .arg(pginfo.GetRecordingStartTime().toString());
60  cerr << tmp.toLocal8Bit().constData() << endl;
61  return GENERIC_EXIT_OK;
62  }
63 
64  QString tmp = QString("Error queueing job for chanid %1 @ %2")
65  .arg(pginfo.GetChanID())
66  .arg(pginfo.GetRecordingStartTime().toString());
67  cerr << tmp.toLocal8Bit().constData() << endl;
68  return GENERIC_EXIT_DB_ERROR;
69 }
70 
71 void registerJobUtils(UtilMap &utilMap)
72 {
73  utilMap["queuejob"] = &QueueJob;
74 }
75 
76 /* vim: set expandtab tabstop=4 shiftwidth=4: */
#define GENERIC_EXIT_DB_ERROR
Database error.
Definition: exitcodes.h:17
bool GetProgramInfo(const MythUtilCommandLineParser &cmdline, ProgramInfo &pginfo)
Definition: mythutil.cpp:11
#define GENERIC_EXIT_OK
Exited with no error.
Definition: exitcodes.h:10
static guint32 * tmp
Definition: goom_core.c:35
Holds information on recordings and videos.
Definition: programinfo.h:66
QMap< QString, UtilFunc > UtilMap
Definition: mythutil.h:16
#define GENERIC_EXIT_NO_RECORDING_DATA
No program/recording data.
Definition: exitcodes.h:29
QString toString(const QString &key) const
Returns stored QVariant as a QString, falling to default if not provided.
static int QueueJob(const MythUtilCommandLineParser &cmdline)
Definition: jobutils.cpp:12
MythCommFlagCommandLineParser cmdline
void registerJobUtils(UtilMap &utilMap)
Definition: jobutils.cpp:71
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Definition: programinfo.h:364
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
Definition: programinfo.h:396
#define GENERIC_EXIT_INVALID_CMDLINE
Command line parse error.
Definition: exitcodes.h:15
static bool QueueJob(int jobType, uint chanid, const QDateTime &recstartts, const QString &args="", const QString &comment="", QString host="", int flags=0, int status=JOB_QUEUED, QDateTime schedruntime=QDateTime())
Definition: jobqueue.cpp:518
int toInt(const QString &key) const
Returns stored QVariant as an integer, falling to default if not provided.