Exemplo n.º 1
0
 def update_room(self, jid, **attrs):
     """ Should only be called from the connection. """
     if jid in self._rooms:
         room = self._rooms[jid]
         updated = update(room, **attrs)
         return (room, False, updated)
     else:
         room = Room(jid=jid, **attrs)
         self._rooms[jid] = room
         return (room, True, {})
Exemplo n.º 2
0
 def update_buddy(self, jid, **attrs):
     """ Should only be called from the connection. """
     if jid in self._buddies:
         buddy = self._buddies[jid]
         updated = update(buddy, **attrs)
         return (buddy, False, updated)
     else:
         buddy = Buddy(jid=jid, **attrs)
         self._buddies[jid] = buddy
         return (buddy, True, {})
Exemplo n.º 3
0
 def received(self, message):
     if not self.check(message):
         return False
     if message.response.code == 0:
         updated = update(self.buddy, **self.attrs)
         if self.buddy.is_room():
             self.con.listeners.room_updated(self.buddy, **updated)
         else:
             self.con.listeners.buddy_updated(self.buddy, **updated)
     else:
         logger.error("Error received in response to buddy edit: %s" % message.response)
     return True
Exemplo n.º 4
0
 def received(self, message):
     if not self.check(message):
         return False
     
     if message.response.code == 0:
         profile = self.con.roster.self_buddy
         updated = update(profile, **self.values)
         if updated:
             self.con.listeners.profile_updated(profile, **updated)
     else:
         logger.error("Cannot update profile: %s" % (message.response))
     
     return True
Exemplo n.º 5
0
 def received(self, message):
     if not self.check(message):
         return False
     
     if message.response.code == 0:
         logger.info("Profile response: %s" % (message.data))
         name, private_id, birthdate, gender_id, q = message.data[0]
         private = PrivateNumber.byid(private_id)
         gender = Gender.byid(gender_id)
         
         
         profile = self.con.roster.self_buddy
         
         updated = update(profile, name=name, birthdate=birthdate, private=private, gender=gender)
         
         if updated:
             self.con.listeners.profile_updated(profile, **updated)
     else:
         logger.error("Error requesting profile: %s" % (message.response))
     
     return True