Ticket #3910: mythshutdown-util-isRunning-18112007.patch

File mythshutdown-util-isRunning-18112007.patch, 1.9 KB (added by Matthew Wire <devel@…>, 19 years ago)

Move isRunning function to libmyth/util.cpp

  • libs/libmyth/util.h

     
    5353MPUBLIC QRgb blendColors(QRgb source, QRgb add, int alpha);
    5454
    5555MPUBLIC uint myth_system(const QString &command, int flags = 0);
     56MPUBLIC bool isRunning(QString program);
    5657
    5758MPUBLIC QString cutDownString(const QString &text, QFont *testFont, uint maxwidth);
    5859
  • libs/libmyth/util.cpp

     
    281281    return GENERIC_EXIT_NOT_OK;
    282282}
    283283
     284/** \fn isRunning(QString program)
     285 *  \brief Returns boolean true/false depending on whether program is running.
     286 */
     287bool isRunning(QString program)
     288{
     289    QString sCommand = QString("ret=`ps cax | grep -c %1`; exit $ret").arg(program);
     290    int res = system(sCommand.ascii());
     291    if (WIFEXITED(res))
     292        res = WEXITSTATUS(res);
     293
     294    return res;
     295}
     296
    284297/** \fn cutDownString(const QString&, QFont*, uint)
    285298 *  \brief Returns a string based on "text" that fits within "maxwidth" pixels.
    286299 */
  • programs/mythshutdown/main.cpp

     
    1515#include "libmythtv/programinfo.h"
    1616#include "libmythtv/jobqueue.h"
    1717#include "tv.h"
     18#include "util.h"
    1819
    1920void setGlobalSetting(const QString &key, const QString &value)
    2021{
     
    101102    return 0;
    102103}
    103104
    104 bool isRunning(QString program)
    105 {
    106     QString sCommand = QString("ret=`ps cax | grep -c %1`; exit $ret").arg(program);
    107     int res = system(sCommand.ascii());
    108     if (WIFEXITED(res))
    109         res = WEXITSTATUS(res);
    110 
    111     return res;
    112 }
    113 
    114105QDateTime getDailyWakeupTime(QString sPeriod)
    115106{
    116107    QString sTime = getGlobalSetting(sPeriod, "00:00");