src/Resources.vala
[app.Builder.js] / src / Resources.vala
1 /**
2  * Resources
3  * 
4  * Idea is to manage resourse used by the app.
5  * 
6  * The original code downloaded all the resources before it renders the main window
7  * 
8  * This is a bit annoying as although they do change quite a bit, it's not on every page load
9  * 
10  * So the Resource fetching behaviour should be a button on the File view page
11  * That starts the refresh of the resources.
12  * 
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...
15 */
16
17 public class Resources : Object
18 {
19
20 public void fetchResourceFrom(string src, string target, Soup.SessionCallback? callback)) 
21 {
22                  
23                 // fetch...
24                 print("downloading %s \nto : %s\n", src,res);
25                 var session = new Soup.Session ();
26                 session.user_agent = "App Builder ";
27                 var message = new Soup.Message ("GET", 
28                         src
29                     );
30 session.queue_message (message, (sess, mess) => {
31     stdout.printf ("Message length: %lld\n%s\n",
32                    mess.response_body.length,
33                    mess.response_body.data);
34 });
35                     // send the HTTP request and wait for response
36  
37
38                     // output the XML result to stdout
39                 FileUtils.set_contents(
40                        configDirectory() + "/resources/" + res,
41                       (string) message.response_body.data
42                     );
43
44
45         }