Fetching an active WindowXMLDialog
#1
Hi guys, I'm working on an addon that fires up a webserver to accept http requests to interact with it.

On start up, the server is launched and then the addon is launched, so they're separate processes.

My problem is, I need to get the active WindowXMLDialog inside my web server handler. Since these are separate processes, hacky globals won't really work. I was expecting I could just fetch the active window, or access it by its window id, but neither of these work for WindowXMLDialog.

Does anyone know of a good way i can actually do this? Here' is some code of what is happening in my addon. Thanks guys!


deck.py

PHP Code:
import os
import re
import simplejson
import urllib
import urllib2
import xbmc
import xbmcaddon
import xbmcgui
import common
import threading
import time
from info import InfoWindow
from player import ParlourPlayer

class DeckWindow(xbmcgui.WindowXMLDialog): 

service.py
PHP Code:
import xbmc
import xbmcaddon
import xbmcgui
import xbmcplugin
from parlour
.server_handler import ParlourServerHandler
import os
import time
import BaseHTTPServer

xbmc
.executebuiltin('RunAddon("script.parlour")')



HOST_NAME os.uname()[1]
PORT_NUMBER 1482

server_class 
BaseHTTPServer.HTTPServer
httpd 
server_class((HOST_NAMEPORT_NUMBER), ParlourServerHandler)
print 
time.asctime(), "Parlour Server Starts - %s:%s" % (HOST_NAMEPORT_NUMBER)
try:
    
httpd.serve_forever()
except KeyboardInterrupt:
    
pass
httpd
.server_close()
print 
time.asctime(), "Parlour Server Stops - %s:%s" % (HOST_NAMEPORT_NUMBER

default.py

PHP Code:
import os
import re
import simplejson
import urllib
import urllib2
import xbmc
import xbmcaddon
import xbmcgui
import xbmcplugin
from parlour import common
from parlour
.deck import DeckWindow

xbmc
.Player().stop()

torypHost xbmcaddon.Addon("script.parlour").getSetting("toryp_host")
if 
torypHost == '':
    
torypHost common.askTorypHost()

if 
torypHost != '':
    
deck DeckWindow(14000)
    
deck.setInitialSceneUrl(common.torypUrlForHost(torypHost))
    
deck.doModal()
    
del deck 

server_handler.py
PHP Code:
import xbmc
import xbmcaddon
import xbmcgui
import xbmcplugin
import time
import BaseHTTPServer
from player import ParlourPlayer
from urlparse import urlparse
parse_qs

class ParlourServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
    
def do_HEAD(s):
        
s.send_response(200)
        
s.send_header("Content-type""text/html")
        
s.end_headers()
    
def do_GET(s):
        
"""Respond to a GET request."""
        
s.send_response(200)
        
s.send_header("Content-type""application/json")
        
s.end_headers()
        
s.wfile.write('{"message":"OK", "path":"' s.path '"')
        
full_url_string "http://" s.server.server_name s.path
        url 
urlparse(full_url_string)
        
params parse_qs(url.query)
        
        print 
s.path
        
        
if url.path == '/play':
          print 
params
          
if params.has_key('url'):
            print 
'play playable item at: ' params['url'][0]
            
current_window_id xbmcgui.getCurrentWindowDialogId()
            
current_window xbmcgui.Window(14000)
            
# print repr(current_window)
            # print current_window.__class__.__name__
            # print current_window.popScene()
            
player ParlourPlayer()
            
player.setDelegate(current_window)
            
player.playPlayableItem(params['url'][0], 'loadingggggggg'
Reply

Logout Mark Read Team Forum Stats Members Help
Fetching an active WindowXMLDialog0