Fix the iq.send() function, and a bunch of places where it is called
[slixmpp.git] / slixmpp / plugins / xep_0196 / user_gaming.py
blobf0dee99f1c004587ac3362956777f28ae718bbfc
1 """
2 Slixmpp: The Slick XMPP Library
3 Copyright (C) 2011 Nathanael C. Fritz, Lance J.T. Stout
4 This file is part of Slixmpp.
6 See the file LICENSE for copying permission.
7 """
9 import logging
11 from slixmpp.plugins.base import BasePlugin
12 from slixmpp.plugins.xep_0196 import stanza, UserGaming
15 log = logging.getLogger(__name__)
18 class XEP_0196(BasePlugin):
20 """
21 XEP-0196: User Gaming
22 """
24 name = 'xep_0196'
25 description = 'XEP-0196: User Gaming'
26 dependencies = set(['xep_0163'])
27 stanza = stanza
29 def plugin_end(self):
30 self.xmpp['xep_0030'].del_feature(feature=UserGaming.namespace)
31 self.xmpp['xep_0163'].remove_interest(UserGaming.namespace)
33 def session_bind(self, jid):
34 self.xmpp['xep_0163'].register_pep('user_gaming', UserGaming)
36 def publish_gaming(self, name=None, level=None, server_name=None,
37 uri=None, character_name=None,
38 character_profile=None, server_address=None,
39 options=None, ifrom=None, callback=None,
40 timeout=None, timeout_callback=None):
41 """
42 Publish the user's current gaming status.
44 Arguments:
45 name -- The name of the game.
46 level -- The user's level in the game.
47 uri -- A URI for the game or relevant gaming service
48 server_name -- The name of the server where the user is playing.
49 server_address -- The hostname or IP address of the server where the
50 user is playing.
51 character_name -- The name of the user's character in the game.
52 character_profile -- A URI for a profile of the user's character.
53 options -- Optional form of publish options.
54 ifrom -- Specify the sender's JID.
55 timeout -- The length of time (in seconds) to wait for a response
56 before exiting the send call if blocking is used.
57 Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
58 callback -- Optional reference to a stream handler function. Will
59 be executed when a reply stanza is received.
60 """
61 gaming = UserGaming()
62 gaming['name'] = name
63 gaming['level'] = level
64 gaming['uri'] = uri
65 gaming['character_name'] = character_name
66 gaming['character_profile'] = character_profile
67 gaming['server_name'] = server_name
68 gaming['server_address'] = server_address
69 return self.xmpp['xep_0163'].publish(gaming,
70 node=UserGaming.namespace,
71 options=options, ifrom=ifrom,
72 callback=callback, timeout=timeout,
73 timeout_callback=timeout_callback)
75 def stop(self, ifrom=None, callback=None, timeout=None,
76 timeout_callback=None):
77 """
78 Clear existing user gaming information to stop notifications.
80 Arguments:
81 ifrom -- Specify the sender's JID.
82 timeout -- The length of time (in seconds) to wait for a response
83 before exiting the send call if blocking is used.
84 Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
85 callback -- Optional reference to a stream handler function. Will
86 be executed when a reply stanza is received.
87 """
88 gaming = UserGaming()
89 return self.xmpp['xep_0163'].publish(gaming,
90 node=UserGaming.namespace,
91 ifrom=ifrom, callback=callback,
92 timeout=timeout,
93 timeout_callback=timeout_callback)