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;
31 this.updateProgress(cur);
33 case 0: // html for rendering Bootstrap apps.
34 this.fetchResourceFrom (
35 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/bootstrap.builder.html",
36 "bootstrap.builder.html",
42 this.fetchResourceFrom (
43 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/roo.builder.html",
49 case 2: // generic javascript
50 this.fetchResourceFrom (
51 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/roo.builder.js",
58 case 3: // Gir overrides - used to handle the fact we are not querying valadoc yet....and gir does
59 // not map that well to vala...
60 this.fetchResourceFrom (
61 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/Gir.overides",
69 case 3: // The main - what goes into what element structure..
70 this.fetchResourceFrom (
71 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/GtkUsage.txt",
78 case 3: // The main - what goes into what element structure..
79 this.fetchResourceFrom (
80 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/GtkUsage.txt",
93 "bootstrap.builder.html",
100 for (var i = 0; i < res.length; i++ ) {
101 this.fetchResource(res[i], force);
104 this.fetchResourceFrom (
105 "http://git.roojs.org/?p=roojs1;a=blob_plain;f=docs/json/roodata.json",
112 public void fetchResource(string res, bool force) {
113 if (!force && FileUtils.test(configDirectory() + "/resources/" + res, FileTest.EXISTS)) {
116 this.fetchResourceFrom(
117 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/" + res,
125 public void fetchResourceFrom(string src, string target, Soup.SessionCallback? callback)
129 print("downloading %s \nto : %s\n", src,res);
130 var session = new Soup.Session ();
131 session.user_agent = "App Builder ";
132 var message = new Soup.Message ("GET", src );
133 session.queue_message (message, (sess, mess) => {
135 FileUtils.set_contents(
136 Application.configDirectory() + "/resources/" + res,
137 (string) message.response_body.data