summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-11-26 23:05:09 +0100
committermathieui <mathieui@mathieui.net>2011-11-26 23:05:09 +0100
commit64b8970d259171b5f59807fab77a149c0df630c7 (patch)
treed8f9250b1c3aefc46a1d6064a6e208e501c83716
parent2eaa54058921ade7702b71567d709fe589603a61 (diff)
downloadpoezio-64b8970d259171b5f59807fab77a149c0df630c7.tar.gz
poezio-64b8970d259171b5f59807fab77a149c0df630c7.tar.bz2
poezio-64b8970d259171b5f59807fab77a149c0df630c7.tar.xz
poezio-64b8970d259171b5f59807fab77a149c0df630c7.zip
Enhance the Bookmark class
-rw-r--r--src/bookmark.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/bookmark.py b/src/bookmark.py
index fe926350..8b4fed27 100644
--- a/src/bookmark.py
+++ b/src/bookmark.py
@@ -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