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