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