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

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

[titan] add new web function

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