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__()
20 self.gconf = gnome.gconf.client_get_default()
22 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)
45 api_key = self.get_api_key()
46 cached_api = eveapi.EVEAPIConnection( cacheHandler = apicache.cache_handler( debug = False ) )
49 self.auth = cached_api.auth( userID = uid, apiKey = api_key )
50 except eveapi.Error, e:
51 # if we can't, return the error message/pic --danny
54 # unknown exception, dunno if this needs to be here if I just
55 # ignore it... probably a bad idea, but it was in the
56 # apitest.py example... --danny
62 # really quick hack to get character list. doesn't handle errors well, and
63 # if it can't get the gconf settings it just returns the placeholders, when
64 # in reality it should tell the UI or something. basically half finished,
65 # just uploading to show ry... FIXME --danny
66 def get_characters( self ):
68 # error message --danny
69 placeholder_chars = [("Please check your API settings.", "imgs/error.jpg")]
72 api_char_list = self.auth.account.Characters()
73 # append each char we get to the list we'll return to the UI --danny
74 for character in api_char_list.characters:
75 ui_char_list.append( ( character.name,
76 fetchimg.portrait_filename( character.characterID, 64 ) ) )
78 # if not entered into gconf, error message --danny
79 except eveapi.Error, e:
80 return placeholder_chars
82 if __name__ == "__main__":