Skip to content

Commit

Permalink
[CORE] change the way we handle Presence /!\
Browse files Browse the repository at this point in the history
/!\ Saved profile is corrupted. You can change the presence field to "BSY"
to fix it
Now the presence field in the accountview is the key of the presence
(self._core.Presence.ONLINE for example).
Front-ends needs to update accordingly.
  • Loading branch information
borisfaure committed Sep 20, 2009
1 parent 284017f commit e8e4639
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
4 changes: 3 additions & 1 deletion amsn2/backend/backend.py
@@ -1,7 +1,8 @@

class aMSNBackendManager(object):
def __init__(self):
def __init__(self, core):
self._backend = None
self._core = core
self.switchToBackend('nullbackend')

def setBackendForFunc(self, funcname, backend):
Expand All @@ -21,6 +22,7 @@ def switchToBackend(self, backend):

del self._backend
self._backend = backend_class()
self._backend._core = self._core
self.current_backend = backend

# Config management methods
Expand Down
2 changes: 1 addition & 1 deletion amsn2/backend/defaultaccountbackend.py
Expand Up @@ -40,7 +40,7 @@ def loadAccount(self, email):
accfile.close()
account = root_tree.getroot()
if account.tag == "aMSNAccount":
accview = AccountView()
accview = AccountView(self._core)
#email
emailElmt = account.find("email")
if emailElmt is None:
Expand Down
24 changes: 13 additions & 11 deletions amsn2/core/amsn.py
Expand Up @@ -49,6 +49,17 @@ def __init__(self, options):
options.front_end = the front end's name to use
options.debug = whether or not to enable debug output
"""
self.p2s = {papyon.Presence.ONLINE:"online",
papyon.Presence.BUSY:"busy",
papyon.Presence.IDLE:"idle",
papyon.Presence.AWAY:"away",
papyon.Presence.BE_RIGHT_BACK:"brb",
papyon.Presence.ON_THE_PHONE:"phone",
papyon.Presence.OUT_TO_LUNCH:"lunch",
papyon.Presence.INVISIBLE:"hidden",
papyon.Presence.OFFLINE:"offline"}
self.Presence = papyon.Presence

self._event_manager = aMSNEventManager(self)
self._options = options

Expand All @@ -58,25 +69,16 @@ def __init__(self, options):
self._main = None
self.loadUI(self._options.front_end)

self._backend_manager = aMSNBackendManager()
self._backend_manager = aMSNBackendManager(self)
self._account_manager = aMSNAccountManager(self, options)
self._account = None
self._theme_manager = aMSNThemeManager()
self._theme_manager = aMSNThemeManager(self)
self._contactlist_manager = aMSNContactListManager(self)
self._oim_manager = aMSNOIMManager(self)
self._conversation_manager = aMSNConversationManager(self)
self._personalinfo_manager = aMSNPersonalInfoManager(self)


self.p2s = {papyon.Presence.ONLINE:"online",
papyon.Presence.BUSY:"busy",
papyon.Presence.IDLE:"idle",
papyon.Presence.AWAY:"away",
papyon.Presence.BE_RIGHT_BACK:"brb",
papyon.Presence.ON_THE_PHONE:"phone",
papyon.Presence.OUT_TO_LUNCH:"lunch",
papyon.Presence.INVISIBLE:"hidden",
papyon.Presence.OFFLINE:"offline"}

# TODO: redirect the logs somewhere, something like ctrl-s ctrl-d for amsn-0.9x
logging.basicConfig(level=logging.WARNING)
Expand Down
3 changes: 2 additions & 1 deletion amsn2/core/theme_manager.py
Expand Up @@ -24,7 +24,8 @@
import os

class aMSNThemeManager:
def __init__(self):
def __init__(self, core):
self._core = core
self._buttons = {}
self._statusicons = {}
self._displaypic = {}
Expand Down
8 changes: 5 additions & 3 deletions amsn2/core/views/accountview.py
Expand Up @@ -3,12 +3,13 @@
from stringview import *

class AccountView:
def __init__(self):
def __init__(self, core):
self._core = core
self.email = None
self.password = None
self.nick = StringView()
self.psm = StringView()
self.presence = 'online'
self.presence = core.Presence.ONLINE
self.dp = ImageView()

self.save = False
Expand All @@ -19,7 +20,8 @@ def __init__(self):
self.preferred_backend = 'defaultbackend'

def __str__(self):
out = "{ email=" + str(self.email) + " presence=" + str(self.presence)
out = "{ email=" + str(self.email)
out += " presence=" + self._core.p2s[self.presence]
out += " save=" + str(self.save) + " save_password=" + str(self.save_password)
out += " autologin=" + str(self.autologin) + " preferred_ui=" + str(self.preferred_ui)
out += " preferred_backend=" + self.preferred_backend + " }"
Expand Down

0 comments on commit e8e4639

Please sign in to comment.