Ticket #314: jobqueue.userjobs.diff

File jobqueue.userjobs.diff, 3.1 KB (added by armin.buehler@…, 19 years ago)

libs/libmythtv/jobqueue.{cpp,h} against 7224

  • libs/libmythtv/jobqueue.cpp

     
    955955
    956956    if (jobType & JOB_USERJOB)
    957957    {
    958         QString settingName = QString("UserJobDesc%1").arg(jobType >> 8);
     958        QString settingName = QString("UserJobDesc%1").arg(jobTypeToIndex(jobType));
    959959        return gContext->GetSetting(settingName, settingName);
    960960    }
    961961
     
    10721072
    10731073            if (thisJob.type & JOB_USERJOB)
    10741074            {
    1075                 int userJobNumber = 1;
    1076                 int jobType = thisJob.type;
    1077 
    1078                 jobType = jobType >> 8;
    1079                 while (jobType != 0x01 && userJobNumber < 5)
    1080                 {
    1081                     jobType = jobType >> 1;
    1082                     userJobNumber++;
    1083                 }
    1084 
    1085                 if (userJobNumber >= 5)
    1086                     thisJob.type = JOB_NONE;
    1087                 else
    1088                     thisJob.type = userJobNumber << 8;
     1075                thisJob.type = 1 << (8 + jobTypeToIndex(thisJob.type) -1);
    10891076            }
    10901077
    10911078            jobs[jobCount++] = thisJob;
     
    11521139                             break;
    11531140        case JOB_USERJOB4:   allowSetting = "JobAllowUserJob4";
    11541141                             break;
    1155         default:             return false;
     1142        default:             VERBOSE(VB_JOBQUEUE, QString("JobQueue::AllowedToRun: unknown job.type: %1").arg(job.type));
     1143                            return false;
    11561144    }
    11571145
    11581146    if (gContext->GetNumSetting(allowSetting, 1))
     
    14431431    else if (!(jobType & JOB_USERJOB))
    14441432        return "Unknown Job";
    14451433
    1446     QString descSetting = QString("UserJobDesc%1").arg(jobType >> 8);
     1434    QString descSetting = QString("UserJobDesc%1").arg(jobTypeToIndex(jobType));
    14471435
    14481436    return gContext->GetSetting(descSetting, "Unknown Job");
    14491437}
     
    14601448    else if (!(jobType & JOB_USERJOB))
    14611449        return "";
    14621450
    1463     QString commandSetting = QString("UserJob%1").arg(jobType >> 8);
     1451    QString commandSetting = QString("UserJob%1").arg(jobTypeToIndex(jobType));
    14641452
    14651453    command = gContext->GetSetting(commandSetting, "");
    14661454
     
    18921880    controlFlagsLock.unlock();
    18931881}
    18941882
     1883int JobQueue::jobTypeToIndex(int JobType)
     1884{
     1885    if (JobType & JOB_USERJOB)
     1886    {
     1887        int x = ((JobType & JOB_USERJOB)>> 8);
     1888        int bits = 1;
     1889        while( (x != 0) && ((x & 0x01) == 0) )
     1890        {
     1891            bits++;
     1892            x = x >> 1;
     1893        }
     1894        if( bits > 4 )
     1895            return 0;
     1896
     1897        return bits;
     1898    }
     1899    return 0;
     1900}
     1901
    18951902/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • libs/libmythtv/jobqueue.h

     
    137137    static int GetJobFlags(int jobID);
    138138    static int GetJobStatus(int jobID);
    139139    static int GetJobStatus(int jobType, QString chanid, QDateTime starttime);
     140    static int jobTypeToIndex(int JobType);
    140141
    141142    static bool DeleteAllJobs(QString chanid, QDateTime starttime);
    142143