4 * Idea is to manage resourse used by the app.
6 * The original code downloaded all the resources before it renders the main window
8 * This is a bit annoying as although they do change quite a bit, it's not on every page load
10 * So the Resource fetching behaviour should be a button on the File view page
11 * That starts the refresh of the resources.
13 * I'm not quite sure how we should flow this - if we do them all at once.. might be a bit of a server
14 * overload... so sequentially may be best...
17 public class Resources : Object
21 public void fetchStart()
27 public void fetchNext()
29 var cur = this.fetch_pos;
32 case 0: // html for rendering Bootstrap apps.
33 this.fetchResourceFrom (
34 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/bootstrap.builder.html",
35 "bootstrap.builder.html",
41 this.fetchResourceFrom (
42 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/roo.builder.html",
48 this.fetchResourceFrom (
49 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/roo.builder.html",
61 "bootstrap.builder.html",
68 for (var i = 0; i < res.length; i++ ) {
69 this.fetchResource(res[i], force);
72 this.fetchResourceFrom (
73 "http://git.roojs.org/?p=roojs1;a=blob_plain;f=docs/json/roodata.json",
80 public void fetchResource(string res, bool force) {
81 if (!force && FileUtils.test(configDirectory() + "/resources/" + res, FileTest.EXISTS)) {
84 this.fetchResourceFrom(
85 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/" + res,
93 public void fetchResourceFrom(string src, string target, Soup.SessionCallback? callback)
97 print("downloading %s \nto : %s\n", src,res);
98 var session = new Soup.Session ();
99 session.user_agent = "App Builder ";
100 var message = new Soup.Message ("GET", src );
101 session.queue_message (message, (sess, mess) => {
103 FileUtils.set_contents(
104 Application.configDirectory() + "/resources/" + res,
105 (string) message.response_body.data