3 from eveapi import eveapi
7 # we will store our preferences in gconf
10 #ugly hack to check maemo version. any better way?
11 if hasattr(hildon, "StackableWindow"):
12 from ui.fremantle import ui
14 from ui.diablo import ui
18 self.program = hildon.Program()
19 self.program.__init__()
21 self.gconf = gnome.gconf.client_get_default()
22 self.ui = ui.mEveMonUI(self)
28 def quit(self, *args):
31 def get_api_key(self):
32 return self.gconf.get_string("/apps/maemo/mevemon/eve_api_key") or ''
35 return self.gconf.get_string("/apps/maemo/mevemon/eve_uid") or ''
37 def set_api_key(self, key):
38 self.gconf.set_string("/apps/maemo/mevemon/eve_api_key", key)
40 def set_uid(self, uid):
41 self.gconf.set_string("/apps/maemo/mevemon/eve_uid", uid)
43 # 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
44 def get_characters( self ):
46 # error message --danny
47 placeholder_chars = [("Please check your API settings.", "imgs/error.jpg")]
48 cached_api = eveapi.EVEAPIConnection( cacheHandler = apicache.cache_handler( debug = False ) )
50 api_key = self.get_api_key()
51 # if they are entered into gconf, try getting api data --danny
52 if ( uid and api_key ):
53 auth = cached_api.auth( userID = uid, apiKey = api_key )
55 api_char_list = auth.account.Characters()
56 except eveapi.Error, e:
57 # if we can't, return the error message/pic --danny
58 return placeholder_chars
60 # 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
61 ##return placeholder_chars
63 # append each char we get to the list we'll return to the UI --danny
64 for character in api_char_list.characters:
65 ui_char_list.append( ( character.name, fetchimg.portrait_filename( character.characterID, 64 ) ) )
67 # if not entered into gconf, error message --danny
69 return placeholder_chars
71 if __name__ == "__main__":