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

Last change on this file since 40938 was 40938, checked in by gost, 6 years ago

[pluins] ip-kamera fix typ 5... I hope

  • Property svn:executable set to *
File size: 15.3 KB
Line 
1//#ifndef INSTAR_H
2//#define INSTAR_H
3
4char* cam1 = NULL;
5char* cam2 = NULL;
6char* cam11 = NULL;
7char* cam21 = NULL;
8struct skin* instar_screen = NULL;
9struct skin* instar_pic1 = NULL;
10struct skin* instar_actcam1 = NULL;
11int actcam = 1;
12
13struct clist *myconfig[LISTHASHSIZE] = {NULL};
14char* instarconf = NULL;
15
16int show_control()
17{
18        char* tmpstr = NULL;
19        char* tempcam = NULL;
20        char* position = NULL;
21        char* positionstop = NULL;
22        int rcret = 0;
23        int rcode = 0;
24        int ohnestop = 0;
25       
26        if(actcam == 1)
27                tempcam = cam1;
28        if(actcam == 2)
29                tempcam = cam2;
30       
31        setfbtransparent(255);
32       
33        printf("[ip-cam] Aufruf1: %s\n", cam1);
34        printf("[ip-cam] Aufruf2: %s\n", cam2);
35       
36        while(1)
37        {
38                        if(cam1 != NULL)
39                        {
40                                if(getconfigint("instar_1", NULL) == 1)
41                                        tmpstr = ostrcat(cam1, "/image/jpeg.cgi", 0, 0);
42                                else if(getconfigint("instar_1", NULL) == 2)
43                                        tmpstr = ostrcat(cam1, "/tmpfs/auto.jpg", 0, 0);
44                                else if(getconfigint("instar_1", NULL) == 3)
45                                        tmpstr = ostrcat(cam1, "/onvif/GetSnapshotUri", 0, 0);
46                                else if(getconfigint("instar_1", NULL) == 4)
47                                        tmpstr = ostrcat(cam1, "/image", 0, 0);
48                                else if(getconfigint("instar_1", NULL) == 5)
49                                {
50                                        tmpstr = ostrcat(cam1, "/cgi-bin/CGIProxy.fcgi?cmd%3DsnapPicture2", 0, 0);
51                                        tmpstr = ostrcat(tmpstr, cam11, 1, 0);
52                                }
53                                else
54                                        tmpstr = ostrcat(cam1, "/snapshot.cgi", 0, 0);
55                                if(getconfigint("instar_alterwebif", NULL) == 1)
56                                        tmpstr = ostrcat(tmpstr, " > /tmp/instar1.jpg", 1, 0);
57                                system(tmpstr);
58                                printf("-> %s\n", tmpstr);
59                                free(tmpstr); tmpstr = NULL;
60                        }
61                        if(cam2 != NULL)
62                        {
63                                if(getconfigint("instar_2", NULL) == 1)
64                                        tmpstr = ostrcat(cam2, "/image/jpeg.cgi", 0, 0);
65                                else if(getconfigint("instar_2", NULL) == 2)
66                                        tmpstr = ostrcat(cam2, "/tmpfs/auto.jpg", 0, 0);
67                                else if(getconfigint("instar_2", NULL) == 3)
68                                        tmpstr = ostrcat(cam2, "/onvif/GetSnapshotUri", 0, 0);
69                                else if(getconfigint("instar_2", NULL) == 4)
70                                        tmpstr = ostrcat(cam2, "/image", 0, 0);
71                                else if(getconfigint("instar_2", NULL) == 5)
72                                {
73                                        tmpstr = ostrcat(cam2, "/cgi-bin/CGIProxy.fcgi?cmd%3DsnapPicture2", 0, 0);
74                                        tmpstr = ostrcat(tmpstr, cam21, 1, 0);
75                                }
76                                else
77                                        tmpstr = ostrcat(cam2, "/snapshot.cgi", 0, 0);
78                                if(getconfigint("instar_alterwebif", NULL) == 1)
79                                        tmpstr = ostrcat(tmpstr, " > /tmp/instar2.jpg", 1, 0);
80                                system(tmpstr);
81                                printf("-> %s\n", tmpstr);
82                                free(tmpstr); tmpstr = NULL;
83                        }
84                               
85                drawscreen(instar_screen, 0, 0);
86                rcret = waitrc(instar_screen, 100, 0);
87                ohnestop = 0;
88
89                if(rcret == getrcconfigint("rcexit", NULL)) break;
90               
91                if(rcret == getrcconfigint("rcinfo", NULL))
92                {
93                        //addlist(myconfig, "InstarCamAutostart", "nein");
94                        rcode = 1;
95                        break;
96                }       
97                       
98                if(rcret == getrcconfigint("rc1", NULL)) {
99                        position = ostrcat("/decoder_control.cgi?command=", "31", 0 , 0);
100                        ohnestop = 1;
101                }
102                if(rcret == getrcconfigint("rc2", NULL)) {
103                        position = ostrcat("/decoder_control.cgi?command=", "33", 0 , 0);
104                        ohnestop = 1;
105                }
106                if(rcret == getrcconfigint("rc3", NULL)) {
107                        position = ostrcat("/decoder_control.cgi?command=", "35", 0 , 0);
108                        ohnestop = 1;
109                }
110                if(rcret == getrcconfigint("rc4", NULL)) {
111                        position = ostrcat("/decoder_control.cgi?command=", "37", 0 , 0);
112                        ohnestop = 1;
113                }
114                if(rcret == getrcconfigint("rc5", NULL)) {
115                        position = ostrcat("/decoder_control.cgi?command=", "39", 0 , 0);
116                        ohnestop = 1;
117                }
118                if(rcret == getrcconfigint("rc6", NULL)) {
119                        position = ostrcat("/decoder_control.cgi?command=", "41", 0 , 0);
120                        ohnestop = 1;
121                }
122                if(rcret == getrcconfigint("rc7", NULL)) {
123                        position = ostrcat("/decoder_control.cgi?command=", "43", 0 , 0);
124                        ohnestop = 1;
125                }
126                if(rcret == getrcconfigint("rc8", NULL)) {
127                        position = ostrcat("/decoder_control.cgi?command=", "45", 0 , 0);
128                        ohnestop = 1;
129                }
130                if(rcret == getrcconfigint("rc9", NULL)) {
131                        position = ostrcat("/decoder_control.cgi?command=", "47", 0 , 0);
132                        ohnestop = 1;
133                }
134                if(positionstop == NULL)
135                {
136                        if(rcret == getrcconfigint("rcup", NULL)) {
137                                position = ostrcat("/decoder_control.cgi?command=", "0", 0 , 0);
138                                positionstop = ostrcat("/decoder_control.cgi?command=", "1", 0 , 0);
139                        }
140                        if(rcret == getrcconfigint("rcdown", NULL)) {
141                                position = ostrcat("/decoder_control.cgi?command=", "2", 0 , 0);
142                                positionstop = ostrcat("/decoder_control.cgi?command=", "3", 0 , 0);
143                        }
144                        if(rcret == getrcconfigint("rcleft", NULL)) {
145                                position = ostrcat("/decoder_control.cgi?command=", "4", 0 , 0);
146                                positionstop = ostrcat("/decoder_control.cgi?command=", "5", 0 , 0);
147                        }
148                        if(rcret == getrcconfigint("rcright", NULL)) {
149                                position = ostrcat("/decoder_control.cgi?command=", "6", 0 , 0);
150                                positionstop = ostrcat("/decoder_control.cgi?command=", "7", 0 , 0);
151                        }
152                        if(rcret == getrcconfigint("rcchup", NULL)) {
153                                position = ostrcat("/decoder_control.cgi?command=", "16", 0 , 0);
154                                positionstop = ostrcat("/decoder_control.cgi?command=", "17", 0 , 0);
155                        }
156                        if(rcret == getrcconfigint("rcchdown", NULL)) {
157                                position = ostrcat("/decoder_control.cgi?command=", "18", 0 , 0);
158                                positionstop = ostrcat("/decoder_control.cgi?command=", "19", 0 , 0);
159                        }
160                }
161               
162                if(tempcam != NULL && rcret != RCTIMEOUT)
163                {
164                        if(positionstop != NULL && ohnestop == 1)
165                        {
166                                tmpstr = ostrcat(tempcam, positionstop, 0, 0);
167                                system(tmpstr);
168                                free(tmpstr); tmpstr = NULL;   
169                                free(positionstop); positionstop = NULL;
170                        }
171                        if(position != NULL)
172                        {
173                                tmpstr = ostrcat(tempcam, position, 0, 0);
174                                system(tmpstr);
175                                free(tmpstr); tmpstr = NULL;   
176                                free(position); position = NULL;
177                        }
178                        else if(positionstop != NULL)
179                        {
180                                tmpstr = ostrcat(tempcam, positionstop, 0, 0);
181                                system(tmpstr);
182                                free(tmpstr); tmpstr = NULL;   
183                                free(positionstop); positionstop = NULL;
184                        }
185                        if(rcret == getrcconfigint("rcred", NULL)) {
186                                if(actcam == 1 && cam2 != NULL) {
187                                        actcam = 2;
188                                        changepic(instar_pic1, "/tmp/instar2.jpg");
189                                        changetext(instar_actcam1, "CAM2");
190                                        tempcam = cam2;
191                                        addlist(myconfig, "InstarActCam", "2");
192                                }
193                                else if(actcam == 2 && cam1 != NULL) {
194                                        actcam = 1;
195                                        changepic(instar_pic1, "/tmp/instar1.jpg");
196                                        changetext(instar_actcam1, "CAM1");
197                                        tempcam = cam1;
198                                        addlist(myconfig, "InstarActCam", "1");
199                                }
200                        }
201                }
202        }
203
204        clearscreen(instar_screen);
205        setosdtransparent(getskinconfigint("osdtransparent", NULL));
206        return rcode;
207}
208
209int instar_settings()
210{
211       
212        int rcret = 0;
213        int rcode = 0;
214       
215        struct skin* instar_einstellungen = getscreen("instar_einstellungen");
216        struct skin* listbox = getscreennode(instar_einstellungen, "listbox");
217        struct skin* alterwebif = getscreennode(instar_einstellungen, "alterwebif");
218        struct skin* autoCam = getscreennode(instar_einstellungen, "autoCam");
219        struct skin* onCam1 = getscreennode(instar_einstellungen, "onCam1");
220        struct skin* typCam1 = getscreennode(instar_einstellungen, "typCam1");
221        struct skin* ipCam1 = getscreennode(instar_einstellungen, "ipCam1");
222        struct skin* portCam1 = getscreennode(instar_einstellungen, "portCam1");
223        struct skin* userCam1 = getscreennode(instar_einstellungen, "userCam1");
224        struct skin* passCam1 = getscreennode(instar_einstellungen, "passCam1");
225        struct skin* onCam2 = getscreennode(instar_einstellungen, "onCam2");
226        struct skin* typCam2 = getscreennode(instar_einstellungen, "typCam2");
227        struct skin* ipCam2 = getscreennode(instar_einstellungen, "ipCam2");
228        struct skin* portCam2 = getscreennode(instar_einstellungen, "portCam2");
229        struct skin* userCam2 = getscreennode(instar_einstellungen, "userCam2");
230        struct skin* passCam2 = getscreennode(instar_einstellungen, "passCam2");
231       
232        struct skin* tmp = NULL;
233
234  addchoicebox(autoCam, "nein", _("nein"));
235        addchoicebox(autoCam, "ja", _("ja"));
236        setchoiceboxselection(autoCam, getlist(myconfig, "InstarCamAutostart", NULL));
237       
238        addchoicebox(alterwebif, "0", "off");
239        addchoicebox(alterwebif, "1", "on");
240        setchoiceboxselection(alterwebif, getconfig("instar_alterwebif", NULL));
241 
242  addchoicebox(onCam1, "aus", _("aus"));
243        addchoicebox(onCam1, "ein", _("ein"));
244        setchoiceboxselection(onCam1, getlist(myconfig, "InstarCam1", NULL));   
245        addchoicebox(typCam1, "0", "0");
246        addchoicebox(typCam1, "1", "1");
247        addchoicebox(typCam1, "2", "2");
248        addchoicebox(typCam1, "3", "3");
249        addchoicebox(typCam1, "4", "4");
250        addchoicebox(typCam1, "5", "5");
251        setchoiceboxselection(typCam1, getconfig("instar_1", NULL));
252        changemask(ipCam1, "abcdefghijklmnopqrstuvwxyz");
253  changeinput(ipCam1, getlist(myconfig, "InstarCam1IP", NULL));
254  changemask(portCam1, "0000");
255  changeinput(portCam1, getlist(myconfig, "InstarCam1Port", NULL));
256  changemask(userCam1, "abcdefghijklmnopqrstuvwxyz");
257  changeinput(userCam1, getlist(myconfig, "InstarCam1User", NULL));
258  changemask(passCam1, "abcdefghijklmnopqrstuvwxyz");
259  changeinput(passCam1, getlist(myconfig, "InstarCam1Pass", NULL));
260 
261  addchoicebox(onCam2, "aus", _("aus"));
262        addchoicebox(onCam2, "ein", _("ein"));
263        setchoiceboxselection(onCam2, getlist(myconfig, "InstarCam2", NULL));   
264        addchoicebox(typCam2, "0", "0");
265        addchoicebox(typCam2, "1", "1");
266        addchoicebox(typCam2, "2", "2");
267        addchoicebox(typCam2, "3", "3");
268        addchoicebox(typCam2, "4", "4");
269        addchoicebox(typCam2, "5", "5");
270        setchoiceboxselection(typCam2, getconfig("instar_2", NULL));
271        changemask(ipCam2, "abcdefghijklmnopqrstuvwxyz");
272  changeinput(ipCam2, getlist(myconfig, "InstarCam2IP", NULL));
273  changemask(portCam2, "0000");
274  changeinput(portCam2, getlist(myconfig, "InstarCam2Port", NULL));
275  changemask(userCam2, "abcdefghijklmnopqrstuvwxyz");
276  changeinput(userCam2, getlist(myconfig, "InstarCam2User", NULL));
277  changemask(passCam2, "abcdefghijklmnopqrstuvwxyz");
278  changeinput(passCam2, getlist(myconfig, "InstarCam2Pass", NULL));
279 
280        drawscreen(instar_einstellungen, 0, 0);
281        addscreenrc(instar_einstellungen, listbox);
282        tmp = listbox->select;
283       
284        while(1)
285        {
286                addscreenrc(instar_einstellungen, tmp);
287                rcret = waitrc(instar_einstellungen, 1000, 0);
288                tmp = listbox->select;
289               
290                if(rcret == getrcconfigint("rcexit", NULL)) break;
291                if(rcret == getrcconfigint("rcgreen", NULL) || rcret == getrcconfigint("rcblue", NULL))
292                {
293                        addlist(myconfig, "InstarCamAutostart", autoCam->ret);
294                        addlist(myconfig, "InstarCam1", onCam1->ret);
295                        addlist(myconfig, "InstarCam1IP", ipCam1->ret);
296                        addlist(myconfig, "InstarCam1Port", portCam1->ret);
297                        addlist(myconfig, "InstarCam1User", userCam1->ret);
298                        addlist(myconfig, "InstarCam1Pass", passCam1->ret);
299                        addlist(myconfig, "InstarCam2", onCam2->ret);
300                        addlist(myconfig, "InstarCam2IP", ipCam2->ret);
301                        addlist(myconfig, "InstarCam2Port", portCam2->ret);
302                        addlist(myconfig, "InstarCam2User", userCam2->ret);
303                        addlist(myconfig, "InstarCam2Pass", passCam2->ret);
304                        writelist(myconfig, instarconf);
305                        addconfig("instar_1", typCam1->ret);
306                        addconfig("instar_2", typCam2->ret);
307                        addconfig("instar_alterwebif", alterwebif->ret);
308                        if(rcret == getrcconfigint("rcblue", NULL))
309                        {
310                                rcode = 1;
311                                break;
312                        }
313                }
314        }
315        delownerrc(instar_einstellungen);
316        clearscreen(instar_einstellungen);
317        return rcode;   
318}
319
320
321
322void instar_main()
323{
324        int rcode = 0;
325        int ext = 0;
326       
327        instarconf = createpluginpath("/instar/instar.conf", 0);
328        readconfig(instarconf, myconfig);
329
330        char* CURL = NULL;
331        CURL = createpluginpath("/instar/curl", 0);
332        if(!file_exist(CURL))
333        {
334                free(CURL); CURL = NULL;
335                CURL = ostrcat("curl", NULL, 0, 0);
336        }
337
338        if(file_exist("/tmp/callcam1"))
339        {
340                ext = 1;
341                system("rm /callcam*");
342        }
343  else if(file_exist("/tmp/callcam2"))
344        {
345                ext = 2;
346                system("rm /callcam*");
347        }
348  else
349        ext = 0;
350 
351  if(ext > 0)
352        rcode = 1;
353  else if(ostrcmp(getlist(myconfig, "InstarCamAutostart", NULL), "ja") == 0)
354                rcode = 1;
355        else
356                rcode = instar_settings();
357       
358        if(rcode == 1)
359        {
360                if(checkbox("ATEMIO5200") == 1)
361                        addconfig("pic_scale", "1");
362                while(1)
363                {
364                        if(ostrcmp(getlist(myconfig, "InstarCam1", NULL), "ein") == 0 || ext == 1)
365                        {
366                                if(getconfigint("instar_1", NULL) != 5)
367                                {
368                                        if(getconfigint("instar_alterwebif", NULL) == 0)
369                                                cam1 = ostrcat("wget --output-document=/tmp/instar1.jpg http://", getlist(myconfig, "InstarCam1User", NULL), 0, 0);
370                                        else
371                                        {
372                                                cam1 = ostrcat(CURL, " http://", 0, 0);
373                                                cam1 = ostrcat(cam1, getlist(myconfig, "InstarCam1User", NULL), 1, 0);
374                                        }
375                                        cam1 = ostrcat(cam1, ":",1, 0);
376                                        cam1 = ostrcat(cam1, getlist(myconfig, "InstarCam1Pass", NULL), 1, 0);
377                                        cam1 = ostrcat(cam1, "@",1, 0);
378                                        cam1 = ostrcat(cam1, getlist(myconfig, "InstarCam1IP", NULL), 1, 0);
379                                        cam1 = ostrcat(cam1, ":",1, 0);
380                                        cam1 = ostrcat(cam1, getlist(myconfig, "InstarCam1Port", NULL), 1, 0);
381                                }
382                                else
383                                {
384                                        if(getconfigint("instar_alterwebif", NULL) == 0)
385                                                cam1 = ostrcat("wget --output-document=/tmp/instar1.jpg http://", NULL, 0, 0);
386                                        else
387                                        {
388                                                cam1 = ostrcat(CURL, " http://", 0, 0);
389                                        }
390                                        cam1 = ostrcat(cam1, getlist(myconfig, "InstarCam1IP", NULL), 1, 0);
391                                        cam1 = ostrcat(cam1, ":",1, 0);
392                                        cam1 = ostrcat(cam1, getlist(myconfig, "InstarCam1Port", NULL), 1, 0);
393                                        cam11 = ostrcat("%26usr%3D", getlist(myconfig, "InstarCam1User", NULL), 0, 0);
394                                        cam11 = ostrcat(cam11, "%26pwd%3D", 1, 0);
395                                        cam11 = ostrcat(cam11, getlist(myconfig, "InstarCam1Pass", NULL), 1, 0);
396                                        //cam11 = ostrcat(cam11, "&", 1, 0);
397                                       
398                                }
399                        }
400                       
401               
402                       
403                        if(ostrcmp(getlist(myconfig, "InstarCam2", NULL), "ein") == 0 || ext == 2)
404                        {
405                                if(getconfigint("instar_2", NULL) != 5)
406                                {                               
407                                        if(getconfigint("instar_alterwebif", NULL) == 0)
408                                                cam2 = ostrcat("wget --output-document=/tmp/instar2.jpg http://", getlist(myconfig, "InstarCam2User", NULL), 0, 0);
409                                        else
410                                        {
411                                                cam2 = ostrcat(CURL, " http://", 0, 0);
412                                                cam2 = ostrcat(cam2, getlist(myconfig, "InstarCam2User", NULL), 1, 0);
413                                        }
414                                        cam2 = ostrcat(cam2, ":",1, 0);
415                                        cam2 = ostrcat(cam2, getlist(myconfig, "InstarCam2Pass", NULL), 1, 0);
416                                        cam2 = ostrcat(cam2, "@",1, 0);
417                                        cam2 = ostrcat(cam2, getlist(myconfig, "InstarCam2IP", NULL), 1, 0);
418                                        cam2 = ostrcat(cam2, ":",1, 0);
419                                        cam2 = ostrcat(cam2, getlist(myconfig, "InstarCam2Port", NULL), 1, 0);
420                                }
421                                else
422                                {
423                                        if(getconfigint("instar_alterwebif", NULL) == 0)
424                                                cam2 = ostrcat("wget --output-document=/tmp/instar2.jpg http://", NULL, 0, 0);
425                                        else
426                                        {
427                                                cam2 = ostrcat(CURL, " http://", 0, 0);
428                                        }
429                                        cam2 = ostrcat(cam2, getlist(myconfig, "InstarCam2IP", NULL), 1, 0);
430                                        cam2 = ostrcat(cam2, ":",1, 0);
431                                        cam2 = ostrcat(cam2, getlist(myconfig, "InstarCam2Port", NULL), 1, 0);
432                                        cam21 = ostrcat("%26usr%3D", getlist(myconfig, "InstarCam2User", NULL), 0, 0);
433                                        cam21 = ostrcat(cam21, "%26pwd%3D", 1, 0);
434                                        cam21 = ostrcat(cam21, getlist(myconfig, "InstarCam2Pass", NULL), 1, 0);
435                                        //cam21 = ostrcat(cam21, "&", 1, 0);
436                                }                               
437                        }
438                                       
439                        instar_screen = getscreen("instar_full");
440                        instar_pic1 = getscreennode(instar_screen, "pic1");
441                        instar_actcam1 = getscreennode(instar_screen, "actcam1");
442       
443                        if(ostrcmp(getlist(myconfig, "InstarActCam", NULL), "2") == 0 && ext != 1)
444                        {
445                                actcam = 2;
446                                changepic(instar_pic1, "/tmp/instar2.jpg");
447                                changetext(instar_actcam1, "CAM2");
448                        }
449                        else
450                        {
451                                actcam = 1;
452                                changepic(instar_pic1, "/tmp/instar1.jpg");
453                                changetext(instar_actcam1, "CAM1");
454                        }
455                       
456                        rcode = show_control();
457       
458                        free(cam1), cam1 = NULL;
459                        free(cam2), cam2 = NULL;
460                        free(cam11), cam11 = NULL;
461                        free(cam21), cam21 = NULL;
462                       
463                        if(rcode == 0)
464                                break;
465                        rcode = 0;
466                       
467                        rcode = instar_settings();
468                        if(rcode == 0)
469                                break;
470                }
471                if(checkbox("ATEMIO5200") == 1)
472                        addconfig("pic_scale", "0");
473        }
474        writelist(myconfig, instarconf);
475        freelist(myconfig);
476        free(instarconf); instarconf = NULL;
477        free(CURL); CURL = NULL;
478}
Note: See TracBrowser for help on using the repository browser.