MythTV  0.26-pre
jobutils.cpp
Go to the documentation of this file.
00001 // C++ includes
00002 #include <iostream>
00003 
00004 // libmyth* includes
00005 #include "exitcodes.h"
00006 #include "jobqueue.h"
00007 #include "mythlogging.h"
00008 
00009 // Local includes
00010 #include "jobutils.h"
00011 
00012 static int QueueJob(const MythUtilCommandLineParser &cmdline)
00013 {
00014     ProgramInfo pginfo;
00015     if (!GetProgramInfo(cmdline, pginfo))
00016         return GENERIC_EXIT_NO_RECORDING_DATA;
00017 
00018     bool rebuildSeektable = false;
00019     int jobType = JOB_NONE;
00020 
00021     if (cmdline.toString("queuejob") == "transcode")
00022         jobType = JOB_TRANSCODE;
00023     else if (cmdline.toString("queuejob") == "commflag")
00024         jobType = JOB_COMMFLAG;
00025     else if (cmdline.toString("queuejob") == "rebuild")
00026     {
00027         jobType = JOB_COMMFLAG;
00028         rebuildSeektable = true;
00029     }
00030     else if (cmdline.toString("queuejob") == "metadata")
00031         jobType = JOB_METADATA;
00032     else if (cmdline.toString("queuejob") == "userjob1")
00033         jobType = JOB_USERJOB1;
00034     else if (cmdline.toString("queuejob") == "userjob2")
00035         jobType = JOB_USERJOB1;
00036     else if (cmdline.toString("queuejob") == "userjob4")
00037         jobType = JOB_USERJOB1;
00038     else if (cmdline.toString("queuejob") == "userjob4")
00039         jobType = JOB_USERJOB1;
00040     else if (cmdline.toInt("queuejob") > 0)
00041         jobType = cmdline.toInt("queuejob");
00042 
00043     if (jobType == JOB_NONE)
00044     {
00045         LOG(VB_GENERAL, LOG_ERR,
00046             "Error, invalid job type given with queuejob option");
00047         return GENERIC_EXIT_INVALID_CMDLINE;
00048     }
00049     
00050     bool result = JobQueue::QueueJob(jobType,
00051         pginfo.GetChanID(), pginfo.GetRecordingStartTime(), "", "", "",
00052         rebuildSeektable, JOB_QUEUED, QDateTime());
00053 
00054     if (result)
00055     {
00056         QString tmp = QString("%1 Job Queued for chanid %2 @ %3")
00057             .arg(cmdline.toString("queuejob"))
00058             .arg(pginfo.GetChanID())
00059             .arg(pginfo.GetRecordingStartTime().toString());
00060         cerr << tmp.toLocal8Bit().constData() << endl;
00061         return GENERIC_EXIT_OK;
00062     }
00063 
00064     QString tmp = QString("Error queueing job for chanid %1 @ %2")
00065         .arg(pginfo.GetChanID())
00066         .arg(pginfo.GetRecordingStartTime().toString());
00067     cerr << tmp.toLocal8Bit().constData() << endl;
00068     return GENERIC_EXIT_DB_ERROR;
00069 }
00070 
00071 void registerJobUtils(UtilMap &utilMap)
00072 {
00073     utilMap["queuejob"]            = &QueueJob;
00074 }
00075 
00076 /* vim: set expandtab tabstop=4 shiftwidth=4: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends