On Wed, 16 Feb 2005 16:23:42 -0500, Brad Benson <[EMAIL PROTECTED]> wrote:
> On Wed, 16 Feb 2005 09:06:35 -0400, Greg <[EMAIL PROTECTED]> wrote:
> >
> > >While I don't currently have any User Jobs set up, I've been wanting
> > >to dive into the myth code a little bit and this seems like a fairly
> > >trivial task and hence, a good starting place for me.  I pulled the
> > >latest cvs last night and I believe I have this working correctly.  I
> > >need to do some more testing on it and create a patch, but as soon as
> > >that's done I'll post the patch.
> > >
> > >As it stands right now User Jobs will show up in the 'Job Options'
> > >menu if there is a command specified for that job (i.e., if you only
> > >specified a command for User Job 1 then User Job 1 will be in the
> > >menu, but 2, 3 and 4 will not).  The menu options for User Jobs pretty
> > >much duplicate the Transcoding and Commercial Flagging menus in that
> > >if the job is already schedule the menu item will allow you to stop
> > >it, if not you can start the job from the menu.
> > >
> > >As Chris pointed out in his previous message, external programs won't
> > >be able to stop unless they're written to check the job queue table
> > >for the stop message, but I figured it's better to have it in there
> > >for now since folks could very well write apps to check for that.
> > >
> > >Brad
> > >
> > Thanks Brad...  The modifications you made will work fine for me as all
> > I wanted was some way to easily start a custom job...
> >
> > Greg
> > _______________________________________________
> > mythtv-users mailing list
> > [email protected]
> > http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
> >
> 
> Okay folks, here's a patch to allow users to start User Jobs from the
> Job Options menu just like you can do with transcoding and commercial
> flagging.  I'm pretty confident that it works 100%, but please let me
> know if anyone runs into any problems with it.
> 
> Also, please be aware that while I am very familiar with coding in C
> my C++ experience is VERY limited.  This is, in fact, my first ever
> patch to C++ code so if there's some ugly code in there or something
> not done correctly please feel free to point it out to me - I'd
> appreciate the education. :)
> 
> Brad
> 

Oops, might help if I attach the patch, huh?
--- mythtv/programs/mythfrontend/playbackbox.h	2005-02-06 18:14:54.000000000 -0500
+++ mythtv.patched/programs/mythfrontend/playbackbox.h	2005-02-16 05:36:44.000000000 -0500
@@ -94,6 +94,10 @@
     void changeOldPasswordChanged(const QString &newText);
     void doBeginTranscoding();
     void doBeginFlagging();
+    void doBeginUserJob1();
+    void doBeginUserJob2();
+    void doBeginUserJob3();
+    void doBeginUserJob4();
     void doClearPlaylist();
     void doPlaylistDelete();
     void doPlaylistChangeRecGroup();

--- mythtv/programs/mythfrontend/playbackbox.cpp	2005-02-15 11:39:44.000000000 -0500
+++ mythtv.patched/programs/mythfrontend/playbackbox.cpp	2005-02-16 06:15:58.000000000 -0500
@@ -1982,6 +1982,8 @@
     QSqlDatabase *db = QSqlDatabase::database();
 
     QButton *jobButton;
+    QString jobTitle = "";
+    QString command = "";
 
     if (JobQueue::IsJobRunning(db, JOB_TRANSCODE, curitem->chanid,
                                                   curitem->startts))
@@ -1999,6 +2001,66 @@
         popup->addButton(tr("Begin Commercial Flagging"), this,
                          SLOT(doBeginFlagging()));
 
