summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlado <herrlado@gmail.com>2011-10-24 13:17:16 +0200
committerlado <herrlado@gmail.com>2011-10-24 13:17:16 +0200
commitdab4548643729a218f83b59fa489bd5e2f39fb84 (patch)
tree48673389628a1a8053475cc57f5acda2135e2906
parent913cff1fdc75512c99c22cf2f89a20fbdbd729f0 (diff)
downloadvdr-manager-dab4548643729a218f83b59fa489bd5e2f39fb84.tar.gz
vdr-manager-dab4548643729a218f83b59fa489bd5e2f39fb84.tar.bz2
UnMapSpecialChars for unescape special chars + handling : in timer title and description
-rw-r--r--vdr-vdrmanager/helpers.cpp40
-rw-r--r--vdr-vdrmanager/helpers.h2
2 files changed, 37 insertions, 5 deletions
diff --git a/vdr-vdrmanager/helpers.cpp b/vdr-vdrmanager/helpers.cpp
index a20fc98..4d7422e 100644
--- a/vdr-vdrmanager/helpers.cpp
+++ b/vdr-vdrmanager/helpers.cpp
@@ -224,7 +224,7 @@ string cHelpers::DelRecordingIntern(string args) {
}
string cHelpers::SetTimerIntern(string args) {
-
+
// separete timer number
size_t sep = args.find(':');
if (sep == string::npos) {
@@ -232,14 +232,25 @@ string cHelpers::SetTimerIntern(string args) {
}
char c = args[0];
-
+
string numberstr = args.substr(sep-1,1);
-
+
int number = atoi(numberstr.c_str());
string params = args.substr(sep+1);
-
-
+
+ // Use StringReplace here because if ':' are characters in the
+ // title or aux string it breaks parsing of timer definition
+ // in VDRs cTimer::Parse method. The '|' will be replaced
+ // back to ':' by the cTimer::Parse() method.
+
+ // Fix was submitted by rofafor: see
+ // http://www.vdr-portal.de/board/thread.php?threadid=100398
+ params = replaceAll(params, "|##", "|");
+
+ //replace also newlines
+ params = replaceAll(params, "||#", "\n");
+
// parse timer
cTimer * timer = new cTimer;
if (!timer->Parse(params.c_str())) {
@@ -658,3 +669,22 @@ string cHelpers::MapSpecialChars(string text) {
}
return result;
}
+
+string cHelpers::replaceAll(string where, string what, string replacement){
+ int position = where.find(what);
+ int size = what.size();
+ while ( position != string::npos )
+ {
+ where.replace( position, size, replacement );
+ position = where.find(what, position + 1 );
+ }
+ return where;
+}
+
+string cHelpers::UnMapSpecialChars(string text) {
+
+ string ntext = replaceAll(text, "|##", ":");
+ ntext = replaceAll(ntext, "||#", "\n");
+
+ return ntext;
+}
diff --git a/vdr-vdrmanager/helpers.h b/vdr-vdrmanager/helpers.h
index a57d634..83e3630 100644
--- a/vdr-vdrmanager/helpers.h
+++ b/vdr-vdrmanager/helpers.h
@@ -41,4 +41,6 @@ private:
static string ToText(cTimer * timer);
static string ToText(cRecording * recording);
static string GetAudioTracks(const cChannel* channel);
+ static string replaceAll(string where, string what, string replacement);
+ static string UnMapSpecialChars(string text);
};