annotate nodejs/examples/mce/epg.js @ 1083:555d89e704c0 openvg

Check if the pattern is NULL for free it for a radial paint
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 03 Dec 2010 08:49:00 +0800
parents eb3719020866
children 3d438daea48c
rev   line source
932
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
2 // vim: sw=4:ts=8:sts=4
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
3 var http = require('http');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
4 var URL = require('url');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
5 var sys = require("sys");
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
6 var fs = require("fs");
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
7 var os = require("child_process");
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
8 function EPG()
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
9 {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
10 var epgsrv = http.createClient(8080, '211.23.50.144');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
11 var cmd = '{"Protocol":"EPG-CSP","Command":"SearchRequest","ProgramCat":"MainCat"}';
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
12 var headers={
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
13 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
14 'Host':'211.23.50.144:8080',
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
15 'User-Agent':'MadButterfly',
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
16 'Content-Type':'application/x-www-form-urlencoded'
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
17 };
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
18 headers['Content-Length'] = cmd.length;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
19 var request = epgsrv.request('POST', '/IPTV_EPG/EPGService.do?timestamp='+new Date().getTime(),headers);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
20 var self = this;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
21 sys.puts("aaaa");
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
22 var js = '';
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
23 request.write(cmd);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
24 request.end();
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
25 request.on('response', function(res) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
26 sys.puts("connected");
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
27 res.on('data',function (data) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
28 js = js + data;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
29 });
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
30 res.on('end', function () {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
31 res = JSON.parse(js);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
32 sys.puts("parsed");
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
33 self.onLoad(res);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
34
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
35 });
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
36 });
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
37 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
38
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
39
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
40 /**
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
41 * Check if the file has been cached. Create a symbolic to link if it is cached already.
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
42 *
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
43 */
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
44 function isCached(cachepath,file,obj) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
45 var fields = cachepath.split('.');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
46 try {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
47 var ext = fields.pop();
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
48 var pngfile = cachepath;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
49 sys.puts("ext="+ext);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
50 if (ext != 'png') {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
51 fields.push('png');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
52 pngfile = fields.join('.');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
53 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
54 var st = fs.statSync(pngfile);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
55 try {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
56 fs.unlinkSync(file);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
57 } catch(e) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
58 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
59 fs.linkSync(pngfile, file);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
60 obj.pend = obj.pend - 1;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
61 if (obj.pend == 0) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
62 obj.onInitDone();
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
63 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
64 return 1;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
65 } catch(e) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
66 sys.puts(e);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
67 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
68 return 0;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
69 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
70
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
71 /**
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
72 * Implement the mkdir -p to create the directory
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
73 */
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
74 function CreateDirectory(cachepath)
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
75 {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
76 var fields = cachepath.split('/');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
77 var p='';
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
78 for(i=0;i<fields.length-1;i++) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
79 p = p + fields[i]+'/';
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
80 try {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
81 fs.mkdirSync(p,0777);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
82 } catch(e) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
83 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
84 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
85 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
86 /*
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
87 * We will check the cache directory. If the file is available, we will create a symbolic link only. Otherwise,
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
88 * we will fetch it before create the symbolic link.
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
89 */
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
90 function httpGetFile(url,file,obj)
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
91 {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
92 sys.puts("fetch "+ file);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
93 var u = URL.parse(url);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
94 var cachepath = 'cache/'+u.pathname;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
95 if (isCached(cachepath,file,obj)) return;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
96 CreateDirectory(cachepath);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
97
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
98 // Fetch file from the server and convert it tyo PNG if it is not PNG format.
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
99 var f = fs.openSync(cachepath,'w');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
100 sys.puts("f="+f);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
101 var headers={
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
102 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
103 'Host':'211.23.50.144:8080',
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
104 'User-Agent':'MadButterfly',
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
105 'Content-Type':'application/x-www-form-urlencoded'
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
106 };
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
107 sys.puts("host="+u.host+' '+u.port+' '+u.pathname);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
108 for(k in u) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
109 sys.puts(k+"--->"+u[k]);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
110 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
111 var c = http.createClient(8080,'211.23.50.144');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
112 var req = c.request('GET',u.pathname,headers);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
113 req.end();
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
114 req.on('response', function(res) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
115 res.on('data',function(data) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
116 fs.writeSync(f,data,0,data.length);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
117 });
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
118 res.on('end',function() {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
119 fs.close(f);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
120 var fields = cachepath.split('.');
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
121 var ext = fields.pop();
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
122 if (ext != "png") {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
123 fields.push("png");
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
124 newf = fields.join(".");
1035
18329b6f77a4 Generate the PNG fropm the JPG file. We need to add the JPG/GIF graphics format
wycc
parents: 932
diff changeset
125 sys.puts("cachepath="+cachepath+" newf="+newf);
18329b6f77a4 Generate the PNG fropm the JPG file. We need to add the JPG/GIF graphics format
wycc
parents: 932
diff changeset
126 os.spawn("convert",[cachepath,newf]);
932
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
127 } else {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
128 newf = cachepath;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
129 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
130 try {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
131 fs.unlinkSync(file);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
132 } catch(e) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
133 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
134 sys.puts("end of "+cachepath+" to "+file);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
135 fs.symlinkSync(newf, file);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
136 obj.pend = obj.pend - 1;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
137 if (obj.pend == 0) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
138 obj.onInitDone();
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
139 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
140
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
141 });
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
142
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
143 });
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
144 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
145
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
146 EPG.prototype.onLoad = function(res) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
147 cats = res['ProgramCat'];
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
148 this.pend = cats.length;
1065
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
149 this.maincat = cats;
932
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
150 for (i in cats) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
151 c = cats[i];
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
152 httpGetFile(c['ProgramPIC'],'cat'+i+'.png',this);
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
153 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
154 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
155
1065
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
156 EPG.prototype.getList=function(item,func) {
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
157 var epgsrv = http.createClient(8080, '211.23.50.144');
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
158 var cmd = '{"Protocol":"EPG-CSP","Command":"SearchRequest","ProgramSub":"'+item.Category+'"}';
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
159 var headers={
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
160 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
161 'Host':'211.23.50.144:8080',
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
162 'User-Agent':'MadButterfly',
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
163 'Content-Type':'application/x-www-form-urlencoded'
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
164 };
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
165 headers['Content-Length'] = cmd.length;
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
166 var request = epgsrv.request('POST', '/IPTV_EPG/EPGService.do?timestamp='+new Date().getTime(),headers);
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
167 var self = this;
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
168 sys.puts("aaaa");
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
169 var js = '';
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
170 request.write(cmd);
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
171 request.end();
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
172 request.on('response', function(res) {
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
173 sys.puts("connected");
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
174 res.on('data',function (data) {
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
175 js = js + data;
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
176 });
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
177 res.on('end', function () {
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
178 res = JSON.parse(js);
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
179 sys.puts("parsed");
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
180 func();
932
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
181
1065
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
182 });
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
183 });
eb3719020866 Add support for the second level page.
wycc
parents: 1035
diff changeset
184 }
932
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
185 EPG.prototype.onInitDone=function() {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
186 if (this.loadCallback)
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
187 this.loadCallback();
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
188 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
189
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
190 EPG.prototype.registerInitDone=function(cb) {
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
191 this.loadCallback = cb;
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
192 }
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
193
bd9b0142fc7e Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff changeset
194 exports.EPG = EPG;