source: titan/plugins/instar/instar.h @ 26912

Last change on this file since 26912 was 24056, checked in by nit, 10 years ago

[titan] add new plugindir system

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