Added get_characters() function in controller. Very rough, needs work.
[mevemon] / mevemon.py
index c1533f6..ce7cc63 100644 (file)
@@ -1,6 +1,6 @@
 import hildon
 import gtk
-import eveapi
+from eveapi import eveapi
 
 # we will store our preferences in gconf
 import gnome.gconf
@@ -37,8 +37,34 @@ class mEveMon():
 
     def set_uid(self, uid):
         self.gconf.set_string("/apps/maemo/mevemon/eve_uid", uid)
-       
 
+    # really quick hack to get character list. doesn't handle errors well, and if it can't get the gconf settings it just returns the placeholders, when in reality it should tell the UI or something. basically half finished, just uploading to show ry... FIXME --danny
+    def get_characters( self ):
+        ui_char_list = []
+        print 'get_characters() called.'
+        placeholder_chars = [("Character 1", "avatar.png"), ("Character 2", "avatar.png")]
+        api = eveapi.EVEAPIConnection()
+        uid = self.get_uid()
+        api_key = self.get_api_key()
+        if ( uid and api_key ):
+            auth = api.auth( userID = uid, apiKey = api_key )
+            try:
+                api_char_list = auth.account.Characters()
+            except eveapi.Error, e:
+                print "Sorry, eveapi returned error code %s." % e.code
+                print '"' + e.message + '"'
+                return placeholder_chars
+            except Exception, e:
+                print "The sky is falling! Unknown error: ", str( e )
+                raise
+            print "grabbing character list:"
+            for character in api_char_list.characters:
+                print character
+                ui_char_list.append( ( character.name, "avatar.png" ) )
+            return ui_char_list
+        else:
+            return placeholder_chars
+        
 if __name__ == "__main__":
     app = mEveMon()
     app.run()