5 import util.misc as misc_utils
9 _moduleLogger = logging.getLogger(__name__)
12 #class LocationMixin(tp.ConnectionInterfaceLocation):
13 class LocationMixin(object):
16 #tp.ConnectionInterfaceLocation.__init__(self)
24 raise NotImplementedError("Abstract property called")
26 @misc_utils.log_exception(_moduleLogger)
27 def GetLocations(self, contacts):
29 @returns {Contact: {Location Type: Location}}
32 (contact, self._get_location(contact))
33 for contact in contacts
37 for (contact, location) in contactLocation
41 @misc_utils.log_exception(_moduleLogger)
42 def RequestLocation(self, contact):
44 @returns {Location Type: Location}
46 return self._get_location(contact)
48 @misc_utils.log_exception(_moduleLogger)
49 def SetLocation(self, location):
51 Since presence is based off of phone numbers, not allowing the client to change it
53 raise telepathy.errors.PermissionDenied()
55 def _get_location(self, contact):
56 h = self.get_handle_by_id(telepathy.HANDLE_TYPE_CONTACT, contact)
57 if isinstance(h, handle.ConnectionHandle):
58 number = self.session.backend.get_callback_number()
60 number = h.phoneNumber
62 rawData = self.session.location.request_location(number)
67 "country": rawData["country"],
68 "city": rawData["city"],
69 "region": rawData["region"],