3 from eveapi import eveapi
5 # we will store our preferences in gconf
8 #ugly hack to check maemo version. any better way?
9 if hasattr(hildon, "StackableWindow"):
10 from ui.fremantle import ui
12 from ui.diablo import ui
16 self.program = hildon.Program()
17 self.program.__init__()
19 self.gconf = gnome.gconf.client_get_default()
20 self.ui = ui.mEveMonUI(self)
26 def quit(self, *args):
29 def get_api_key(self):
30 return self.gconf.get_string("/apps/maemo/mevemon/eve_api_key") or ''
33 return self.gconf.get_string("/apps/maemo/mevemon/eve_uid") or ''
35 def set_api_key(self, key):
36 self.gconf.set_string("/apps/maemo/mevemon/eve_api_key", key)
38 def set_uid(self, uid):
39 self.gconf.set_string("/apps/maemo/mevemon/eve_uid", uid)
41 # 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
42 def get_characters( self ):
44 print 'get_characters() called.'
45 placeholder_chars = [("Character 1", "avatar.png"), ("Character 2", "avatar.png")]
46 api = eveapi.EVEAPIConnection()
48 api_key = self.get_api_key()
49 if ( uid and api_key ):
50 auth = api.auth( userID = uid, apiKey = api_key )
52 api_char_list = auth.account.Characters()
53 except eveapi.Error, e:
54 print "Sorry, eveapi returned error code %s." % e.code
55 print '"' + e.message + '"'
56 return placeholder_chars
58 print "The sky is falling! Unknown error: ", str( e )
60 print "grabbing character list:"
61 for character in api_char_list.characters:
63 ui_char_list.append( ( character.name, "avatar.png" ) )
66 return placeholder_chars
68 if __name__ == "__main__":