add: send Messages to Tv-Screen
authorRico Schulte <ricoschulte@users.schwerkraft.elitedvb.net>
Tue, 23 Jan 2007 19:58:53 +0000 (19:58 +0000)
committerRico Schulte <ricoschulte@users.schwerkraft.elitedvb.net>
Tue, 23 Jan 2007 19:58:53 +0000 (19:58 +0000)
webinterface/src/WebComponents/Sources/Message.py [new file with mode: 0644]
webinterface/src/web-data/templates.js
webinterface/src/web-data/tools.js
webinterface/src/web/message.xml [new file with mode: 0644]
webinterface/src/webif.py

diff --git a/webinterface/src/WebComponents/Sources/Message.py b/webinterface/src/WebComponents/Sources/Message.py
new file mode 100644 (file)
index 0000000..cd9c9d0
--- /dev/null
@@ -0,0 +1,53 @@
+from enigma import *
+from Components.Sources.Source import Source
+from Screens.MessageBox import MessageBox
+
+class Message( Source):
+        
+    def __init__(self,session):
+        self.cmd = []
+        self.session = session
+        Source.__init__(self)
+
+    def handleCommand(self, cmd):
+        self.cmd = cmd
+        
+    def do_func(self):
+        list = []
+        
+        if self.cmd['text'] == "" or self.cmd['text'] is None:
+            return [[False,"no text for message"]]
+        else:
+            mtext = self.cmd['text']
+
+        try:
+            typeint = int(self.cmd['type'])
+        except ValueError,e:
+            return [[False,"type %s is not a number"%self.cmd['type']]]   
+            
+        if typeint == MessageBox.TYPE_YESNO:
+            #dont know how to give the result to the webif back 
+            mtype= MessageBox.TYPE_YESNO
+        elif typeint == MessageBox.TYPE_INFO:
+            mtype= MessageBox.TYPE_INFO
+        elif typeint == MessageBox.TYPE_WARNING:
+            mtype= MessageBox.TYPE_WARNING
+        elif typeint == MessageBox.TYPE_ERROR:
+            mtype= MessageBox.TYPE_ERROR
+        else:
+            return [[False,"unsupported type %s"%self.cmd['type']]]   
+        
+        try:
+            mtimeout = int(self.cmd['timeout'])
+        except ValueError,e:
+            mtimeout = -1   
+        
+        self.session.open(MessageBox, mtext, type = mtype ,timeout = mtimeout)
+        
+        return [[True,"Message send to screen"]]
+    
+    list = property(do_func)
+    lut = {"Result": 0
+           ,"ResultText": 1
+           }
+
index 0a4446f..0c91f54 100644 (file)
@@ -141,3 +141,16 @@ var tplSignalPanel  = '<table width="100%" id="SignalPanelTable">';
        
 var tplSignalPanelButton = '<img src="/webdata/gfx/signal.png" title="show SignalInfoPanel" onclick="openSignalDialog();" title="view Signal Info">';
 
+// Message send
+var tplMessageSendForm = ""
+       tplMessageSendForm += '<table id="MessageSendForm" width="100%" border="0" cellspacing="1" cellpadding="0" border="0">';
+       tplMessageSendForm += '<tr><td>Text</td><td><input type="text" id="MessageSendFormText" value=""></td></tr>\n';
+       tplMessageSendForm += '<tr><td>Timeout</td><td><input type="text" id="MessageSendFormTimeout" value=""></td></tr>\n';
+       tplMessageSendForm += '<tr><td>Typ</td><td><select id="MessageSendFormType">';
+       tplMessageSendForm += '<option value="1">Info</option>';
+       tplMessageSendForm += '<option value="0">YesNo</option>';
+       tplMessageSendForm += '<option value="2">Warning</option>';
+       tplMessageSendForm += '<option value="3">Error</option>';
+       tplMessageSendForm += '</select></td></tr>\n';
+       tplMessageSendForm += '<tr><td colspan="2"><button onclick="sendMessage()">send Message</button></td></tr>\n';
+       tplMessageSendForm += "</table></form>\n";
index 5a89afc..60ff053 100644 (file)
@@ -19,6 +19,8 @@ var url_timeradd= "/web/timeradd"; // plus serviceref,begin,end,name,description
 var url_timeraddbyeventid= "/web/timeraddbyeventid"; // plus serviceref,eventid
 var url_timerdelete= "/web/timerdelete"; // plus serviceref,bedin,end
 
