2 SleekXMPP: The Sleek XMPP Library
3 Copyright (C) 2010 Nathanael C. Fritz, Erik Reuterborg Larsson
4 This file is part of SleekXMPP.
6 See the file LICENSE for copying permission.
12 from sleekxmpp
.plugins
.base
import BasePlugin
13 from sleekxmpp
.xmlstream
import register_stanza_plugin
14 from sleekxmpp
.plugins
.xep_0080
import stanza
, Geoloc
17 log
= logging
.getLogger(__name__
)
20 class XEP_0080(BasePlugin
):
23 XEP-0080: User Location
27 description
= 'XEP-0080: User Location'
28 dependencies
= set(['xep_0163'])
32 self
.xmpp
['xep_0163'].remove_interest(Geoloc
.namespace
)
33 self
.xmpp
['xep_0030'].del_feature(feature
=Geoloc
.namespace
)
35 def session_bind(self
, jid
):
36 self
.xmpp
['xep_0163'].register_pep('user_location', Geoloc
)
38 def publish_location(self
, **kwargs
):
40 Publish the user's current location.
43 accuracy -- Horizontal GPS error in meters.
44 alt -- Altitude in meters above or below sea level.
45 area -- A named area such as a campus or neighborhood.
46 bearing -- GPS bearing (direction in which the entity is
47 heading to reach its next waypoint), measured in
48 decimal degrees relative to true north.
49 building -- A specific building on a street or in an area.
50 country -- The nation where the user is located.
51 countrycode -- The ISO 3166 two-letter country code.
53 description -- A natural-language name for or description of
55 error -- Horizontal GPS error in arc minutes. Obsoleted by
56 the accuracy parameter.
57 floor -- A particular floor in a building.
58 lat -- Latitude in decimal degrees North.
59 locality -- A locality within the administrative region, such
61 lon -- Longitude in decimal degrees East.
62 postalcode -- A code used for postal delivery.
63 region -- An administrative region of the nation, such
64 as a state or province.
65 room -- A particular room in a building.
66 speed -- The speed at which the entity is moving,
68 street -- A thoroughfare within the locality, or a crossing
70 text -- A catch-all element that captures any other
71 information about the location.
72 timestamp -- UTC timestamp specifying the moment when the
74 uri -- A URI or URL pointing to information about
77 options -- Optional form of publish options.
78 ifrom -- Specify the sender's JID.
79 block -- Specify if the send call will block until a response
80 is received, or a timeout occurs. Defaults to True.
81 timeout -- The length of time (in seconds) to wait for a response
82 before exiting the send call if blocking is used.
83 Defaults to sleekxmpp.xmlstream.RESPONSE_TIMEOUT
84 callback -- Optional reference to a stream handler function. Will
85 be executed when a reply stanza is received.
87 options
= kwargs
.get('options', None)
88 ifrom
= kwargs
.get('ifrom', None)
89 block
= kwargs
.get('block', None)
90 callback
= kwargs
.get('callback', None)
91 timeout
= kwargs
.get('timeout', None)
92 for param
in ('ifrom', 'block', 'callback', 'timeout', 'options'):
97 geoloc
.values
= kwargs
99 return self
.xmpp
['xep_0163'].publish(geoloc
,
106 def stop(self
, ifrom
=None, block
=True, callback
=None, timeout
=None):
108 Clear existing user location information to stop notifications.
111 ifrom -- Specify the sender's JID.
112 block -- Specify if the send call will block until a response
113 is received, or a timeout occurs. Defaults to True.
114 timeout -- The length of time (in seconds) to wait for a response
115 before exiting the send call if blocking is used.
116 Defaults to sleekxmpp.xmlstream.RESPONSE_TIMEOUT
117 callback -- Optional reference to a stream handler function. Will
118 be executed when a reply stanza is received.
121 return self
.xmpp
['xep_0163'].publish(geoloc
,