summaryrefslogtreecommitdiff
path: root/status.c
diff options
context:
space:
mode:
Diffstat (limited to 'status.c')
-rw-r--r--status.c105
1 files changed, 98 insertions, 7 deletions
diff --git a/status.c b/status.c
index 08e5c88..aaa7def 100644
--- a/status.c
+++ b/status.c
@@ -1,23 +1,42 @@
/*
- * $Id: status.c,v 1.1 2004/12/19 22:03:19 lordjaxom Exp $
+ * $Id: status.c,v 1.2 2004/12/21 18:35:54 lordjaxom Exp $
*/
#include "status.h"
+#include "render.h"
-cText2SkinStatus *cText2SkinStatus::mStatus = NULL;
-const std::string cText2SkinStatus::ReplayNames[__REPLAY_COUNT__] =
+const std::string ReplayNames[__REPLAY_COUNT__] =
{ "", "normal", "mp3", "mplayer", "dvd", "vcd", "image" };
+cText2SkinStatus *cText2SkinStatus::mStatus = NULL;
cText2SkinStatus Text2SkinStatus;
-cText2SkinStatus::cText2SkinStatus(void) {
+cText2SkinStatus::cText2SkinStatus(void):
+ mRender(NULL),
+ mReplayMode(replayNone),
+ mRecordings(),
+ mCurrentRecording(0),
+ mNextRecording(0)
+{
mStatus = this;
- mReplayMode = replayNone;
+}
+
+void cText2SkinStatus::SetRender(cText2SkinRender *Render)
+{
+ mRender = Render;
+ mCurrentRecording = 0;
+ mNextRecording = 0;
}
void cText2SkinStatus::Replaying(const cControl* /*Control*/, const char *Name) {
+ Dprintf("cText2SkinStatus::Replaying(%s)\n", Name);
+ eReplayMode oldMode = mReplayMode;
+
+ if (mRender != NULL)
+ mRender->UpdateLock();
+
if (Name != NULL) {
- mReplayMode = replayNormal;
+ mReplayMode = replayMPlayer;
if (strlen(Name) > 6 && Name[0]=='[' && Name[3]==']' && Name[5]=='(') {
int i;
for (i = 6; Name[i]; ++i) {
@@ -26,7 +45,10 @@ void cText2SkinStatus::Replaying(const cControl* /*Control*/, const char *Name)
}
if (Name[i]) // replaying mp3
mReplayMode = replayMP3;
- } else if (strcmp(Name, "DVD") == 0)
+ }
+ else if (GetRecordingByName(Name) != NULL)
+ mReplayMode = replayNormal;
+ else if (strcmp(Name, "DVD") == 0)
mReplayMode = replayDVD;
else if (strcmp(Name, "VCD") == 0)
mReplayMode = replayVCD;
@@ -46,4 +68,73 @@ void cText2SkinStatus::Replaying(const cControl* /*Control*/, const char *Name)
}
} else
mReplayMode = replayNone;
+
+ if (mRender != NULL) {
+ if (mReplayMode != oldMode)
+ mRender->SetDirty();
+ mRender->UpdateUnlock();
+ }
+}
+
+void cText2SkinStatus::Recording(const cDevice *Device, const char *Name)
+{
+ if (mRender != NULL)
+ mRender->UpdateLock();
+
+ if (Name != NULL) {
+ tRecordingInfo info(Name, Device);
+ mRecordings.push_back(info);
+ } else {
+ tRecordings::iterator it = mRecordings.begin();
+ for (; it != mRecordings.end(); ++it) {
+ if ((*it).device == Device && StoppedTimer((*it).name.c_str())) {
+ mRecordings.erase(it);
+ break;
+ }
+ }
+ }
+
+ if (mRender != NULL) {
+ mRender->UpdateUnlock();
+ mRender->Flush(true);
+ }
+}
+
+cxType cText2SkinStatus::GetTokenData(const txToken &Token)
+{
+ switch (Token.Type) {
+ case tReplayMode:
+ return ReplayNames[mReplayMode];
+
+ case tCurrentRecording:
+ if (Token.Attrib.Type == aNumber) {
+ return mRecordings.size() > (uint)Token.Attrib.Number
+ ? (cxType)mRecordings[Token.Attrib.Number].name
+ : (cxType)false;
+ } else if (mRecordings.size() > 0) {
+ uint now = time_ms();
+ if (mNextRecording == 0)
+ mNextRecording = now + 2000;
+ else if (now >= mNextRecording) {
+ mCurrentRecording = (mCurrentRecording + 1) % mRecordings.size();
+ mNextRecording = now + 2000;
+ }
+
+ uint next = 0;
+ if (mRecordings.size() > 1) {
+ next = mNextRecording - now;
+ Dprintf("next update in %d ms\n", next);
+ }
+
+ cxType res = mRecordings[mCurrentRecording].name;
+ res.SetNoCache();
+ return res;
+ }
+ return false;
+
+ default:
+ break;
+ };
+
+ return cxType::False;
}