Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of git://github.com/drf/amsn2

  • Loading branch information...
commit c1e26951f0eb6e090b3d864fcf1db6e075368d78 2 parents 80e4e5f + 10ac7bd
authored September 24, 2009
4  amsn2/backend/backend.py
... ...
@@ -1,7 +1,8 @@
1 1
 
2 2
 class aMSNBackendManager(object):
3  
-    def __init__(self):
  3
+    def __init__(self, core):
4 4
         self._backend = None
  5
+        self._core = core
5 6
         self.switchToBackend('nullbackend')
6 7
 
7 8
     def setBackendForFunc(self, funcname, backend):
@@ -21,6 +22,7 @@ def switchToBackend(self, backend):
21 22
 
22 23
         del self._backend
23 24
         self._backend = backend_class()
  25
+        self._backend._core = self._core
24 26
         self.current_backend = backend
25 27
 
26 28
         # Config management methods
2  amsn2/backend/defaultaccountbackend.py
@@ -40,7 +40,7 @@ def loadAccount(self, email):
40 40
         accfile.close()
41 41
         account = root_tree.getroot()
42 42
         if account.tag == "aMSNAccount":
43  
-            accview = AccountView()
  43
+            accview = AccountView(self._core)
44 44
             #email
45 45
             emailElmt = account.find("email")
46 46
             if emailElmt is None:
37  amsn2/core/amsn.py
@@ -49,6 +49,17 @@ def __init__(self, options):
49 49
            options.front_end = the front end's name to use
50 50
            options.debug = whether or not to enable debug output
51 51
         """
  52
+        self.p2s = {papyon.Presence.ONLINE:"online",
  53
+                    papyon.Presence.BUSY:"busy",
  54
+                    papyon.Presence.IDLE:"idle",
  55
+                    papyon.Presence.AWAY:"away",
  56
+                    papyon.Presence.BE_RIGHT_BACK:"brb",
  57
+                    papyon.Presence.ON_THE_PHONE:"phone",
  58
+                    papyon.Presence.OUT_TO_LUNCH:"lunch",
  59
+                    papyon.Presence.INVISIBLE:"hidden",
  60
+                    papyon.Presence.OFFLINE:"offline"}
  61
+        self.Presence = papyon.Presence
  62
+
52 63
         self._event_manager = aMSNEventManager(self)
53 64
         self._options = options
54 65
 
@@ -56,28 +67,17 @@ def __init__(self, options):
56 67
         self._gui = None
57 68
         self._loop = None
58 69
         self._main = None
  70
+        self._account = None
59 71
         self.loadUI(self._options.front_end)
60 72
 
61  
-        self._backend_manager = aMSNBackendManager()
  73
+        self._backend_manager = aMSNBackendManager(self)
62 74
         self._account_manager = aMSNAccountManager(self, options)
63  
-        self._account = None
64  
-        self._theme_manager = aMSNThemeManager()
  75
+        self._theme_manager = aMSNThemeManager(self)
65 76
         self._contactlist_manager = aMSNContactListManager(self)
66 77
         self._oim_manager = aMSNOIMManager(self)
67 78
         self._conversation_manager = aMSNConversationManager(self)
68 79
         self._personalinfo_manager = aMSNPersonalInfoManager(self)
69 80
 
70  
-
71  
-        self.p2s = {papyon.Presence.ONLINE:"online",
72  
-                    papyon.Presence.BUSY:"busy",
73  
-                    papyon.Presence.IDLE:"idle",
74  
-                    papyon.Presence.AWAY:"away",
75  
-                    papyon.Presence.BE_RIGHT_BACK:"brb",
76  
-                    papyon.Presence.ON_THE_PHONE:"phone",
77  
-                    papyon.Presence.OUT_TO_LUNCH:"lunch",
78  
-                    papyon.Presence.INVISIBLE:"hidden",
79  
-                    papyon.Presence.OFFLINE:"offline"}
80  
-
81 81
         # TODO: redirect the logs somewhere, something like ctrl-s ctrl-d for amsn-0.9x
82 82
         logging.basicConfig(level=logging.WARNING)
83 83
 
@@ -103,6 +103,9 @@ def loadUI(self, ui_name):
103 103
 
104 104
         self._gui_name = ui_name
105 105
         self._gui = gui.GUIManager(self, self._gui_name)
  106
+        if not self._gui.gui:
  107
+            print "Unable to load UI %s" %(self._gui_name,)
  108
+            self.quit()
106 109
         self._loop = self._gui.gui.aMSNMainLoop(self)
107 110
         self._main = self._gui.gui.aMSNMainWindow(self)
108 111
         self._skin_manager = self._gui.gui.SkinManager(self)
@@ -209,10 +212,12 @@ def timerAdd(self, delay, func):
209 212
         self._loop.timerAdd(delay, func)
210 213
 
211 214
     def quit(self):
212  
-        if self._account is not None:
  215
+        if self._account:
213 216
             self._account.signOut()
214  
-        self._loop.quit()
  217
+        if self._loop:
  218
+            self._loop.quit()
215 219
         logging.shutdown()
  220
+        exit(0)
216 221
 
217 222
     # TODO: move to UImanager
218 223
     def addContact(self):
3  amsn2/core/theme_manager.py
@@ -24,7 +24,8 @@
24 24
 import os
25 25
 
26 26
 class aMSNThemeManager:
27  
-    def __init__(self):
  27
+    def __init__(self, core):
  28
+        self._core = core
28 29
         self._buttons = {}
29 30
         self._statusicons = {}
30 31
         self._displaypic = {}
8  amsn2/core/views/accountview.py
@@ -3,12 +3,13 @@
3 3
 from stringview import *
4 4
 
5 5
 class AccountView:
6  
-    def __init__(self):
  6
+    def __init__(self, core):
  7
+        self._core = core
7 8
         self.email = None
8 9
         self.password = None
9 10
         self.nick = StringView()
10 11
         self.psm = StringView()
11  
-        self.presence = 'online'
  12
+        self.presence = core.Presence.ONLINE
12 13
         self.dp = ImageView()
13 14
 
14 15
         self.save = False
@@ -19,7 +20,8 @@ def __init__(self):
19 20
         self.preferred_backend = 'defaultbackend'
20 21
 
21 22
     def __str__(self):
22  
-        out = "{ email=" + str(self.email) + " presence=" + str(self.presence)
  23
+        out = "{ email=" + str(self.email)
  24
+        out += " presence=" + self._core.p2s[self.presence]
23 25
         out += " save=" + str(self.save) + " save_password=" + str(self.save_password)
24 26
         out += " autologin=" + str(self.autologin) + " preferred_ui=" + str(self.preferred_ui)
25 27
         out += " preferred_backend=" + self.preferred_backend + " }"
2  papyon
... ...
@@ -1 +1 @@
1  
-Subproject commit cc69fd6bb2f6b24ed4ea4c614f5fe88a58db9ec0
  1
+Subproject commit b8cf878a7104b312c787846fecc4c62b21d9a803

0 notes on commit c1e2695

Please sign in to comment.
Something went wrong with that request. Please try again.