fixed openwebif patch.
[vuplus_openvuplus_3.0] / meta-openvuplus / recipes-vuplus / e2openplugins / enigma2-plugin-extensions-openwebif / openwebif_8001_8002.patch
1 diff --git a/plugin/controllers/models/stream.py b/plugin/controllers/models/stream.py
2 index c42ba76..4380052 100644
3 --- a/plugin/controllers/models/stream.py
4 +++ b/plugin/controllers/models/stream.py
5 @@ -38,11 +38,16 @@ def getStream(session, request, m3ufile):
6         if "name" in request.args:
7                 name = request.args["name"][0]
8         # #EXTINF:-1,%s\n  remove not compatiple with old api
9 +       portNumber = 8001
10 +       if "device" in request.args :
11 +               if request.args["device"][0] == "phone" :
12 +                       portNumber = 8002;
13         if sRef != '':
14                 progopt="#EXTVLCOPT:program=%d\n" % (int(sRef.split(':')[3],16))
15         else:
16                 progopt=""
17 -       response = "#EXTM3U \n#EXTVLCOPT--http-reconnect=true \n%shttp://%s:8001/%s\n" % (progopt,request.getRequestHostname(), sRef)
18 +       #response = "#EXTM3U \n#EXTVLCOPT--http-reconnect=true \n%shttp://%s:8001/%s\n" % (progopt,request.getRequestHostname(), sRef)
19 +       response = "#EXTM3U \n#EXTVLCOPT--http-reconnect=true \n%shttp://%s:%s/%s\n" % (progopt,request.getRequestHostname(), portNumber, sRef)
20         request.setHeader('Content-Type', 'application/text')
21         return response
22  
23 diff --git a/plugin/controllers/views/ajax/channels.tmpl b/plugin/controllers/views/ajax/channels.tmpl
24 index 9bad685..a8253d2 100755
25 --- a/plugin/controllers/views/ajax/channels.tmpl
26 +++ b/plugin/controllers/views/ajax/channels.tmpl
27 @@ -15,9 +15,12 @@
28  <a href="#" onclick="open_epg_pop('$channel.ref')">
29  <img src="../images/ico_epg.png" title="Show EPG for $channel.name" border="0">
30  </a>
31 -<a target="_blank" href='/web/stream.m3u?ref=$channel.ref&name=$channel.name'>
32 +<a href="#" onclick="jumper8001('$channel.ref', '$channel.name');">
33  <img align="top" src="../images/ico_stream.png" title="Stream $channel.name" border="0">
34  </a>
35 +<a href="#" onclick="jumper8002('$channel.ref', '$channel.name');">
36 +<img align="top" src="../images/ico_stream.png" title="Stream Port 8002 $channel.name" border="0">
37 +</a>
38  #else
39  <a target="_blank" href='#'>
40  <img align="top" src="../images/ico_lock.png" title="Locked" border="0">
41 diff --git a/plugin/controllers/views/main.tmpl b/plugin/controllers/views/main.tmpl
42 index 12b9941..3d0debc 100755
43 --- a/plugin/controllers/views/main.tmpl
44 +++ b/plugin/controllers/views/main.tmpl
45 @@ -9,6 +9,69 @@
46  <script type="text/javascript" src="/js/jquery-ui-1.8.18.custom.min.js"></script>\r
47  <script type="text/javascript" src="/js/openwebif.js"></script>\r
48  \r
49 +<script>\r
50 +       // VuPlus Port Jumper \r
51 +       // 2012.12.10\r
52 +       function getWinSize(win) {                      \r
53 +               if(!win) win = window;                  \r
54 +               var s = {};                     \r
55 +               if(typeof win.innerWidth != "undefined") {\r
56 +                       s.screenWidth = win.screen.width;                               \r
57 +                       s.screenHeight = win.screen.height;                     \r
58 +               } else {\r
59 +                       s.screenWidth = 0;                              \r
60 +                       s.screenHeight = 0;                     \r
61 +               }                       \r
62 +               return s;               \r
63 +       }\r
64 +\r
65 +       function getDeviceType() {\r
66 +               var ss = getWinSize();  \r
67 +               var screenLen = 0;\r
68 +               // alert( ss.screenHeight );    \r
69 +               // alert( ss.screenWidth );     \r
70 +\r
71 +               if( ss.screenHeight > ss.screenWdith ) {                \r
72 +                       screenLen = ss.screenHeight;    \r
73 +               } else {                \r
74 +                       screenLen = ss.screenWidth;     \r
75 +               }       \r
76 +\r
77 +               if( screenLen < 500 ) {         \r
78 +                       return "phone"; \r
79 +               } else {\r
80 +                       return "tab";   \r
81 +               }\r
82 +       }\r
83 +\r
84 +       function getOSType() {\r
85 +               var agentStr = navigator.userAgent;\r
86 +\r
87 +               if(agentStr.indexOf("iPod") > -1 || agentStr.indexOf("iPhone") > -1)\r
88 +                       return "ios";\r
89 +               else if(agentStr.indexOf("Android") > -1)\r
90 +                       return "android";\r
91 +               else\r
92 +                       return "unknown";\r
93 +       }\r
94 +\r
95 +       function jumper8002( sref, sname ) {\r
96 +               var deviceType = getDeviceType();\r
97 +               document.portForm.ref.value = sref;\r
98 +               document.portForm.name.value = sname;\r
99 +               document.portForm.device.value = "phone";\r
100 +               document.portForm.submit();\r
101 +       }\r
102 +\r
103 +       function jumper8001( sref, sname ) {\r
104 +               var deviceType = getDeviceType();\r
105 +               document.portForm.ref.value = sref;\r
106 +               document.portForm.name.value = sname;\r
107 +               document.portForm.device.value = "etc";\r
108 +               document.portForm.submit();\r
109 +       }\r
110 +</script>\r
111 +\r
112  <title>Open Webif</title>\r
113  </head>\r
114  \r
115 @@ -196,5 +259,11 @@
116                         <div id="footer"><h3>&nbsp;&nbsp;<a href="https://github.com/E2OpenPlugins">E2OpenPlugins</a> | <a href="http://www.vuplus-community.net">Black Hole</a> | <a href="http://openpli.org">OpenPli</a> | <a href="http://forum.sifteam.eu">Sif</a> | <a href="http://www.vuplus-support.org">Vti</a></h3></div>\r
117                 </div>\r
118         </div>\r
119 +\r
120 +       <form name="portForm" action="/web/stream.m3u" method="GET" target="_blank">\r
121 +               <input type="hidden" name="ref">\r
122 +               <input type="hidden" name="name">\r
123 +               <input type="hidden" name="device">\r
124 +       </form>\r
125  </body>\r
126  </html>\r