Ticket #3910: mythshutdown-util-isRunning-18112007.patch
| File mythshutdown-util-isRunning-18112007.patch, 1.9 KB (added by , 19 years ago) |
|---|
-
libs/libmyth/util.h
53 53 MPUBLIC QRgb blendColors(QRgb source, QRgb add, int alpha); 54 54 55 55 MPUBLIC uint myth_system(const QString &command, int flags = 0); 56 MPUBLIC bool isRunning(QString program); 56 57 57 58 MPUBLIC QString cutDownString(const QString &text, QFont *testFont, uint maxwidth); 58 59 -
libs/libmyth/util.cpp
281 281 return GENERIC_EXIT_NOT_OK; 282 282 } 283 283 284 /** \fn isRunning(QString program) 285 * \brief Returns boolean true/false depending on whether program is running. 286 */ 287 bool 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 284 297 /** \fn cutDownString(const QString&, QFont*, uint) 285 298 * \brief Returns a string based on "text" that fits within "maxwidth" pixels. 286 299 */ -
programs/mythshutdown/main.cpp
15 15 #include "libmythtv/programinfo.h" 16 16 #include "libmythtv/jobqueue.h" 17 17 #include "tv.h" 18 #include "util.h" 18 19 19 20 void setGlobalSetting(const QString &key, const QString &value) 20 21 { … … 101 102 return 0; 102 103 } 103 104 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 114 105 QDateTime getDailyWakeupTime(QString sPeriod) 115 106 { 116 107 QString sTime = getGlobalSetting(sPeriod, "00:00");
