3 from eveapi import eveapi
6 # we will store our preferences in gconf
9 #ugly hack to check maemo version. any better way?
10 if hasattr(hildon, "StackableWindow"):
11 from ui.fremantle import ui
13 from ui.diablo import ui
17 self.program = hildon.Program()
18 self.program.__init__()
20 self.gconf = gnome.gconf.client_get_default()
21 self.ui = ui.mEveMonUI(self)
27 def quit(self, *args):
30 def get_api_key(self):
31 return self.gconf.get_string("/apps/maemo/mevemon/eve_api_key") or ''
34 return self.gconf.get_string("/apps/maemo/mevemon/eve_uid") or ''
36 def set_api_key(self, key):
37 self.gconf.set_string("/apps/maemo/mevemon/eve_api_key", key)
39 def set_uid(self, uid):
40 self.gconf.set_string("/apps/maemo/mevemon/eve_uid", uid)
42 # 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
43 def get_characters( self ):
45 # error message --danny
46 placeholder_chars = [("Please check your API settings.", "imgs/error.jpg")]
47 api = eveapi.EVEAPIConnection()
49 api_key = self.get_api_key()
50 # if they are entered into gconf, try getting api data --danny
51 if ( uid and api_key ):
52 auth = api.auth( userID = uid, apiKey = api_key )
54 api_char_list = auth.account.Characters()
55 except eveapi.Error, e:
56 # if we can't, return the error message/pic --danny
57 return placeholder_chars
59 # unknown exception, dunno if this needs to be here if I just ignore it... probably a bad idea, but it was in the apitest.py example... --danny
60 return placeholder_chars
61 # append each char we get to the list we'll return to the UI --danny
62 for character in api_char_list.characters:
63 ui_char_list.append( ( character.name, fetchimg.portrait_filename( character.characterID, 64 ) ) )
65 # if not entered into gconf, error message --danny
67 return placeholder_chars
69 if __name__ == "__main__":