Enhance the Bookmark class

This commit is contained in:
mathieui 2011-11-26 23:05:09 +01:00
parent 2eaa540589
commit 64b8970d25

View file

@ -1,11 +1,27 @@
import os
from sleekxmpp.plugins.xep_0048 import *
from core import JID
from config import config
preferred = config.get('use_bookmarks_method', 'pep').lower()
if preferred not in ('pep', 'privatexml'):
preferred = 'pep'
not_preferred = 'pep' if preferred is 'privatexml' else 'privatexml'
methods = ('local', preferred, not_preferred)
class Bookmark(object):
possible_methods = ('pep', 'privatexml', 'local')
possible_methods = methods
def __init__(self, jid, name=None, autojoin=False, nick=None, password=None, method=None):
self.jid = jid
self.name = name or jid
self.autojoin = autojoin
if not nick:
default = os.environ.get('USER') if os.environ.get('USER') else 'poezio'
nick = config.get('default_nick', '') or default
self.nick = nick
self.password = password
self._method = method
@ -20,6 +36,9 @@ class Bookmark(object):
return
self._method = value
def __repr__(self):
return '<%s>' % self.jid
def stanza(self):
"""
Generate a <conference/> stanza from the instance