From d5d0a20e02a5e7fad15d78c0163ac53465dcd706 Mon Sep 17 00:00:00 2001 From: gregor herrmann Date: Sun, 4 Mar 2007 02:15:10 +0000 Subject: [PATCH] * New upstream release. --- ChangeLog | 286 ++++++++++++++++++++++++++++++++++++++++++++++ debian/changelog | 6 + debian/rules | 2 +- main.cpp | 127 +++++++++++++++----- maindialog.ui | 40 ++++++- options.cpp | 4 +- options.h | 2 +- options.ui | 10 +- qteleschorsch.pro | 6 +- teleschorschrc | 2 +- 10 files changed, 444 insertions(+), 41 deletions(-) create mode 100644 ChangeLog diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..faf86e1 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,286 @@ +------------------------------------------------------------------------ +r427 | philipp | 2007-03-03 14:11:23 +0100 (Sat, 03 Mar 2007) | 3 lines +Changed paths: + M /teleschorsch/trunk/main.cpp + M /teleschorsch/trunk/maindialog.ui + M /teleschorsch/trunk/options.cpp + M /teleschorsch/trunk/options.h + M /teleschorsch/trunk/options.ui + M /teleschorsch/trunk/qteleschorsch.pro + M /teleschorsch/trunk/teleschorschrc + +Removed the timeout from waitForFinished (I assume the user wants to watch more than 30 seconds ;-) ) +Removed minsize of the dialogs + +------------------------------------------------------------------------ +r426 | gregoa | 2007-03-03 01:51:18 +0100 (Sat, 03 Mar 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/main.cpp + +minor fixes to inline documentation +------------------------------------------------------------------------ +r425 | philipp | 2007-03-02 18:07:22 +0100 (Fri, 02 Mar 2007) | 2 lines +Changed paths: + M /teleschorsch/trunk/main.cpp + M /teleschorsch/trunk/maindialog.ui + M /teleschorsch/trunk/options.cpp + M /teleschorsch/trunk/options.ui + +Implemented error handling in substitution. Not tested. + +------------------------------------------------------------------------ +r424 | gregoa | 2007-03-02 16:14:20 +0100 (Fri, 02 Mar 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/teleschorschrc + +new url for M6-1250 +------------------------------------------------------------------------ +r423 | gregoa | 2007-03-02 16:03:41 +0100 (Fri, 02 Mar 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/main.cpp + +eval staticUrl in a shell +------------------------------------------------------------------------ +r422 | gregoa | 2007-03-02 00:38:46 +0100 (Fri, 02 Mar 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/main.cpp + +remove %1 in appendPlayerOffsetOption +------------------------------------------------------------------------ +r421 | philipp | 2007-03-02 00:01:52 +0100 (Fri, 02 Mar 2007) | 2 lines +Changed paths: + M /teleschorsch/trunk/main.cpp + M /teleschorsch/trunk/options.cpp + +Further working... This times on the offset as parameter for the player. Not tested. + +------------------------------------------------------------------------ +r420 | philipp | 2007-03-01 00:33:17 +0100 (Thu, 01 Mar 2007) | 2 lines +Changed paths: + M /teleschorsch/trunk/main.cpp + M /teleschorsch/trunk/options.cpp + M /teleschorsch/trunk/options.ui + +Further development of starting a specified program. Not tested. Offset ignored. + +------------------------------------------------------------------------ +r419 | gregoa | 2007-02-28 23:18:40 +0100 (Wed, 28 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/makedist + +add make distclean to makedist +------------------------------------------------------------------------ +r418 | gregoa | 2007-02-28 23:17:57 +0100 (Wed, 28 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/teleschorsch.pl + +quote in perl version when calling player +------------------------------------------------------------------------ +r417 | philipp | 2007-02-26 20:22:35 +0100 (Mon, 26 Feb 2007) | 2 lines +Changed paths: + M /teleschorsch/trunk/main.cpp + M /teleschorsch/trunk/main.h + M /teleschorsch/trunk/options.cpp + M /teleschorsch/trunk/options.h + M /teleschorsch/trunk/options.ui + M /teleschorsch/trunk/teleschorschrc + +Basic option file editing works now. + +------------------------------------------------------------------------ +r416 | philipp | 2007-02-26 19:30:49 +0100 (Mon, 26 Feb 2007) | 3 lines +Changed paths: + M /teleschorsch/trunk/main.cpp + M /teleschorsch/trunk/main.h + M /teleschorsch/trunk/options.cpp + M /teleschorsch/trunk/options.h + +Slightly re-structured to make config file editing easy from the program point-of-view. +The editing itself does not work yet. + +------------------------------------------------------------------------ +r415 | gregoa | 2007-02-25 23:16:48 +0100 (Sun, 25 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/main.cpp + M /teleschorsch/trunk/main.h + +started to work on 'start' button but ... +------------------------------------------------------------------------ +r414 | gregoa | 2007-02-25 22:03:03 +0100 (Sun, 25 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/teleschorschrc + +teleschorschrc: cleanup and additions +------------------------------------------------------------------------ +r413 | gregoa | 2007-02-25 17:39:59 +0100 (Sun, 25 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/teleschorschrc + +changed descriptions for ö1-journals in teleschorschrc +------------------------------------------------------------------------ +r412 | gregoa | 2007-02-25 17:31:40 +0100 (Sun, 25 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/main.cpp + +only show fullname in maindialog's lwChannels +------------------------------------------------------------------------ +r411 | gregoa | 2007-02-25 17:21:07 +0100 (Sun, 25 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/teleschorschrc + +add ö1-journals to teleschorschrc (currently only the last broadcast, date selection is ignored) +------------------------------------------------------------------------ +r410 | gregoa | 2007-02-25 17:19:21 +0100 (Sun, 25 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/teleschorsch.sh + +change separator in arrays in teleschorsch.sh from | to ~ in order to allow pipes in URL +------------------------------------------------------------------------ +r409 | gregoa | 2007-02-25 15:52:13 +0100 (Sun, 25 Feb 2007) | 1 line +Changed paths: + A /teleschorsch/trunk/makedist + +add script makedist (creates tarball with qt, perl, and bash version) +------------------------------------------------------------------------ +r408 | gregoa | 2007-02-24 23:23:24 +0100 (Sat, 24 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/teleschorsch.pl + +add newline to error messages +------------------------------------------------------------------------ +r407 | philipp | 2007-02-24 22:58:12 +0100 (Sat, 24 Feb 2007) | 2 lines +Changed paths: + M /teleschorsch/trunk/main.cpp + M /teleschorsch/trunk/main.h + A /teleschorsch/trunk/options.cpp + A /teleschorsch/trunk/options.h (from /teleschorsch/trunk/main.h:406) + M /teleschorsch/trunk/options.ui + M /teleschorsch/trunk/qteleschorsch.pro + +The options window opens when "Options" is clicked. + +------------------------------------------------------------------------ +r406 | gregoa | 2007-02-24 22:13:46 +0100 (Sat, 24 Feb 2007) | 1 line +Changed paths: + A /teleschorsch/trunk/teleschorsch.pl + +first commit of teleschorsch.pl +------------------------------------------------------------------------ +r405 | gregoa | 2007-02-24 20:44:40 +0100 (Sat, 24 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/main.cpp + M /teleschorsch/trunk/teleschorsch.sh + +add/change copyright statement +------------------------------------------------------------------------ +r404 | gregoa | 2007-02-24 20:24:01 +0100 (Sat, 24 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/README + M /teleschorsch/trunk/teleschorsch.sh + +s/TIME/OFFSET/ in teleschorsch.sh +------------------------------------------------------------------------ +r403 | gregoa | 2007-02-24 17:52:57 +0100 (Sat, 24 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/README + D /teleschorsch/trunk/teleschorsch + A /teleschorsch/trunk/teleschorsch.sh (from /teleschorsch/trunk/teleschorsch:402) + +mv teleschorsch teleschorsch.sh (to allow teleschorsch as alternatives and maybe teleschorsch.pl +------------------------------------------------------------------------ +r402 | gregoa | 2007-02-24 17:44:57 +0100 (Sat, 24 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/teleschorsch + +add command line options -xdialog (default) and -dialog to teleschorsch +------------------------------------------------------------------------ +r401 | philipp | 2007-02-24 15:14:42 +0100 (Sat, 24 Feb 2007) | 2 lines +Changed paths: + M /teleschorsch/trunk/main.cpp + +$HOME bug fixed. + +------------------------------------------------------------------------ +r400 | gregoa | 2007-02-24 01:22:09 +0100 (Sat, 24 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/maindialog.ui + M /teleschorsch/trunk/options.ui + +minor changes to dialogs +------------------------------------------------------------------------ +r399 | gregoa | 2007-02-24 01:09:39 +0100 (Sat, 24 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/main.cpp + +read config from /etc/teleschorschrc or /home/gregoa/.teleschorschrc +------------------------------------------------------------------------ +r398 | gregoa | 2007-02-24 00:19:04 +0100 (Sat, 24 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/options.ui + +minor tweaks to options dialog +------------------------------------------------------------------------ +r397 | gregoa | 2007-02-24 00:05:32 +0100 (Sat, 24 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/options.ui + +extend help in options dialog +------------------------------------------------------------------------ +r396 | gregoa | 2007-02-22 23:01:40 +0100 (Thu, 22 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/teleschorsch + +bash version 0.1.0: use config file +------------------------------------------------------------------------ +r395 | gregoa | 2007-02-22 22:52:32 +0100 (Thu, 22 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/teleschorschrc + +change ini file to new +------------------------------------------------------------------------ +r394 | gregoa | 2007-02-22 17:39:55 +0100 (Thu, 22 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/teleschorschrc + +TF1 descriptions +------------------------------------------------------------------------ +r393 | gregoa | 2007-02-22 16:56:52 +0100 (Thu, 22 Feb 2007) | 2 lines +Changed paths: + M /teleschorsch/trunk/main.cpp + M /teleschorsch/trunk/teleschorschrc + +ini file: changed keynames, added "FULLNAME", adapted main.cpp accordingly + +------------------------------------------------------------------------ +r392 | gregoa | 2007-02-22 16:44:34 +0100 (Thu, 22 Feb 2007) | 1 line +Changed paths: + A /teleschorsch/trunk/README + +add README (comments for development) +------------------------------------------------------------------------ +r391 | gregoa | 2007-02-22 16:20:52 +0100 (Thu, 22 Feb 2007) | 1 line +Changed paths: + M /teleschorsch/trunk/teleschorsch + +0.0.6 minor fixes +------------------------------------------------------------------------ +r390 | philipp | 2007-02-22 00:27:04 +0100 (Thu, 22 Feb 2007) | 2 lines +Changed paths: + A /teleschorsch/trunk/main.cpp + A /teleschorsch/trunk/main.h + A /teleschorsch/trunk/maindialog.ui + A /teleschorsch/trunk/options.ui + A /teleschorsch/trunk/qteleschorsch.pro + A /teleschorsch/trunk/teleschorschrc + +Started to program qteleschorsch + +------------------------------------------------------------------------ +r389 | philipp | 2007-02-21 19:41:59 +0100 (Wed, 21 Feb 2007) | 2 lines +Changed paths: + A /teleschorsch/trunk + A /teleschorsch/trunk/teleschorsch + +Initial check-in of Gregors teleschorsch 0.0.5 + +------------------------------------------------------------------------ diff --git a/debian/changelog b/debian/changelog index 598ba00..88c133b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +teleschorsch (0.0.7-1) unstable; urgency=low + + * New upstream release. + + -- gregor herrmann Sun, 4 Mar 2007 03:14:46 +0100 + teleschorsch (0.0.6-1) unstable; urgency=low * New upstream release. diff --git a/debian/rules b/debian/rules index 1772774..8ca6300 100755 --- a/debian/rules +++ b/debian/rules @@ -52,7 +52,7 @@ binary-indep: build install binary-arch: build install dh_testdir dh_testroot - dh_installchangelogs + dh_installchangelogs ChangeLog dh_installdocs # dh_installexamples dh_install diff --git a/main.cpp b/main.cpp index a968403..0c72f6d 100644 --- a/main.cpp +++ b/main.cpp @@ -101,51 +101,114 @@ QString readChannelVec(const ConfigInfo& configInfo, ChannelVec& channelVec) { } -QString substitudeVar(const QString& var, QDate date) { - if (var == "d") return date.toString("dd"); - if (var == "m") return date.toString("MM"); - if (var == "y") return date.toString("yy"); - if (var == "Y") return date.toString("yyyy"); +/// \brief Finds a value for a specified variable and appends it to a string. +/// +/// \param[in] var variable to substitute. These are the possibilities: +/// - d day of month (01-31) +/// - m month (01-12) +/// - y year (last two digits) +/// - Y year (4 digits) +/// - dow_DE day of week in German (Montag, ...) +/// \param[in] date date that should be used when replacing the date dependend variables +/// \param[out] result The determined value of the variable is _appended_. +/// \param[out] error error message in error cases +/// \returns true in case of success. +bool substituteVar(const QString& var, QDate date, QString& result, QString& errorMsg) { + if (var == "d") {result += date.toString("dd"); return true;} + if (var == "m") {result += date.toString("MM"); return true;} + if (var == "y") {result += date.toString("yy"); return true;} + if (var == "Y") {result += date.toString("yyyy"); return true;} if (var == "dow_DE") { int dow = date.dayOfWeek() - 1; - static const char dow_de[][20] = {"Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"}; - if (dow >= 0 && dow < 7) return dow_de[dow]; + static const char dow_de[][16] = {"Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"}; + if (dow >= 0 && dow < 7) {result += dow_de[dow]; return true;} } - return "{no match}"; // maybe do some error handling here... + errorMsg = QObject::tr("No match for variable %1").arg(var); + return false; } -QString substitudeStaticUrl(const QString& staticUrl, QDate date) { - QString result; +/// \brief Finds a string, where variables of the form ${var} are substituted in input (normally a staticUrl). +/// +/// - ${d} day of month (01-31) +/// - ${m} month (01-12) +/// - ${y} year (last two digits) +/// - ${Y} year (4 digits) +/// - ${dow_DE} day of week in German (Montag, ...) +/// +/// \param[in] input string where the substitution should be done. +/// \param[in] date date that should be used when replacing the date dependend variables +/// \param[out] result The result string with the variables substituted is appended here +/// \param[out] error error message in error cases +/// \returns true in case of success. +bool substituteVars(const QString& input, QDate date, QString& result, QString& errorMsg) { int pos = 0; int lastPos = 0; while (pos != -1) { - pos = staticUrl.indexOf("${", lastPos); - if (pos == -1) result += staticUrl.mid(lastPos); - else result += staticUrl.mid(lastPos, pos-lastPos); + pos = input.indexOf("${", lastPos); + if (pos == -1) result += input.mid(lastPos); + else result += input.mid(lastPos, pos-lastPos); lastPos = pos; // Match? if (pos != -1) { - pos = staticUrl.indexOf("}", lastPos); - if (pos == -1) return ""; // ${ not closed with }. Some day we should report the error somehow... - QString var = staticUrl.mid(lastPos+2, pos-lastPos-2); - result += substitudeVar(var, date); + pos = input.indexOf("}", lastPos); + if (pos == -1) { + errorMsg = QObject::tr("${ not closed with }."); + return false; + } + QString var = input.mid(lastPos+2, pos-lastPos-2); + if (!substituteVar(var, date, result, errorMsg)) return false; lastPos = pos+1; } } + return true; +} + + +/// \brief Calls the /bin/sh shell with the specified command and appends the result to a string variable. +/// +/// \param[in] command command to execute with /bin/sh -c "command" +/// \param[out] result The result string where the output is appended at. +/// \param[out] error error message in error cases +/// \returns true in case of success. +bool executeShellCommand(const QString& command, QString& result, QString& errorMsg) { + QProcess evalUrl(0); + QString cmd = "/bin/sh -c \"" + command + "\""; + evalUrl.start(cmd); + if (evalUrl.waitForFinished(3000)) { + QByteArray newResult = evalUrl.readAllStandardOutput(); + if (result != newResult) {result += newResult.trimmed();} + return true; + } + errorMsg = QObject::tr("Shell command executed when substituting URL (%1) timed out.").arg(command); + return false; +} + + +/// \brief Evaluates the staticUrl +/// +/// - Variables of the form ${var} are substituted according the the function ::substituteVars +/// - If the staticUrl is enclosed by backticks it is evaluated by a shell command (after the substitution mentioned above) +/// +/// \param[in] staticUrl string where the substitution should be done. +/// \param[in] date date that should be used when replacing the date dependend variables +/// \param[out] result The result string is appended here +/// \param[out] error error message in error cases +/// \returns true in case of success. +bool evaluateStaticUrl(const QString& staticUrl, QDate date, QString& result, QString& errorMsg) { + QString subst; + bool success = substituteVars(staticUrl, date, subst, errorMsg); + if (!success) return false; // Evaluate staticUrl - it might be dynamic despite its name :-) - if (result.left(1) == "`" && result.right(1) == "`") { - QProcess evalUrl(0); - QString command = "/bin/sh -c \"echo " + result + "\""; - evalUrl.start(command); - if (evalUrl.waitForFinished()) { - QByteArray newResult = evalUrl.readAllStandardOutput(); - if (result != newResult) {result = newResult.trimmed();} - } - } - return result; + QString cmdres; + if (subst.left(1) == "`" && subst.right(1) == "`") { + success = executeShellCommand(subst.mid(1, subst.size()-2), cmdres, errorMsg); + if (!success) return false; + result = cmdres; + } else result = subst; + return true; } @@ -206,13 +269,19 @@ bool MainDialog::startAction() { if (row > 0) { Channel channel = channelVec[row]; QDate date = calDate->selectedDate(); + QString substUrl; + QString errorMsg; + if (!evaluateStaticUrl(channel.staticUrl, date, substUrl, errorMsg)) { + QMessageBox::warning(this, tr("Problem when substituting URL"), errorMsg); + return false; + } QStringList arguments; - arguments.append(substitudeStaticUrl(channel.staticUrl, date)); + arguments.append(substUrl); appendPlayerOffsetOption(channel.player, teOffset->time(), arguments); QProcess player(this); qDebug() << channel.player << arguments; player.start(channel.player, arguments); - player.waitForFinished(); + player.waitForFinished(-1); return true; } return false; diff --git a/maindialog.ui b/maindialog.ui index 18618f4..847e519 100644 --- a/maindialog.ui +++ b/maindialog.ui @@ -5,8 +5,8 @@ 0 0 - 400 - 339 + 672 + 508 @@ -43,7 +43,20 @@ - + + + + 0 + 0 + + + + + 0 + 0 + + + @@ -64,6 +77,14 @@ + + + 0 + 5 + 0 + 0 + + Qt::Monday @@ -83,6 +104,19 @@ + + + + Qt::Vertical + + + + 20 + 1000 + + + + diff --git a/options.cpp b/options.cpp index 97abf6d..4606913 100644 --- a/options.cpp +++ b/options.cpp @@ -11,7 +11,7 @@ OptionsDialog::OptionsDialog(QWidget *parent): QDialog(parent) { helpText.append(tr("
  • ${d}: day of month (01-31)
  • ")); helpText.append(tr("
  • ${m}: month (01-12)
  • ")); helpText.append(tr("
  • ${y}: year (last two digits)
  • ")); - helpText.append(tr("
  • ${Y}: year (4 digits}
  • ")); + helpText.append(tr("
  • ${Y}: year (4 digits)
  • ")); helpText.append(tr("
  • ${dow_DE}: day of week in German (Montag, ...)
  • ")); helpText.append(tr("")); labHelp->setText(helpText); @@ -35,9 +35,11 @@ bool OptionsDialog::exec(const QString& configFile) { } QTextStream in(&configFileUser); while (!in.atEnd()) teIni->append(in.readLine()); + teIni->moveCursor(QTextCursor::Start); } configFileUser.close(); if (QDialog::exec() == QDialog::Accepted) { + if (!teIni->document()->isModified()) return false; // Save if (!configFileUser.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::warning(this, tr("File not writeable"), tr("The config file %1 is not writeable.").arg(configFile)); diff --git a/options.h b/options.h index 924a74e..a476cb0 100644 --- a/options.h +++ b/options.h @@ -10,7 +10,7 @@ public: /// \brief Shows a dialog where the user can edit the specified configuration file. /// /// If the file was modified and successfully saved, true is returned, otherwise false. - /// The dialog shows error to the user itself. + /// The dialog shows errors to the user itself. /// \todo First try to save and afterwards save. This would give the user the chance to copy & paste his/her changes. /// \param configFile file name with full path to the configuration file to edit. bool exec(const QString& configFile); diff --git a/options.ui b/options.ui index d252dd3..97f19f8 100644 --- a/options.ui +++ b/options.ui @@ -5,8 +5,8 @@ 0 0 - 400 - 300 + 618 + 480 @@ -21,6 +21,12 @@ + + + 0 + 0 + + QTextEdit::NoWrap diff --git a/qteleschorsch.pro b/qteleschorsch.pro index aec77a0..6d9c0ec 100644 --- a/qteleschorsch.pro +++ b/qteleschorsch.pro @@ -1,7 +1,7 @@ TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . +# TARGET = +# DEPENDPATH += . +# INCLUDEPATH += . # Input FORMS += maindialog.ui options.ui diff --git a/teleschorschrc b/teleschorschrc index 2d9d373..8b867c0 100644 --- a/teleschorschrc +++ b/teleschorschrc @@ -71,4 +71,4 @@ PLAYER=vlc [ORFoe118] FULLNAME=ORF - Ö1 Abendjournal (only current broadcast) STATICURL=`wget -q -O- "http://oe1.orf.at/konsole/journal?type=abend" | grep -Eo "mms://stream2\.orf\.at/oe1/demand/abend/.+\.WMA"` -PLAYER=vlc +PLAYER=vlc \ No newline at end of file -- 2.30.2