xbmc/xbmc — pull request #728 by Montellese (2012-02-25 16:09:03+00:00)
Title: JSON-RPC notifications for python scripts

Currently the only way for python scripts using JSON-RPC to receive JSON-RPC notifications is to open a TCP socket to localhost:9090 and parse the notifications coming through the socket. This has two major drawbacks:
1. This only works if the user enabled "Allow programs on this system to control XBMC" in Settings -> Network -> Services
2. The TCP port (default 9090) is configurable through advancedsettings.xml so an addon using this method needs to add a configuration option to allow changing the port for users who changed that port through AS.xml

This implementation adds a new python class xbmc.JSONRPCClient which can be used as a base class in a python script. By overriding the onNotification() method it is possible to receive JSON-RPC notifications in that method (similar to how the player callbacks (OnPlaybackStarted etc) work). Furthermore the whole logic from xbmc.executeJSONRPC has been moved to xbmc.JSONRPCClient.execute().

As I'm not very familiar with the python callback stuff I mainly copied from the player callback implementation and made the necessary adjustments. So I'd be grateful if someone could take a closer look at that part of the changes to make sure I didn't screw something up. I tested this (on win32) by modifying a python script of an existing addon and it worked fine for me.