00001 #include "LCDKdeMultimediaSensor.h"
00002 #include "LCDUtils.h"
00003
00004 #include <string>
00005 #include <unistd.h>
00006
00007 using namespace std;
00008
00009 LCDKdeMultimediaSensor::LCDKdeMultimediaSensor(std::string defaultValue)
00010 {
00011 _previousValue = "NO";
00012 _defaultValue = defaultValue;
00013 }
00014
00015 void LCDKdeMultimediaSensor::waitForChange()
00016 {
00017 while (_previousValue == getCurrentValue())
00018 {
00019 sleep(1);
00020 }
00021 _previousValue = getCurrentValue();
00022 }
00023
00024 string LCDKdeMultimediaSensor::getCurrentValue()
00025 {
00026 string value;
00027
00028 string noatunId = executeCommand("dcop | grep noatun");
00029
00030 if (noatunId != "")
00031 {
00032 value = executeCommand("dcop " + noatunId + " Noatun title");
00033 }
00034 else
00035 {
00036 string kscdTitle = executeCommand("dcop kscd CDPlayer currentTrackTitle");
00037 if (kscdTitle != "")
00038 {
00039 value = kscdTitle;
00040 }
00041 }
00042
00043 if (value == "")
00044 {
00045 value = _defaultValue;
00046 }
00047
00048 return value;
00049 }