+    command = gContext->GetSetting("UserJob1", "");
+
+    if (command != "") {
+
+        jobTitle = gContext->GetSetting("UserJobDesc1");
+
+        if (JobQueue::IsJobRunning(db, JOB_USERJOB1, curitem->chanid,
+                                                     curitem->startts))
+            popup->addButton(tr("Stop " + jobTitle), this,
+                             SLOT(doBeginUserJob1()));
+        else
+            popup->addButton(tr("Begin " + jobTitle), this,
+                             SLOT(doBeginUserJob1()));
+    }
+
+    command = gContext->GetSetting("UserJob2", "");
+
+    if (command != "") {
+
+        jobTitle = gContext->GetSetting("UserJobDesc2");
+
+        if (JobQueue::IsJobRunning(db, JOB_USERJOB2, curitem->chanid,
+                                                      curitem->startts))
+            popup->addButton(tr("Stop " + jobTitle), this,
+                             SLOT(doBeginUserJob2()));
+        else
+            popup->addButton(tr("Begin " + jobTitle), this,
+                             SLOT(doBeginUserJob2()));
+    }
+
+    command = gContext->GetSetting("UserJob3", "");
+
+    if (command != "") {
+
+        jobTitle = gContext->GetSetting("UserJobDesc3");
+
+        if (JobQueue::IsJobRunning(db, JOB_USERJOB3, curitem->chanid,
+                                                      curitem->startts))
+            popup->addButton(tr("Stop " + jobTitle), this,
+                             SLOT(doBeginUserJob3()));
+        else
+            popup->addButton(tr("Begin " + jobTitle), this,
+                             SLOT(doBeginUserJob3()));
+    }
+
+    command = gContext->GetSetting("UserJob4", "");
+
+    if (command != "") {
+
+        jobTitle = gContext->GetSetting("UserJobDesc4");
+
+        if (JobQueue::IsJobRunning(db, JOB_USERJOB4, curitem->chanid,
+                                                      curitem->startts))
+            popup->addButton(tr("Stop " + jobTitle), this,
+                             SLOT(doBeginUserJob4()));
+        else
+            popup->addButton(tr("Begin " + jobTitle), this,
+                             SLOT(doBeginUserJob4()));
+    }
+
     popup->ShowPopup(this, SLOT(doCancel()));
     jobButton->setFocus();
     
@@ -2268,6 +2330,100 @@
     }
 }
 
+void PlaybackBox::doBeginUserJob1()
+{
+    if (!expectingPopup)
+        return;
+
+    cancelPopup();
+
+    QSqlDatabase *db = QSqlDatabase::database();
+
+    if (JobQueue::IsJobRunning(db, JOB_USERJOB1,
+                               curitem->chanid, curitem->startts))
+    {
+        JobQueue::ChangeJobCmds(db, JOB_USERJOB1,
+                                curitem->chanid, curitem->startts, JOB_STOP);
+    }
+    else
+    {
+        QString jobHost = "";
+        if (gContext->GetNumSetting("JobsRunOnRecordHost", 0))
+            jobHost = gContext->GetHostName();
+
+        JobQueue::QueueJob(db, JOB_USERJOB1, curitem->chanid, curitem->startts,
+                           "", "", jobHost);
+    }
+}
+
+void PlaybackBox::doBeginUserJob2()
+{
+    if (!expectingPopup)
+        return;
+
+    cancelPopup();
+
+    QSqlDatabase *db = QSqlDatabase::database();
+
+    if (JobQueue::IsJobRunning(db, JOB_USERJOB2,
+                               curitem->chanid, curitem->startts))
+    {
+        JobQueue::ChangeJobCmds(db, JOB_USERJOB2,
+                                curitem->chanid, curitem->startts, JOB_STOP);
+    }
+    else
+    {
+        QString jobHost = "";
+        if (gContext->GetNumSetting("JobsRunOnRecordHost", 0))
+            jobHost = gContext->GetHostName();
+
+        JobQueue::QueueJob(db, JOB_USERJOB2, curitem->chanid, curitem->startts,
+                           "", "", jobHost);
+    }
+}
+
+void PlaybackBox::doBeginUserJob3()
+{
+    if (!expectingPopup)
+        return;
+
+    cancelPopup();
+
+    QSqlDatabase *db = QSqlDatabase::database();
+
+    if (!JobQueue::IsJobRunning(db, JOB_USERJOB3,
+                               curitem->chanid, curitem->startts))
+    {
+        QString jobHost = "";
+        if (gContext->GetNumSetting("JobsRunOnRecordHost", 0))
+            jobHost = gContext->GetHostName();
+
+        JobQueue::QueueJob(db, JOB_USERJOB3, curitem->chanid, curitem->startts,
+                           "", "", jobHost);
+    }
+}
+
+void PlaybackBox::doBeginUserJob4()
+{
+    if (!expectingPopup)
+        return;
+
+    cancelPopup();
+
+    QSqlDatabase *db = QSqlDatabase::database();
+
+    if (!JobQueue::IsJobRunning(db, JOB_USERJOB4,
+                               curitem->chanid, curitem->startts))
+    {
+        QString jobHost = "";
+        if (gContext->GetNumSetting("JobsRunOnRecordHost", 0))
+            jobHost = gContext->GetHostName();
+
+        JobQueue::QueueJob(db, JOB_USERJOB4, curitem->chanid, curitem->startts,
+                           "", "", jobHost);
+    }
+}
+
 void PlaybackBox::doBeginFlagging()
 {
     if (!expectingPopup)
_______________________________________________
mythtv-users mailing list
[email protected]
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users

Reply via email to