Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
8487bdb8
by Philipp Hörist at 2018-10-19T13:59:04Z
2 changed files:
Changes:
| ... | ... | @@ -166,6 +166,7 @@ class Bookmarks: |
| 166 | 166 |
autojoin_val = conf.getAttr('autojoin')
|
| 167 | 167 |
if not autojoin_val: # not there (it's optional)
|
| 168 | 168 |
autojoin_val = False
|
| 169 |
+ |
|
| 169 | 170 |
minimize_val = conf.getTag('minimize', namespace=NS_GAJIM_BM)
|
| 170 | 171 |
if not minimize_val: # not there, try old Gajim behaviour
|
| 171 | 172 |
minimize_val = conf.getAttr('minimize')
|
| ... | ... | @@ -189,19 +190,27 @@ class Bookmarks: |
| 189 | 190 |
conf.getAttr('jid'))
|
| 190 | 191 |
continue
|
| 191 | 192 |
|
| 193 |
+ bookmark = {
|
|
| 194 |
+ 'name': conf.getAttr('name'),
|
|
| 195 |
+ 'password': conf.getTagData('password'),
|
|
| 196 |
+ 'nick': conf.getTagData('nick'),
|
|
| 197 |
+ 'print_status': print_status
|
|
| 198 |
+ }
|
|
| 199 |
+ |
|
| 200 |
+ try:
|
|
| 201 |
+ bookmark['autojoin'] = from_xs_boolean(autojoin_val)
|
|
| 202 |
+ bookmark['minimize'] = from_xs_boolean(minimize_val)
|
|
| 203 |
+ except ValueError as error:
|
|
| 204 |
+ log.warning(error)
|
|
| 205 |
+ continue
|
|
| 206 |
+ |
|
| 192 | 207 |
if check_merge:
|
| 193 | 208 |
if jid in self.bookmarks:
|
| 194 | 209 |
continue
|
| 195 | 210 |
merged = True
|
| 196 | 211 |
|
| 197 | 212 |
log.debug('Found Bookmark: %s', jid)
|
| 198 |
- self.bookmarks[jid] = {
|
|
| 199 |
- 'name': conf.getAttr('name'),
|
|
| 200 |
- 'autojoin': from_xs_boolean(autojoin_val),
|
|
| 201 |
- 'minimize': from_xs_boolean(minimize_val),
|
|
| 202 |
- 'password': conf.getTagData('password'),
|
|
| 203 |
- 'nick': conf.getTagData('nick'),
|
|
| 204 |
- 'print_status': print_status}
|
|
| 213 |
+ self.bookmarks[jid] = bookmark
|
|
| 205 | 214 |
|
| 206 | 215 |
return merged
|
| 207 | 216 |
|
| ... | ... | @@ -47,20 +47,16 @@ def is_muc_pm(message: nbxmpp.Node, |
| 47 | 47 |
|
| 48 | 48 |
|
| 49 | 49 |
def from_xs_boolean(value: Union[str, bool]) -> bool:
|
| 50 |
- # Convert a xs:boolean ('true', 'false', '1', '0', '')
|
|
| 51 |
- # to a python boolean (True, False)
|
|
| 52 | 50 |
if isinstance(value, bool):
|
| 53 | 51 |
return value
|
| 54 | 52 |
|
| 55 |
- if value in ('1', 'true'):
|
|
| 53 |
+ if value in ('1', 'true', 'True'):
|
|
| 56 | 54 |
return True
|
| 57 | 55 |
|
| 58 |
- # '0', 'false' or empty
|
|
| 59 |
- if value in ('0', 'false', ''):
|
|
| 56 |
+ if value in ('0', 'false', 'False', ''):
|
|
| 60 | 57 |
return False
|
| 61 | 58 |
|
| 62 |
- raise ValueError(
|
|
| 63 |
- 'Cant convert %s to python boolean' % value)
|
|
| 59 |
+ raise ValueError('Cant convert %s to python boolean' % value)
|
|
| 64 | 60 |
|
| 65 | 61 |
|
| 66 | 62 |
def to_xs_boolean(value: Union[bool, None]) -> str:
|