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)
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 def eveapi_connect(self):
44 api_key = self.get_api_key()
45 cached_api = eveapi.EVEAPIConnection( cacheHandler = apicache.cache_handler( debug = False ) )
48 auth = cached_api.auth( userID = uid, apiKey = api_key )
49 except eveapi.Error, e:
50 # if we can't, return the error message/pic --danny
53 # unknown exception, dunno if this needs to be here if I just
54 # ignore it... probably a bad idea, but it was in the
55 # apitest.py example... --danny
60 def get_alliances(self, charID):
61 auth = eveapi_connect()
64 alliance_list = auth.character(charID)
70 # really quick hack to get character list. doesn't handle errors well, and
71 # if it can't get the gconf settings it just returns the placeholders, when
72 # in reality it should tell the UI or something. basically half finished,
73 # just uploading to show ry... FIXME --danny
74 def get_characters( self ):
76 # error message --danny
77 placeholder_chars = [("Please check your API settings.", "imgs/error.jpg")]
79 auth = self.eveapi_connect()
82 api_char_list = auth.account.Characters()
83 # append each char we get to the list we'll return to the UI --danny
84 for character in api_char_list.characters:
85 ui_char_list.append( ( character.name,
86 fetchimg.portrait_filename( character.characterID, 64 ) ) )
88 # if not entered into gconf, error message --danny
89 except eveapi.Error, e:
90 return placeholder_chars
92 if __name__ == "__main__":