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.
11 from slixmpp
.plugins
.base
import BasePlugin
12 from slixmpp
.plugins
.xep_0108
import stanza
, UserActivity
15 log
= logging
.getLogger(__name__
)
18 class XEP_0108(BasePlugin
):
21 XEP-0108: User Activity
25 description
= 'XEP-0108: User Activity'
26 dependencies
= set(['xep_0163'])
30 self
.xmpp
['xep_0030'].del_feature(feature
=UserActivity
.namespace
)
31 self
.xmpp
['xep_0163'].remove_interest(UserActivity
.namespace
)
33 def session_bind(self
, jid
):
34 self
.xmpp
['xep_0163'].register_pep('user_activity', UserActivity
)
36 def publish_activity(self
, general
, specific
=None, text
=None,
37 options
=None, ifrom
=None, callback
=None,
38 timeout
=None, timeout_callback
=None):
40 Publish the user's current activity.
43 general -- The required general category of the activity.
44 specific -- Optional specific activity being done as part
45 of the general category.
46 text -- Optional natural-language description or reason
48 options -- Optional form of publish options.
49 ifrom -- Specify the sender's JID.
50 timeout -- The length of time (in seconds) to wait for a response
51 before exiting the send call if blocking is used.
52 Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
53 callback -- Optional reference to a stream handler function. Will
54 be executed when a reply stanza is received.
56 activity
= UserActivity()
57 activity
['value'] = (general
, specific
)
58 activity
['text'] = text
59 self
.xmpp
['xep_0163'].publish(activity
, node
=UserActivity
.namespace
,
60 options
=options
, ifrom
=ifrom
,
63 timeout_callback
=timeout_callback
)
65 def stop(self
, ifrom
=None, callback
=None, timeout
=None,
66 timeout_callback
=None):
68 Clear existing user activity information to stop notifications.
71 ifrom -- Specify the sender's JID.
72 timeout -- The length of time (in seconds) to wait for a response
73 before exiting the send call if blocking is used.
74 Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
75 callback -- Optional reference to a stream handler function. Will
76 be executed when a reply stanza is received.
78 activity
= UserActivity()
79 self
.xmpp
['xep_0163'].publish(activity
, node
=UserActivity
.namespace
,
80 ifrom
=ifrom
, callback
=callback
,
82 timeout_callback
=timeout_callback
)