source: titan/plugins/callmonitor1/callmon_main.h @ 40377

Last change on this file since 40377 was 40377, checked in by gost, 7 years ago

[plugins] callmon.. smaller fix

  • Property svn:executable set to *
File size: 6.9 KB
Line 
1//#ifndef CALLMON_MAIN_H
2//#define CALLMON_MAIN_H
3
4struct stimerthread* CallmonStartThread = NULL;
5int coldstart = 0;
6
7void callmonstart()
8{
9        char* tmpstr = NULL;
10       
11        tmpstr = createpluginpath("/callmonitor1/fritzbox_msg_new.sh", 0);
12        tmpstr = ostrcat(tmpstr, " stop", 1, 0);
13        system(tmpstr);
14        free(tmpstr); tmpstr = NULL;
15       
16        if(coldstart == 1)
17                sleep(10);
18        else
19                sleep(1);
20       
21        tmpstr = createpluginpath("/callmonitor1/fritzbox_msg_new.sh", 0);
22        tmpstr = ostrcat(tmpstr, " start", 1, 0);
23        system(tmpstr);
24        free(tmpstr); tmpstr = NULL;
25        coldstart = 0;
26        CallmonStartThread = NULL;
27}
28
29void callmontimeout()
30{
31        if(coldstart == 1)
32                sleep(45);
33        else
34                sleep(35);
35               
36        if(CallmonStartThread != NULL)
37        {
38                system("killall fritzbox_msg_new.sh");
39                textbox(_("Message"), _("Callmon Timeout !!!\n\ncheck your parameter "), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 650, 200,5, 0);
40        }
41}
42       
43
44void callmon_main()
45{
46        char* tmpstr = NULL;
47       
48        struct clist *myconfig[LISTHASHSIZE] = {NULL};
49        char* callconf = NULL;
50        callconf = createpluginpath("/callmonitor1/callmon.conf", 0);
51        readconfig(callconf, myconfig);
52               
53        debug(1000, "in");
54        status.hangtime = 99999;
55        int rcret = 0;
56        int hgreen = 0;
57        int hblue = 0;
58
59        struct skin* callmon_main = getscreen("callmon_main");
60        struct skin* listbox = getscreennode(callmon_main, "listbox");
61        struct skin* fritzversion = getscreennode(callmon_main, "fritzversion");
62        struct skin* ipaddress = getscreennode(callmon_main, "ipaddress");
63        struct skin* phonebook = getscreennode(callmon_main, "phonebook");
64        struct skin* userid = getscreennode(callmon_main, "userid");
65        struct skin* passwort = getscreennode(callmon_main, "passwort");
66        struct skin* rufnummer1 = getscreennode(callmon_main, "rufnummer1");
67        struct skin* rufnummer2 = getscreennode(callmon_main, "rufnummer2");
68        struct skin* allnum = getscreennode(callmon_main, "allnum");
69        struct skin* ausgehend = getscreennode(callmon_main, "ausgehend");
70        struct skin* eingehend = getscreennode(callmon_main, "eingehend");
71        struct skin* stumm = getscreennode(callmon_main, "stumm");
72        struct skin* wennaus = getscreennode(callmon_main, "wennaus");
73        struct skin* atimeout = getscreennode(callmon_main, "atimeout");
74        struct skin* tmp = NULL;
75       
76        addchoicebox(fritzversion, "50", _("nein"));
77        addchoicebox(fritzversion, "60", _("ja"));
78        setchoiceboxselection(fritzversion, getlist(myconfig, "FritzVersion", NULL));
79       
80        changemask(passwort, "abcdefghijklmnopqrstuvwxyz");
81        changeinput(passwort, getlist(myconfig, "FritzPass", NULL));
82       
83        changemask(userid, "abcdefghijklmnopqrstuvwxyz");
84        changeinput(userid, getlist(myconfig, "FritzUser", NULL));
85       
86        changemask(ipaddress, "000.000.000.000");
87        tmpstr = fixip(getlist(myconfig, "FRITZBOXIP", NULL), 0);
88        changeinput(ipaddress, tmpstr);
89        free(tmpstr); tmpstr = NULL;
90       
91        changemask(rufnummer1, "0000000000000");
92        changeinput(rufnummer1,getlist(myconfig, "Ziel", NULL));
93       
94        changemask(rufnummer2, "0000000000000");
95        changeinput(rufnummer2,getlist(myconfig, "Ziel_2", NULL));
96               
97        addchoicebox(allnum, "ja", _("ja"));
98        addchoicebox(allnum, "nein", _("nein"));
99        if(ostrcmp(getlist(myconfig, "Alle", NULL), "1")  == 0)
100        {
101                setchoiceboxselection(allnum, "ja");
102                rufnummer1->hidden = YES;
103                rufnummer2->hidden = YES;
104        }
105        else {
106                setchoiceboxselection(allnum, "nein");
107                rufnummer1->hidden = NO;
108                rufnummer2->hidden = NO;
109        }
110       
111        //addlist(myconfig, "key", Value));
112        //writelist(myconfig, callconf);
113        //freelist(myconfig);
114       
115        addchoicebox(phonebook, "1", _("ja"));
116        addchoicebox(phonebook, "0", _("nein"));
117        setchoiceboxselection(phonebook, getlist(myconfig, "usePhoneBook", NULL));
118       
119        addchoicebox(eingehend, "1", _("ja"));
120        addchoicebox(eingehend, "0", _("nein"));
121        setchoiceboxselection(eingehend, getlist(myconfig, "monRing", NULL));
122       
123        addchoicebox(ausgehend, "1", _("ja"));
124        addchoicebox(ausgehend, "0", _("nein"));
125        setchoiceboxselection(ausgehend, getlist(myconfig, "monCall", NULL));
126       
127        addchoicebox(stumm, "1", _("ja"));
128        addchoicebox(stumm, "0", _("nein"));
129        setchoiceboxselection(stumm, getlist(myconfig, "muteRing", NULL));
130       
131        addchoicebox(wennaus, "1", _("puffern"));
132        addchoicebox(wennaus, "0", _("verwerfen"));
133        setchoiceboxselection(wennaus, getlist(myconfig, "anzeigewennaus", NULL));
134       
135        addchoicebox(atimeout, "3", _("3"));
136        addchoicebox(atimeout, "4", _("4"));
137        addchoicebox(atimeout, "5", _("5"));
138        addchoicebox(atimeout, "6", _("6"));
139        addchoicebox(atimeout, "8", _("8"));
140        addchoicebox(atimeout, "10", _("10"));
141        addchoicebox(atimeout, "12", _("12"));
142        setchoiceboxselection(atimeout, getlist(myconfig, "anzeigetimeout", NULL));
143
144        drawscreen(callmon_main, 0, 0);
145        addscreenrc(callmon_main, listbox);
146
147        tmp = listbox->select;
148        while(1)
149        {
150                addscreenrc(callmon_main, tmp);
151                rcret = waitrc(callmon_main, 1000, 0);
152                tmp = listbox->select;
153               
154                hgreen=0;
155                hblue=0;
156
157                if(rcret == getrcconfigint("rcexit", NULL)) break;
158       
159                if((rcret == getrcconfigint("rcleft", NULL) || rcret == getrcconfigint("rcright", NULL)) && listbox->select != NULL && ostrcmp(listbox->select->name, "allnum") == 0)
160                {
161                        rufnummer1->hidden = NO;
162                        rufnummer2->hidden = NO;
163                        if(ostrcmp(allnum->ret, "ja") == 0)
164                        {
165                                rufnummer1->hidden = YES;
166                                rufnummer2->hidden = YES;
167                        }
168                        drawscreen(callmon_main, 0, 0);
169                }
170                if(rcret == getrcconfigint("rcgreen", NULL))
171                        hgreen = 1;
172                if(rcret == getrcconfigint("rcblue", NULL))
173                        hblue = 1;
174               
175                if(hgreen == 1 || hblue == 1)
176                {       
177                        tmpstr = createpluginpath("/callmonitor1/fritzbox_msg_new.sh", 0);
178                        tmpstr = ostrcat(tmpstr, " stop", 1, 0);
179                        system(tmpstr);
180                        free(tmpstr); tmpstr = NULL;
181                       
182                        tmpstr = fixip(ipaddress->ret, 1);
183                        addlist(myconfig, "FRITZBOXIP", tmpstr);
184                        free(tmpstr); tmpstr = NULL;
185                        addlist(myconfig, "FritzVersion", fritzversion->ret);
186                        addlist(myconfig, "monRing", eingehend->ret);
187                        addlist(myconfig, "monCall", ausgehend->ret);
188                        addlist(myconfig, "muteRing", stumm->ret);
189                        addlist(myconfig, "anzeigewennaus", wennaus->ret);
190                        addlist(myconfig, "anzeigetimeout", atimeout->ret);
191                        addlist(myconfig, "usePhoneBook", phonebook->ret);
192                        addlist(myconfig, "FritzPass", passwort->ret);
193                        addlist(myconfig, "FritzUser", userid->ret);
194                        addlist(myconfig, "Ziel", rufnummer1->ret);
195                        addlist(myconfig, "Ziel_2", rufnummer2->ret);
196                       
197                        if(ostrcmp(allnum->ret, "ja")  == 0)
198                                addlist(myconfig, "Alle", "1");
199                        else
200                                addlist(myconfig, "Alle", "0");
201                        writelist(myconfig, callconf);
202                       
203                        if(hblue == 1 && ostrcmp(getlist(myconfig, "usePhoneBook", NULL), "1")  == 0)
204                        {
205                                tmpstr = createpluginpath("/callmonitor1/fritzbox_msg_new.sh", 0);
206                                tmpstr = ostrcat(tmpstr, " loadPhoneBook", 1, 0);
207                                system(tmpstr);
208                                free(tmpstr); tmpstr = NULL;
209                        }
210                        if(CallmonStartThread == NULL)
211                        {
212                                CallmonStartThread = addtimer(&callmonstart, START, 10000, 1, NULL, NULL, NULL);
213                                addtimer(&callmontimeout, START, 10000, 1, NULL, NULL, NULL);
214                        }
215                        free(tmpstr); tmpstr = NULL;
216                       
217                        break;
218                }
219        }
220        delownerrc(callmon_main);
221        clearscreen(callmon_main);
222        freelist(myconfig);
223        free(callconf); callconf = NULL;
224        status.hangtime = getconfigint("hangtime", NULL);
225}
226       
Note: See TracBrowser for help on using the repository browser.