Mercurial > libervia-backend
comparison tools/memory.py @ 68:9b842086d915
multiple profiles update
- Wix: new profile managed, it appear at launch in place of the contact list, and disappear once the profile is choosen
- SàT: default profile is now saved, first one is choosed is no default profile
- Bridge: new delete profile method
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 25 Feb 2010 17:09:18 +1100 |
parents | 8147b4f40809 |
children | 86f1f7f6d332 |
comparison
equal
deleted
inserted
replaced
67:0e50dd3a234a | 68:9b842086d915 |
---|---|
117 def getProfilesList(self): | 117 def getProfilesList(self): |
118 return self.params.keys() | 118 return self.params.keys() |
119 | 119 |
120 def createProfile(self, name): | 120 def createProfile(self, name): |
121 """Create a new profile | 121 """Create a new profile |
122 @param name: Name of the profile | 122 @param name: Name of the profile""" |
123 @param default: True if default value""" | |
124 if self.params.has_key(name): | 123 if self.params.has_key(name): |
125 info ('The profile name already exists') | 124 info ('The profile name already exists') |
126 return 1 | 125 return 1 |
127 self.params[name]={} | 126 self.params[name]={} |
127 return 0 | |
128 | |
129 def deleteProfile(self, name): | |
130 """Delete an existing profile | |
131 @param name: Name of the profile""" | |
132 if not self.params.has_key(name): | |
133 error ('Trying to delete an unknown profile') | |
134 return 1 | |
135 del self.params[name] | |
128 return 0 | 136 return 0 |
129 | 137 |
130 def getProfileName(self, profile_key): | 138 def getProfileName(self, profile_key): |
131 """return profile according to profile_key | 139 """return profile according to profile_key |
132 @param profile_key: profile name or key which can be | 140 @param profile_key: profile name or key which can be |
134 @DEFAULT@ for default profile | 142 @DEFAULT@ for default profile |
135 @return: requested profile name or None if it doesn't exist""" | 143 @return: requested profile name or None if it doesn't exist""" |
136 if profile_key=='@DEFAULT@': | 144 if profile_key=='@DEFAULT@': |
137 if not self.params: | 145 if not self.params: |
138 return "" | 146 return "" |
139 info('No default profile, returning first one') #TODO: manage real default profile | 147 default = self.host.memory.getPrivate('Profile_default') |
140 return self.params.keys()[0] #FIXME: gof: temporary, must use real default value, and fallback to first one if it doesn't exists | 148 if not default or not default in self.params: |
149 info('No default profile, returning first one') #TODO: manage real default profile | |
150 default = self.params.keys()[0] | |
151 self.host.memory.setPrivate('Profile_default', default) | |
152 return default #FIXME: gof: temporary, must use real default value, and fallback to first one if it doesn't exists | |
141 if not self.params.has_key(profile_key): | 153 if not self.params.has_key(profile_key): |
142 error ('Trying to access an unknown profile') | 154 info ('Trying to access an unknown profile') |
143 return "" | 155 return "" |
144 return profile_key | 156 return profile_key |
145 | 157 |
146 def __get_unique_node(self, parent, tag, name): | 158 def __get_unique_node(self, parent, tag, name): |
147 """return node with given tag | 159 """return node with given tag |
449 """Return name of profile from keyword | 461 """Return name of profile from keyword |
450 @param profile_key: can be the profile name or a keywork (like @DEFAULT@) | 462 @param profile_key: can be the profile name or a keywork (like @DEFAULT@) |
451 @return: profile name or None if it doesn't exist""" | 463 @return: profile name or None if it doesn't exist""" |
452 return self.params.getProfileName(profile_key) | 464 return self.params.getProfileName(profile_key) |
453 | 465 |
454 def createProfile(self, name, default=False): | 466 def createProfile(self, name): |
455 """Create a new profile | 467 """Create a new profile |
456 @param name: Profile name | 468 @param name: Profile name |
457 @param default: True if default profile (replace previous default) | |
458 """ | 469 """ |
459 return self.params.createProfile(name, default) | 470 return self.params.createProfile(name) |
471 | |
472 def deleteProfile(self, name): | |
473 """Delete an existing profile | |
474 @param name: Name of the profile""" | |
475 return self.params.deleteProfile(name) | |
460 | 476 |
461 def addToHistory(self, me_jid, from_jid, to_jid, type, message): | 477 def addToHistory(self, me_jid, from_jid, to_jid, type, message): |
462 me_short=me_jid.userhost() | 478 me_short=me_jid.userhost() |
463 from_short=from_jid.userhost() | 479 from_short=from_jid.userhost() |
464 to_short=to_jid.userhost() | 480 to_short=to_jid.userhost() |