finished preliminary support for multiple accounts
authorRyan Campbell <campbellr@gmail.com>
Thu, 29 Apr 2010 22:50:14 +0000 (16:50 -0600)
committerRyan Campbell <campbellr@gmail.com>
Thu, 29 Apr 2010 23:07:31 +0000 (17:07 -0600)
Some cleanup could be made, but the basic support for
multiple eve accounts is working.

Diablo GUI will need some changes to get working (see
Fremantle GUI changes for info).

package/src/mevemon.py
package/src/ui/fremantle/gui.py
package/src/ui/models.py

index 0b189a3..d138978 100755 (executable)
@@ -72,7 +72,6 @@ class mEveMon():
         self.gconf.set_string("/apps/maemo/mevemon/accounts/%s" % uid, api_key)
 
     def get_auth(self, uid):
-        
         api_key = self.get_api_key(uid)
 
         try:
@@ -91,6 +90,20 @@ class mEveMon():
 
         return sheet
 
+    def charid2uid(self, charID):
+        acct_dict = self.get_accounts()
+        
+        for uid, apiKey in acct_dict.items():
+            auth = self.cached_api.auth(userID=uid, apiKey=apiKey)
+            api_char_list = auth.account.Characters()
+            
+            for character in api_char_list.characters:
+                if character.characterID== charID:
+                    return uid
+
+        
+        return None
+    
     def char_id2name(self, charID):
         # the api can take a comma-seperated list of ids, but we'll just take
         # a single id for now
index 0f33d6b..e3b50ef 100644 (file)
@@ -103,11 +103,9 @@ class BaseUI():
             elif result == RESPONSE_EDIT:
                 # get the selected treeview item and pop up the account_box
                 self.edit_account(accounts_treeview)
-                pass
             elif result == RESPONSE_DELETE:
                 # get the selected treeview item, and delete the gconf keys
                 self.delete_account(accounts_treeview)
-                pass
             elif result == gtk.RESPONSE_OK:
                 self.char_model.get_characters()
                 break
@@ -116,7 +114,7 @@ class BaseUI():
 
         dialog.destroy()
 
-   def get_selected_item(treeview, column):
+    def get_selected_item(treeview, column):
         selection = treeview.get_selection()
         model, miter = selection.get_selected() 
         
@@ -300,8 +298,10 @@ class CharacterSheetUI(BaseUI):
         
         # column 0 is the portrait, column 1 is name
         char_name = model.get_value(miter, 1)
+        uid = model.get_value(miter, 2)
         self.char_id = self.controller.char_name2id(char_name)
-        self.sheet = self.controller.get_char_sheet(self.char_id)
+
+        self.sheet = self.controller.get_char_sheet(uid, self.char_id)
 
         win.set_title(char_name)
 
@@ -328,7 +328,7 @@ class CharacterSheetUI(BaseUI):
         self.fill_stats(stats_vbox)
         
         self.add_label("<big>Skill in Training:</big>", vbox, align="normal")
-        skill = self.controller.get_skill_in_training(self.char_id)
+        skill = self.controller.get_skill_in_training(uid, self.char_id)
         
         if skill.skillInTraining:
 
index 8c4a620..41d3f77 100644 (file)
@@ -59,7 +59,9 @@ class CharacterSkillsModel(gtk.ListStore):
     def get_skills(self):
         self.clear()
         
-        self.sheet = self.controller.get_char_sheet(self.charID)
+        uid = self.controller.charid2uid(self.charID)
+
+        self.sheet = self.controller.get_char_sheet(uid, self.charID)
         
         skilltree = self.controller.get_skill_tree()