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

Last change on this file since 16100 was 16100, checked in by gost, 11 years ago

[titanb] add new plugin IP-Kammera

  • Property svn:executable set to *
File size: 8.1 KB
Line 
1//#ifndef INSTAR_H
2//#define INSTAR_H
3
4char* cam1 = NULL;
5char* cam2 = NULL;
6struct skin* instar_screen = NULL;
7int actcam = 1;
8
9struct clist *ownconfig[LISTHASHSIZE] = {NULL};
10char* instarconf = NULL;
11
12int 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        while(1)
26        {
27                if(cam1 != NULL)
28                {
29                        tmpstr = ostrcat(cam1, "/snapshot.cgi", 0, 0);
30                        system(tmpstr);
31                        free(tmpstr); tmpstr = NULL;
32                }
33                if(cam2 != NULL)
34                {
35                        tmpstr = ostrcat(cam2, "/snapshot.cgi", 0, 0);
36                        system(tmpstr);
37                        free(tmpstr); tmpstr = NULL;
38                }
39               
40                drawscreen(instar_screen, 0);
41                rcret = waitrc(instar_screen, 0, 0);
42
43                if(rcret == getrcconfigint("rcexit", NULL)) break;
44               
45                if(rcret == getrcconfigint("rcinfo", NULL))
46                {
47                        addlist(ownconfig, "InstarCamAutostart", "nein");
48                        rcode = 1;
49                        break;
50                }       
51                       
52                if(rcret == getrcconfigint("rc1", NULL))
53                        position = ostrcat("/decoder_control.cgi?command=", "31", 0 , 0);
54                if(rcret == getrcconfigint("rc2", NULL))
55                        position = ostrcat("/decoder_control.cgi?command=", "33", 0 , 0);
56                if(rcret == getrcconfigint("rc3", NULL))
57                        position = ostrcat("/decoder_control.cgi?command=", "35", 0 , 0);
58                if(rcret == getrcconfigint("rc4", NULL))
59                        position = ostrcat("/decoder_control.cgi?command=", "37", 0 , 0);
60                if(rcret == getrcconfigint("rc5", NULL))
61                        position = ostrcat("/decoder_control.cgi?command=", "39", 0 , 0);
62                if(rcret == getrcconfigint("rc6", NULL))
63                        position = ostrcat("/decoder_control.cgi?command=", "41", 0 , 0);
64                if(rcret == getrcconfigint("rc7", NULL))
65                        position = ostrcat("/decoder_control.cgi?command=", "43", 0 , 0);
66                if(rcret == getrcconfigint("rc8", NULL))
67                        position = ostrcat("/decoder_control.cgi?command=", "45", 0 , 0);
68                if(rcret == getrcconfigint("rc9", NULL))
69                        position = ostrcat("/decoder_control.cgi?command=", "47", 0 , 0);
70                if(rcret == getrcconfigint("rcup", NULL))
71                        position = ostrcat("/decoder_control.cgi?command=", "0&onestep=1", 0 , 0);
72                if(rcret == getrcconfigint("rcdown", NULL))
73                        position = ostrcat("/decoder_control.cgi?command=", "2&onestep=1", 0 , 0);
74                if(rcret == getrcconfigint("rcleft", NULL))
75                        position = ostrcat("/decoder_control.cgi?command=", "4&onestep=1", 0 , 0);
76                if(rcret == getrcconfigint("rcright", NULL))
77                        position = ostrcat("/decoder_control.cgi?command=", "6&onestep=1", 0 , 0);
78               
79               
80                if(position != NULL && tempcam != NULL)
81                {
82                        tmpstr = ostrcat(tempcam, position, 0, 0);
83                        system(tmpstr);
84                        free(tmpstr); tmpstr = NULL;   
85                        free(position); position = NULL;
86                        sleep(1);
87                }
88        }
89
90        clearscreen(instar_screen);
91        return rcode;
92}
93
94int instar_settings()
95{
96       
97        int rcret = 0;
98        int rcode = 0;
99       
100        struct skin* instar_einstellungen = getscreen("instar_einstellungen");
101        struct skin* listbox = getscreennode(instar_einstellungen, "listbox");
102        struct skin* autoCam = getscreennode(instar_einstellungen, "autoCam");
103        struct skin* onCam1 = getscreennode(instar_einstellungen, "onCam1");
104        struct skin* ipCam1 = getscreennode(instar_einstellungen, "ipCam1");
105        struct skin* portCam1 = getscreennode(instar_einstellungen, "portCam1");
106        struct skin* userCam1 = getscreennode(instar_einstellungen, "userCam1");
107        struct skin* passCam1 = getscreennode(instar_einstellungen, "passCam1");
108        struct skin* onCam2 = getscreennode(instar_einstellungen, "onCam2");
109        struct skin* ipCam2 = getscreennode(instar_einstellungen, "ipCam2");
110        struct skin* portCam2 = getscreennode(instar_einstellungen, "portCam2");
111        struct skin* userCam2 = getscreennode(instar_einstellungen, "userCam2");
112        struct skin* passCam2 = getscreennode(instar_einstellungen, "passCam2");
113       
114        struct skin* tmp = NULL;
115
116  addchoicebox(autoCam, "nein", _("nein"));
117        addchoicebox(autoCam, "ja", _("ja"));
118        setchoiceboxselection(autoCam, getlist(ownconfig, "InstarCamAutostart", NULL));
119 
120  addchoicebox(onCam1, "aus", _("aus"));
121        addchoicebox(onCam1, "ein", _("ein"));
122        setchoiceboxselection(onCam1, getlist(ownconfig, "InstarCam1", NULL)); 
123        changemask(ipCam1, "abcdefghijklmnopqrstuvwxyz");
124  changeinput(ipCam1, getlist(ownconfig, "InstarCam1IP", NULL));
125  changemask(portCam1, "0000");
126  changeinput(portCam1, getlist(ownconfig, "InstarCam1Port", NULL));
127  changemask(userCam1, "abcdefghijklmnopqrstuvwxyz");
128  changeinput(userCam1, getlist(ownconfig, "InstarCam1User", NULL));
129  changemask(passCam1, "abcdefghijklmnopqrstuvwxyz");
130  changeinput(passCam1, getlist(ownconfig, "InstarCam1Pass", NULL));
131 
132  addchoicebox(onCam2, "aus", _("aus"));
133        addchoicebox(onCam2, "ein", _("ein"));
134        setchoiceboxselection(onCam2, getlist(ownconfig, "InstarCam2", NULL)); 
135        changemask(ipCam2, "abcdefghijklmnopqrstuvwxyz");
136  changeinput(ipCam2, getlist(ownconfig, "InstarCam2IP", NULL));
137  changemask(portCam2, "0000");
138  changeinput(portCam2, getlist(ownconfig, "InstarCam2Port", NULL));
139  changemask(userCam2, "abcdefghijklmnopqrstuvwxyz");
140  changeinput(userCam2, getlist(ownconfig, "InstarCam2User", NULL));
141  changemask(passCam2, "abcdefghijklmnopqrstuvwxyz");
142  changeinput(passCam2, getlist(ownconfig, "InstarCam2Pass", NULL));
143 
144        drawscreen(instar_einstellungen, 0);
145        addscreenrc(instar_einstellungen, listbox);
146        tmp = listbox->select;
147       
148        while(1)
149        {
150                addscreenrc(instar_einstellungen, tmp);
151                rcret = waitrc(instar_einstellungen, 1000, 0);
152                tmp = listbox->select;
153               
154                if(rcret == getrcconfigint("rcexit", NULL)) break;
155                if(rcret == getrcconfigint("rcgreen", NULL) || rcret == getrcconfigint("rcblue", NULL))
156                {
157                        addlist(ownconfig, "InstarCamAutostart", autoCam->ret);
158                        addlist(ownconfig, "InstarCam1", onCam1->ret);
159                        addlist(ownconfig, "InstarCam1IP", ipCam1->ret);
160                        addlist(ownconfig, "InstarCam1Port", portCam1->ret);
161                        addlist(ownconfig, "InstarCam1User", userCam1->ret);
162                        addlist(ownconfig, "InstarCam1Pass", passCam1->ret);
163                        addlist(ownconfig, "InstarCam2", onCam2->ret);
164                        addlist(ownconfig, "InstarCam2IP", ipCam2->ret);
165                        addlist(ownconfig, "InstarCam2Port", portCam2->ret);
166                        addlist(ownconfig, "InstarCam2User", userCam2->ret);
167                        addlist(ownconfig, "InstarCam2Pass", passCam2->ret);
168                        writelist(ownconfig, instarconf);
169                        if(rcret == getrcconfigint("rcblue", NULL))
170                        {
171                                rcode = 1;
172                                break;
173                        }
174                }
175        }
176        delownerrc(instar_einstellungen);
177        clearscreen(instar_einstellungen);
178        return rcode;   
179}
180
181
182
183void instar_main()
184{
185        int rcode = 0;
186
187        instarconf = ostrcat(getconfig("pluginpath", NULL), "/instar/instar.conf", 0, 0);
188        readconfig(instarconf, ownconfig);
189       
190  if(ostrcmp(getlist(ownconfig, "InstarCamAutostart", NULL), "ja") == 0)
191                rcode = 1;
192        else
193                rcode = instar_settings();
194       
195        if(rcode == 1)
196        {
197                while(1)
198                {
199                        cam1 = ostrcat(" wget --output-document=/tmp/instar1.jpg http://gost:goetz@10.0.0.201:8081", "", 0, 0);
200                        /*
201                        if(ostrcmp(getlist(ownconfig, "InstarCam1", NULL), "ein") == 0)
202                        {
203                                cam1 = ostrcat("wget --user=", getlist(ownconfig, "InstarCam1User", NULL), 0, 0);
204                                cam1 = ostrcat(cam1, " --password=",1, 0);
205                                cam1 = ostrcat(cam1, getlist(ownconfig, "InstarCam1Pass", NULL), 1, 0);
206                                cam1 = ostrcat(cam1, " --output-document=/tmp/instar1.jpg http://",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}
Note: See TracBrowser for help on using the repository browser.