mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
Add GAM menu token handling
This adds the tokens for app submenus. I am now successfully able to load `vault'!
This commit is contained in:
parent
7532a34769
commit
5186a723f5
2 changed files with 18 additions and 9 deletions
|
|
@ -14,7 +14,7 @@ pub(crate) struct AppLoader {
|
||||||
load_menu: MenuMatic,
|
load_menu: MenuMatic,
|
||||||
conn: xous::CID,
|
conn: xous::CID,
|
||||||
apps: Vec<xous_ipc::String<64>>,
|
apps: Vec<xous_ipc::String<64>>,
|
||||||
possible_apps: Vec<xous_ipc::String<64>>,
|
possible_apps: Vec<(xous_ipc::String<64>, usize)>,
|
||||||
server: Option<String>,
|
server: Option<String>,
|
||||||
current_menu: String,
|
current_menu: String,
|
||||||
}
|
}
|
||||||
|
|
@ -63,7 +63,7 @@ impl AppLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn add_app(&mut self, index: usize) {
|
pub(crate) fn add_app(&mut self, index: usize) {
|
||||||
let name = self.possible_apps[index];
|
let (name, menus) = self.possible_apps[index];
|
||||||
|
|
||||||
self.modals.start_progress(t!("apploader.addapp.loading", locales::LANG), 0, 3, 0).expect("Couldn't set up progress bar");
|
self.modals.start_progress(t!("apploader.addapp.loading", locales::LANG), 0, 3, 0).expect("Couldn't set up progress bar");
|
||||||
|
|
||||||
|
|
@ -130,6 +130,9 @@ impl AppLoader {
|
||||||
|
|
||||||
// add its name to GAM
|
// add its name to GAM
|
||||||
self.gam.register_name(name.to_str(), self.auth).expect("Couldn't register name");
|
self.gam.register_name(name.to_str(), self.auth).expect("Couldn't register name");
|
||||||
|
for menu in 0..menus {
|
||||||
|
self.gam.register_name(&format!("{} Submenu {}", name, menu), self.auth).expect("Couldn't register name");
|
||||||
|
}
|
||||||
|
|
||||||
// add it to the menu
|
// add it to the menu
|
||||||
self.menu.insert_item(MenuItem { name,
|
self.menu.insert_item(MenuItem { name,
|
||||||
|
|
@ -191,7 +194,7 @@ impl AppLoader {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.into_json::<Vec<String>>()
|
.into_json::<Vec<(String, usize)>>()
|
||||||
{
|
{
|
||||||
Ok(json) => { self.modals.update_progress(2).expect("Couldn't update progress"); json },
|
Ok(json) => { self.modals.update_progress(2).expect("Couldn't update progress"); json },
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
@ -200,14 +203,14 @@ impl AppLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.iter()
|
.iter()
|
||||||
.map(|s| xous_ipc::String::<64>::from_str(&s))
|
.map(|(name, menus)| (xous_ipc::String::<64>::from_str(&name), *menus))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
for old_name in old {
|
for (old_name, _) in old {
|
||||||
self.load_menu.delete_item(old_name.as_str().unwrap());
|
self.load_menu.delete_item(old_name.as_str().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i, app) in self.possible_apps.iter().enumerate() {
|
for (i, (app, _)) in self.possible_apps.iter().enumerate() {
|
||||||
self.load_menu.insert_item(MenuItem { name: xous_ipc::String::from_str(app.to_str()),
|
self.load_menu.insert_item(MenuItem { name: xous_ipc::String::from_str(app.to_str()),
|
||||||
action_conn: Some(self.conn),
|
action_conn: Some(self.conn),
|
||||||
action_opcode: Opcode::AddApp.to_u32().unwrap(),
|
action_opcode: Opcode::AddApp.to_u32().unwrap(),
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,11 @@ from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
from urllib.parse import unquote
|
from urllib.parse import unquote
|
||||||
|
|
||||||
class XousAppServer(BaseHTTPRequestHandler):
|
class XousAppServer(BaseHTTPRequestHandler):
|
||||||
def __init__(self, profile, target, context_to_app, *args):
|
def __init__(self, profile, target, context_to_app, context_to_menus, *args):
|
||||||
self.profile = profile
|
self.profile = profile
|
||||||
self.target = target
|
self.target = target
|
||||||
self.context_to_app = context_to_app
|
self.context_to_app = context_to_app
|
||||||
|
self.context_to_menus = context_to_menus
|
||||||
BaseHTTPRequestHandler.__init__(self, *args)
|
BaseHTTPRequestHandler.__init__(self, *args)
|
||||||
|
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
|
|
@ -20,7 +21,7 @@ class XousAppServer(BaseHTTPRequestHandler):
|
||||||
self.send_header('Content-Type', 'application/json')
|
self.send_header('Content-Type', 'application/json')
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
|
||||||
l = json.dumps(list(self.context_to_app.keys()))
|
l = json.dumps(list(self.context_to_menus.items()))
|
||||||
|
|
||||||
self.wfile.write(l.encode())
|
self.wfile.write(l.encode())
|
||||||
else:
|
else:
|
||||||
|
|
@ -52,12 +53,17 @@ def main():
|
||||||
manifest = json.loads(f.read())
|
manifest = json.loads(f.read())
|
||||||
|
|
||||||
context_to_app = {}
|
context_to_app = {}
|
||||||
|
context_to_menus = {}
|
||||||
|
|
||||||
for app in args.apps:
|
for app in args.apps:
|
||||||
context_name = manifest[app]['context_name']
|
context_name = manifest[app]['context_name']
|
||||||
context_to_app[context_name] = app
|
context_to_app[context_name] = app
|
||||||
|
if 'submenu' in manifest[app]:
|
||||||
|
context_to_menus[context_name] = manifest[app]['submenu']
|
||||||
|
else:
|
||||||
|
context_to_menus[context_name] = 0
|
||||||
|
|
||||||
server = HTTPServer(('0.0.0.0', args.port), lambda *server_args: XousAppServer(args.profile, args.target, context_to_app, *server_args))
|
server = HTTPServer(('0.0.0.0', args.port), lambda *server_args: XousAppServer(args.profile, args.target, context_to_app, context_to_menus, *server_args))
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue