1 | //#ifndef INSTAR_H |
---|
2 | //#define INSTAR_H |
---|
3 | |
---|
4 | char* cam1 = NULL; |
---|
5 | char* cam2 = NULL; |
---|
6 | struct skin* instar_screen = NULL; |
---|
7 | int actcam = 1; |
---|
8 | |
---|
9 | struct clist *myconfig[LISTHASHSIZE] = {NULL}; |
---|
10 | char* instarconf = NULL; |
---|
11 | |
---|
12 | int show_control() |
---|
13 | { |
---|
14 | char* tmpstr = NULL; |
---|
15 | char* tempcam = NULL; |
---|
16 | char* position = NULL; |
---|
17 | char* positionstop = NULL; |
---|
18 | int rcret = 0; |
---|
19 | int rcode = 0; |
---|
20 | int ohnestop = 0; |
---|
21 | |
---|
22 | if(actcam == 1) |
---|
23 | tempcam = cam1; |
---|
24 | if(actcam == 2) |
---|
25 | tempcam = cam2; |
---|
26 | |
---|
27 | setfbtransparent(255); |
---|
28 | |
---|
29 | while(1) |
---|
30 | { |
---|
31 | if(cam1 != NULL) |
---|
32 | { |
---|
33 | tmpstr = ostrcat(cam1, "/snapshot.cgi", 0, 0); |
---|
34 | system(tmpstr); |
---|
35 | free(tmpstr); tmpstr = NULL; |
---|
36 | } |
---|
37 | if(cam2 != NULL) |
---|
38 | { |
---|
39 | tmpstr = ostrcat(cam2, "/snapshot.cgi", 0, 0); |
---|
40 | system(tmpstr); |
---|
41 | free(tmpstr); tmpstr = NULL; |
---|
42 | } |
---|
43 | |
---|
44 | drawscreen(instar_screen, 0, 0); |
---|
45 | rcret = waitrc(instar_screen, 100, 0); |
---|
46 | ohnestop = 0; |
---|
47 | |
---|
48 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
49 | |
---|
50 | if(rcret == getrcconfigint("rcinfo", NULL)) |
---|
51 | { |
---|
52 | //addlist(myconfig, "InstarCamAutostart", "nein"); |
---|
53 | rcode = 1; |
---|
54 | break; |
---|
55 | } |
---|
56 | |
---|
57 | if(rcret == getrcconfigint("rc1", NULL)) { |
---|
58 | position = ostrcat("/decoder_control.cgi?command=", "31", 0 , 0); |
---|
59 | ohnestop = 1; |
---|
60 | } |
---|
61 | if(rcret == getrcconfigint("rc2", NULL)) { |
---|
62 | position = ostrcat("/decoder_control.cgi?command=", "33", 0 , 0); |
---|
63 | ohnestop = 1; |
---|
64 | } |
---|
65 | if(rcret == getrcconfigint("rc3", NULL)) { |
---|
66 | position = ostrcat("/decoder_control.cgi?command=", "35", 0 , 0); |
---|
67 | ohnestop = 1; |
---|
68 | } |
---|
69 | if(rcret == getrcconfigint("rc4", NULL)) { |
---|
70 | position = ostrcat("/decoder_control.cgi?command=", "37", 0 , 0); |
---|
71 | ohnestop = 1; |
---|
72 | } |
---|
73 | if(rcret == getrcconfigint("rc5", NULL)) { |
---|
74 | position = ostrcat("/decoder_control.cgi?command=", "39", 0 , 0); |
---|
75 | ohnestop = 1; |
---|
76 | } |
---|
77 | if(rcret == getrcconfigint("rc6", NULL)) { |
---|
78 | position = ostrcat("/decoder_control.cgi?command=", "41", 0 , 0); |
---|
79 | ohnestop = 1; |
---|
80 | } |
---|
81 | if(rcret == getrcconfigint("rc7", NULL)) { |
---|
82 | position = ostrcat("/decoder_control.cgi?command=", "43", 0 , 0); |
---|
83 | ohnestop = 1; |
---|
84 | } |
---|
85 | if(rcret == getrcconfigint("rc8", NULL)) { |
---|
86 | position = ostrcat("/decoder_control.cgi?command=", "45", 0 , 0); |
---|
87 | ohnestop = 1; |
---|
88 | } |
---|
89 | if(rcret == getrcconfigint("rc9", NULL)) { |
---|
90 | position = ostrcat("/decoder_control.cgi?command=", "47", 0 , 0); |
---|
91 | ohnestop = 1; |
---|
92 | } |
---|
93 | if(positionstop == NULL) |
---|
94 | { |
---|
95 | if(rcret == getrcconfigint("rcup", NULL)) { |
---|
96 | position = ostrcat("/decoder_control.cgi?command=", "0", 0 , 0); |
---|
97 | positionstop = ostrcat("/decoder_control.cgi?command=", "1", 0 , 0); |
---|
98 | } |
---|
99 | if(rcret == getrcconfigint("rcdown", NULL)) { |
---|
100 | position = ostrcat("/decoder_control.cgi?command=", "2", 0 , 0); |
---|
101 | positionstop = ostrcat("/decoder_control.cgi?command=", "3", 0 , 0); |
---|
102 | } |
---|
103 | if(rcret == getrcconfigint("rcleft", NULL)) { |
---|
104 | position = ostrcat("/decoder_control.cgi?command=", "4", 0 , 0); |
---|
105 | positionstop = ostrcat("/decoder_control.cgi?command=", "5", 0 , 0); |
---|
106 | } |
---|
107 | if(rcret == getrcconfigint("rcright", NULL)) { |
---|
108 | position = ostrcat("/decoder_control.cgi?command=", "6", 0 , 0); |
---|
109 | positionstop = ostrcat("/decoder_control.cgi?command=", "7", 0 , 0); |
---|
110 | } |
---|
111 | if(rcret == getrcconfigint("rcchup", NULL)) { |
---|
112 | position = ostrcat("/decoder_control.cgi?command=", "16", 0 , 0); |
---|
113 | positionstop = ostrcat("/decoder_control.cgi?command=", "17", 0 , 0); |
---|
114 | } |
---|
115 | if(rcret == getrcconfigint("rcchdown", NULL)) { |
---|
116 | position = ostrcat("/decoder_control.cgi?command=", "18", 0 , 0); |
---|
117 | positionstop = ostrcat("/decoder_control.cgi?command=", "19", 0 , 0); |
---|
118 | } |
---|
119 | } |
---|
120 | |
---|
121 | if(tempcam != NULL && rcret != RCTIMEOUT) |
---|
122 | { |
---|
123 | if(positionstop != NULL && ohnestop == 1) |
---|
124 | { |
---|
125 | tmpstr = ostrcat(tempcam, positionstop, 0, 0); |
---|
126 | system(tmpstr); |
---|
127 | free(tmpstr); tmpstr = NULL; |
---|
128 | free(positionstop); positionstop = NULL; |
---|
129 | } |
---|
130 | if(position != NULL) |
---|
131 | { |
---|
132 | tmpstr = ostrcat(tempcam, position, 0, 0); |
---|
133 | system(tmpstr); |
---|
134 | free(tmpstr); tmpstr = NULL; |
---|
135 | free(position); position = NULL; |
---|
136 | } |
---|
137 | else if(positionstop != NULL) |
---|
138 | { |
---|
139 | tmpstr = ostrcat(tempcam, positionstop, 0, 0); |
---|
140 | system(tmpstr); |
---|
141 | free(tmpstr); tmpstr = NULL; |
---|
142 | free(positionstop); positionstop = NULL; |
---|
143 | } |
---|
144 | } |
---|
145 | } |
---|
146 | |
---|
147 | clearscreen(instar_screen); |
---|
148 | setosdtransparent(getskinconfigint("osdtransparent", NULL)); |
---|
149 | return rcode; |
---|
150 | } |
---|
151 | |
---|
152 | int instar_settings() |
---|
153 | { |
---|
154 | |
---|
155 | int rcret = 0; |
---|
156 | int rcode = 0; |
---|
157 | |
---|
158 | struct skin* instar_einstellungen = getscreen("instar_einstellungen"); |
---|
159 | struct skin* listbox = getscreennode(instar_einstellungen, "listbox"); |
---|
160 | struct skin* autoCam = getscreennode(instar_einstellungen, "autoCam"); |
---|
161 | struct skin* onCam1 = getscreennode(instar_einstellungen, "onCam1"); |
---|
162 | struct skin* ipCam1 = getscreennode(instar_einstellungen, "ipCam1"); |
---|
163 | struct skin* portCam1 = getscreennode(instar_einstellungen, "portCam1"); |
---|
164 | struct skin* userCam1 = getscreennode(instar_einstellungen, "userCam1"); |
---|
165 | struct skin* passCam1 = getscreennode(instar_einstellungen, "passCam1"); |
---|
166 | struct skin* onCam2 = getscreennode(instar_einstellungen, "onCam2"); |
---|
167 | struct skin* ipCam2 = getscreennode(instar_einstellungen, "ipCam2"); |
---|
168 | struct skin* portCam2 = getscreennode(instar_einstellungen, "portCam2"); |
---|
169 | struct skin* userCam2 = getscreennode(instar_einstellungen, "userCam2"); |
---|
170 | struct skin* passCam2 = getscreennode(instar_einstellungen, "passCam2"); |
---|
171 | |
---|
172 | struct skin* tmp = NULL; |
---|
173 | |
---|
174 | addchoicebox(autoCam, "nein", _("nein")); |
---|
175 | addchoicebox(autoCam, "ja", _("ja")); |
---|
176 | setchoiceboxselection(autoCam, getlist(myconfig, "InstarCamAutostart", NULL)); |
---|
177 | |
---|
178 | addchoicebox(onCam1, "aus", _("aus")); |
---|
179 | addchoicebox(onCam1, "ein", _("ein")); |
---|
180 | setchoiceboxselection(onCam1, getlist(myconfig, "InstarCam1", NULL)); |
---|
181 | changemask(ipCam1, "abcdefghijklmnopqrstuvwxyz"); |
---|
182 | changeinput(ipCam1, getlist(myconfig, "InstarCam1IP", NULL)); |
---|
183 | changemask(portCam1, "0000"); |
---|
184 | changeinput(portCam1, getlist(myconfig, "InstarCam1Port", NULL)); |
---|
185 | changemask(userCam1, "abcdefghijklmnopqrstuvwxyz"); |
---|
186 | changeinput(userCam1, getlist(myconfig, "InstarCam1User", NULL)); |
---|
187 | changemask(passCam1, "abcdefghijklmnopqrstuvwxyz"); |
---|
188 | changeinput(passCam1, getlist(myconfig, "InstarCam1Pass", NULL)); |
---|
189 | |
---|
190 | addchoicebox(onCam2, "aus", _("aus")); |
---|
191 | addchoicebox(onCam2, "ein", _("ein")); |
---|
192 | setchoiceboxselection(onCam2, getlist(myconfig, "InstarCam2", NULL)); |
---|
193 | changemask(ipCam2, "abcdefghijklmnopqrstuvwxyz"); |
---|
194 | changeinput(ipCam2, getlist(myconfig, "InstarCam2IP", NULL)); |
---|
195 | changemask(portCam2, "0000"); |
---|
196 | changeinput(portCam2, getlist(myconfig, "InstarCam2Port", NULL)); |
---|
197 | changemask(userCam2, "abcdefghijklmnopqrstuvwxyz"); |
---|
198 | changeinput(userCam2, getlist(myconfig, "InstarCam2User", NULL)); |
---|
199 | changemask(passCam2, "abcdefghijklmnopqrstuvwxyz"); |
---|
200 | changeinput(passCam2, getlist(myconfig, "InstarCam2Pass", NULL)); |
---|
201 | |
---|
202 | drawscreen(instar_einstellungen, 0, 0); |
---|
203 | addscreenrc(instar_einstellungen, listbox); |
---|
204 | tmp = listbox->select; |
---|
205 | |
---|
206 | while(1) |
---|
207 | { |
---|
208 | addscreenrc(instar_einstellungen, tmp); |
---|
209 | rcret = waitrc(instar_einstellungen, 1000, 0); |
---|
210 | tmp = listbox->select; |
---|
211 | |
---|
212 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
213 | if(rcret == getrcconfigint("rcgreen", NULL) || rcret == getrcconfigint("rcblue", NULL)) |
---|
214 | { |
---|
215 | addlist(myconfig, "InstarCamAutostart", autoCam->ret); |
---|
216 | addlist(myconfig, "InstarCam1", onCam1->ret); |
---|
217 | addlist(myconfig, "InstarCam1IP", ipCam1->ret); |
---|
218 | addlist(myconfig, "InstarCam1Port", portCam1->ret); |
---|
219 | addlist(myconfig, "InstarCam1User", userCam1->ret); |
---|
220 | addlist(myconfig, "InstarCam1Pass", passCam1->ret); |
---|
221 | addlist(myconfig, "InstarCam2", onCam2->ret); |
---|
222 | addlist(myconfig, "InstarCam2IP", ipCam2->ret); |
---|
223 | addlist(myconfig, "InstarCam2Port", portCam2->ret); |
---|
224 | addlist(myconfig, "InstarCam2User", userCam2->ret); |
---|
225 | addlist(myconfig, "InstarCam2Pass", passCam2->ret); |
---|
226 | writelist(myconfig, instarconf); |
---|
227 | if(rcret == getrcconfigint("rcblue", NULL)) |
---|
228 | { |
---|
229 | rcode = 1; |
---|
230 | break; |
---|
231 | } |
---|
232 | } |
---|
233 | } |
---|
234 | delownerrc(instar_einstellungen); |
---|
235 | clearscreen(instar_einstellungen); |
---|
236 | return rcode; |
---|
237 | } |
---|
238 | |
---|
239 | |
---|
240 | |
---|
241 | void instar_main() |
---|
242 | { |
---|
243 | int rcode = 0; |
---|
244 | |
---|
245 | instarconf = ostrcat(getconfig("pluginpath", NULL), "/instar/instar.conf", 0, 0); |
---|
246 | readconfig(instarconf, myconfig); |
---|
247 | |
---|
248 | if(ostrcmp(getlist(myconfig, "InstarCamAutostart", NULL), "ja") == 0) |
---|
249 | rcode = 1; |
---|
250 | else |
---|
251 | rcode = instar_settings(); |
---|
252 | |
---|
253 | if(rcode == 1) |
---|
254 | { |
---|
255 | while(1) |
---|
256 | { |
---|
257 | if(ostrcmp(getlist(myconfig, "InstarCam1", NULL), "ein") == 0) |
---|
258 | { |
---|
259 | cam1 = ostrcat("wget --output-document=/tmp/instar1.jpg http://", getlist(myconfig, "InstarCam1User", NULL), 0, 0); |
---|
260 | cam1 = ostrcat(cam1, ":",1, 0); |
---|
261 | cam1 = ostrcat(cam1, getlist(myconfig, "InstarCam1Pass", NULL), 1, 0); |
---|
262 | cam1 = ostrcat(cam1, "@",1, 0); |
---|
263 | cam1 = ostrcat(cam1, getlist(myconfig, "InstarCam1IP", NULL), 1, 0); |
---|
264 | cam1 = ostrcat(cam1, ":",1, 0); |
---|
265 | cam1 = ostrcat(cam1, getlist(myconfig, "InstarCam1Port", NULL), 1, 0); |
---|
266 | } |
---|
267 | |
---|
268 | |
---|
269 | /* |
---|
270 | if(ostrcmp(getlist(myconfig, "InstarCam2", NULL), "ein") == 0) |
---|
271 | { |
---|
272 | cam2 = ostrcat("wget --output-document=/tmp/instar2.jpg http://", getlist(myconfig, "InstarCam2User", NULL), 0, 0); |
---|
273 | cam2 = ostrcat(cam2, ":",1, 0); |
---|
274 | cam2 = ostrcat(cam2, getlist(myconfig, "InstarCam2Pass", NULL), 1, 0); |
---|
275 | cam2 = ostrcat(cam2, "@",1, 0); |
---|
276 | cam2 = ostrcat(cam2, getlist(myconfig, "InstarCam2IP", NULL), 1, 0); |
---|
277 | cam2 = ostrcat(cam2, ":",1, 0); |
---|
278 | cam2 = ostrcat(cam2, getlist(myconfig, "InstarCam2Port", NULL), 1, 0); |
---|
279 | } |
---|
280 | */ |
---|
281 | |
---|
282 | instar_screen = getscreen("instar_full"); |
---|
283 | |
---|
284 | actcam = 1; |
---|
285 | |
---|
286 | rcode = show_control(); |
---|
287 | |
---|
288 | free(cam1), cam1 = NULL; |
---|
289 | free(cam2), cam2 = NULL; |
---|
290 | |
---|
291 | if(rcode == 0) |
---|
292 | break; |
---|
293 | rcode = 0; |
---|
294 | |
---|
295 | rcode = instar_settings(); |
---|
296 | if(rcode == 0) |
---|
297 | break; |
---|
298 | } |
---|
299 | } |
---|
300 | writelist(myconfig, instarconf); |
---|
301 | freelist(myconfig); |
---|
302 | free(instarconf); instarconf = NULL; |
---|
303 | } |
---|