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
32             FileUtils.set_contents(
33                configDirectory() + "/resources/" + res,
34                  (string) message.response_body.data
35             );
36                 
37             callback(sess,mess);
38         });
39                      
40
41         }