+var url_message = "/web/message"; // plus text,type,timeout
+
 var bouqet_tv = '1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 195) || (type == 25)FROM BOUQUET "bouquets.tv" ORDER BY bouquet';
 var bouqet_radio = '1:7:2:0:0:0:0:0:0:0:(type == 2)FROM BOUQUET "bouquets.radio" ORDER BY bouquet';
 var bouqet_provider_tv = '1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 195) || (type == 25) FROM PROVIDERS ORDER BY name';
@@ -580,4 +582,36 @@ function incomingTimerDelResult(request){
 function loadTimerForm() {
        debug("timers form");
        debug("there is still work to do here");
+}
+
+// send Messages
+function showMessageSendForm(){
+               document.getElementById('BodyContentChannellist').innerHTML = tplMessageSendForm;
+}
+function sendMessage(messagetext,messagetype,messagetimeout){
+       if(!messagetext){
+               messagetext = $('MessageSendFormText').value;
+       }       
+       if(!messagetimeout){
+               messagetimeout = $('MessageSendFormTimeout').value;
+       }       
+       if(!messagetype){
+               var index = $('MessageSendFormType').selectedIndex;
+               messagetype = $('MessageSendFormType').options[index].value;
+       }       
+       doRequest(url_message+'?text='+messagetext+'&type='+messagetype+'&timeout='+messagetimeout, incomingMessageResult);
+}
+function incomingMessageResult(request){
+       if(request.readyState == 4){
+               var b = getXML(request).getElementsByTagName("e2message");
+               var result = b.item(0).getElementsByTagName('e2result').item(0).firstChild.data;
+               var resulttext = b.item(0).getElementsByTagName('e2resulttext').item(0).firstChild.data;
+               if (result=="True"){
+                       messageBox('message send','message send successfully! it appears on TV-Screen');
+               }else{
+                       messageBox('message send failed',resulttext);
+               }
+       }               
+
+       
 }
\ No newline at end of file
diff --git a/webinterface/src/web/message.xml b/webinterface/src/web/message.xml
new file mode 100644 (file)
index 0000000..9b593b9
--- /dev/null
@@ -0,0 +1,8 @@
+<e2:screen name="TestScreen">&lt;?xml version="1.0" encoding="UTF-8"?>
+&lt;e2message>
+       <e2:element source="Message" id="text,type,timeout"><e2:convert type="web:ListFiller" >
+       &lt;e2result><e2:item name="Result" filter="xml"/>&lt;/e2result>
+       &lt;e2resulttext><e2:item name="ResultText" filter="xml"/>&lt;/e2resulttext>
+       </e2:convert><e2:convert type="web:TextToHTML" /></e2:element>
+&lt;/e2message>
+</e2:screen>
\ No newline at end of file
index f35aee7..b6673a4 100644 (file)
@@ -20,6 +20,7 @@ from WebComponents.Sources.Volume import Volume
 from WebComponents.Sources.EPG import EPG
 from WebComponents.Sources.Timer import Timer
 from WebComponents.Sources.Movie import Movie
+from WebComponents.Sources.Message import Message
 from Components.Sources.FrontendStatus import FrontendStatus
 
 from Components.Converter.Converter import Converter
@@ -64,6 +65,7 @@ class TestScreen(InfoBarServiceName, InfoBarEvent,InfoBarTuner, WebScreen):
                self["TimerDel"] = Timer(session,func = Timer.DEL)
                self["MovieList"] = Movie(session)
                self["Volume"] = Volume(session)
+               self["Message"] = Message(session)
 
        def browseTo(self, reftobrowse):
                self["ServiceListBrowse"].root = reftobrowse