Mercurial > libervia-backend
comparison frontends/src/quick_frontend/quick_contact_management.py @ 1009:d1084f7e56a5
quick_frontend: use of new logging system
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 05 May 2014 18:58:34 +0200 |
parents | 1fe00f0c9a91 |
children | 75025461141f |
comparison
equal
deleted
inserted
replaced
1008:d70d4fe5c5f8 | 1009:d1084f7e56a5 |
---|---|
16 | 16 |
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 from logging import debug, info, warning, error | 21 from sat.core.log import getLogger |
22 log = getLogger(__name__) | |
22 from sat.tools.jid import JID | 23 from sat.tools.jid import JID |
23 import pdb | |
24 | 24 |
25 | 25 |
26 class QuickContactManagement(object): | 26 class QuickContactManagement(object): |
27 """This helper class manage the contacts and ease the use of nicknames and shortcuts""" | 27 """This helper class manage the contacts and ease the use of nicknames and shortcuts""" |
28 ### FIXME: is SàT a better place for all this stuff ??? ### | 28 ### FIXME: is SàT a better place for all this stuff ??? ### |
66 if self.__contactlist[entity.bare]['statuses']: | 66 if self.__contactlist[entity.bare]['statuses']: |
67 return self.__contactlist[entity.bare]['statuses'].values()[0] | 67 return self.__contactlist[entity.bare]['statuses'].values()[0] |
68 if self.__contactlist[entity.bare].has_key(name): | 68 if self.__contactlist[entity.bare].has_key(name): |
69 return self.__contactlist[entity.bare][name] | 69 return self.__contactlist[entity.bare][name] |
70 else: | 70 else: |
71 debug(_('Trying to get attribute for an unknown contact')) | 71 log.debug(_('Trying to get attribute for an unknown contact')) |
72 return None | 72 return None |
73 | 73 |
74 def isConnected(self, entity): | 74 def isConnected(self, entity): |
75 """Tell if the contact is online""" | 75 """Tell if the contact is online""" |
76 return self.__contactlist.has_key(entity.bare) | 76 return self.__contactlist.has_key(entity.bare) |
82 self.__contactlist[entity.bare]['resources'].remove(entity.resource) | 82 self.__contactlist[entity.bare]['resources'].remove(entity.resource) |
83 if not entity.resource or not self.__contactlist[entity.bare]['resources']: | 83 if not entity.resource or not self.__contactlist[entity.bare]['resources']: |
84 #no more resource available: the contact seems really disconnected | 84 #no more resource available: the contact seems really disconnected |
85 del self.__contactlist[entity.bare] | 85 del self.__contactlist[entity.bare] |
86 except KeyError: | 86 except KeyError: |
87 error(_('INTERNAL ERROR: Key error')) | 87 log.error(_('INTERNAL ERROR: Key log.error')) |
88 raise | 88 raise |
89 | 89 |
90 def update(self, entity, key, value): | 90 def update(self, entity, key, value): |
91 """Update attribute of contact | 91 """Update attribute of contact |
92 @param entity: jid of the contact | 92 @param entity: jid of the contact |
94 @param value: value of the attribute | 94 @param value: value of the attribute |
95 """ | 95 """ |
96 if self.__contactlist.has_key(entity.bare): | 96 if self.__contactlist.has_key(entity.bare): |
97 self.__contactlist[entity.bare][key] = value | 97 self.__contactlist[entity.bare][key] = value |
98 else: | 98 else: |
99 debug (_('Trying to update an unknown contact: %s'), entity.bare) | 99 log.debug (_('Trying to update an unknown contact: %s') % entity.bare) |
100 | 100 |
101 def get_full(self, entity): | 101 def get_full(self, entity): |
102 return entity.bare+'/'+self.__contactlist[entity.bare]['resources'][-1] | 102 return entity.bare+'/'+self.__contactlist[entity.bare]['resources'][-1] |
103 | 103 |