source: titan/titan/extensions.h @ 27899

Last change on this file since 27899 was 27842, checked in by obi, 10 years ago

misel disable mnt tpk install

File size: 16.3 KB
Line 
1#ifndef EXTENSIONS_H
2#define EXTENSIONS_H
3
4void screenfeed()
5{
6        char* tmpstr = NULL, *line = NULL, *lastline = NULL;
7        char* pos = NULL;
8
9        tmpstr = readsys(getconfig("feed", NULL), 3); //line3
10        tmpstr = string_replace("src/gz secret http://", "", tmpstr, 1);
11
12        if(tmpstr != NULL)
13                pos = strchr(tmpstr, '/');
14        if(pos != NULL)
15                pos[0] = '\0';
16
17        if(tmpstr == NULL || ostrcmp(tmpstr, "") == 0 || ostrcmp(tmpstr, "\n") == 0)
18                tmpstr = ostrcat(tmpstr, "000.000.000.000", 1, 0);
19
20        lastline = numinput(_("Feed"), tmpstr, "000.000.000.000", 1);
21
22        //for devs, who have secret feed not in mind
23        if(ostrcmp("999.999.999.999", lastline) == 0)
24        {
25                free(lastline); lastline = NULL;
26                lastline = ostrcat("097.074.032.010", NULL, 0, 0);
27        }
28
29        if(lastline != NULL)
30        {
31                free(tmpstr); tmpstr = NULL;
32                tmpstr = fixip(lastline, 1);
33                free(lastline); lastline = tmpstr;
34
35                tmpstr = readsys(getconfig("feed", NULL), 1); //line1
36                if(tmpstr == NULL || (tmpstr != NULL && strlen(tmpstr) == 0))
37                        line = ostrcat(line, "#", 1, 0);
38                else
39                        line = ostrcat(line, tmpstr, 1, 0);
40                free(tmpstr); tmpstr = NULL;
41
42                if(line[strlen(line) - 1] != '\n')
43                        line = ostrcat(line, "\n", 1, 0);
44
45                tmpstr = readsys(getconfig("feed", NULL), 2); //line2
46                if(tmpstr == NULL || (tmpstr != NULL && strlen(tmpstr) == 0))
47                        line = ostrcat(line, "#\n", 1, 0);
48                else
49                        line = ostrcat(line, tmpstr, 1, 0);
50                free(tmpstr); tmpstr = NULL;
51
52                if(line[strlen(line) - 1] == '\n')
53                        tmpstr = ostrcat(line, "src/gz secret http://", 0, 0);
54                else
55                        tmpstr = ostrcat(line, "\nsrc/gz secret http://", 0, 0);
56
57                if(strlen(lastline) == 0)
58                {
59                        free(tmpstr);
60                        tmpstr = ostrcat(line, NULL, 0, 0);
61                }
62
63                tmpstr = ostrcat(tmpstr, lastline, 1, 0);
64                tmpstr = ostrcat(tmpstr, "/svn/tpk/sh4", 1, 0);
65                writesys(getconfig("feed", NULL), tmpstr, 0);
66        }
67
68        free(tmpstr);
69        free(line);
70        free(lastline);
71}
72
73//flag 0: install ok
74//flag 1: install err
75//flag 2: remove ok
76//flag 3: remove err
77char* gettpklog(char* installpath, int flag)
78{
79        char* tmpstr = NULL;
80
81        if(flag == 0 || flag == 1)
82                tmpstr = ostrcat(tmpstr, _("Installation start"), 1, 0);
83        else
84                tmpstr = ostrcat(tmpstr, _("Remove start"), 1, 0);
85        tmpstr = ostrcat(tmpstr, "\n\n", 1, 0);
86       
87        tmpstr = ostrcat(tmpstr, readfiletomem(TPKLOG, 0), 1, 1);
88       
89        tmpstr = ostrcat(tmpstr, "\n\n", 1, 0);
90       
91        if(installpath != NULL)
92        {
93                tmpstr = ostrcat(tmpstr, _("New free space (KB): "), 1, 0);
94                tmpstr = ostrcat(tmpstr, ollutoa(getfreespace(installpath) / 1024), 1, 1);
95                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
96        }
97       
98        if(flag == 0)
99                tmpstr = ostrcat(tmpstr, _("Install success"), 1, 0);
100        if(flag == 1)
101                tmpstr = ostrcat(tmpstr, _("Install error"), 1, 0);
102        if(flag == 2)
103                tmpstr = ostrcat(tmpstr, _("Remove success"), 1, 0);
104        if(flag == 3)
105                tmpstr = ostrcat(tmpstr, _("Remove error"), 1, 0);
106               
107        if(installpath == NULL || ostrcmp("/var/swap", installpath) == 0)
108                sync();
109       
110        return tmpstr;
111}
112
113char* getinstallpath(char* path, char* size)
114{
115        int count = 0, isize = 0;
116        char* tmpstr = NULL;
117        struct menulist* mlist = NULL, *mbox = NULL, *tmpmlist = NULL;
118       
119        if(size != NULL) isize = atoi(size);
120       
121        if(checkbox("ATEMIO5000") != 1 && checkbox("ATEMIO5200") != 1)
122        {
123                if(path == NULL || path[0] == '*' || ostrstr(path, "mnt") != NULL)
124                {
125                        if(tpkchecksize(NULL, "/mnt/swapextensions", isize) == 0)
126                        {
127                                tmpmlist = addmenulist(&mlist, _("Install to MNT"), NULL, NULL, 0, 0);
128                                changemenulistparam(tmpmlist, "/mnt/swapextensions", NULL, NULL, NULL);
129                                free(tmpstr); tmpstr = NULL;
130                                tmpstr = ostrcat("/mnt/swapextensions", NULL, 0, 0);
131                                count++;
132                        }
133                }
134        }
135       
136        if(path == NULL || path[0] == '*' || ostrstr(path, "var") != NULL)
137        {
138                if(tpkchecksize(NULL, "/var", isize) == 0)
139                {
140                        tmpmlist = addmenulist(&mlist, _("Install to FLASH"), NULL, NULL, 0, 0);
141                        changemenulistparam(tmpmlist, "/var", NULL, NULL, NULL);
142                        free(tmpstr); tmpstr = NULL;
143                        tmpstr = ostrcat("/var", NULL, 0, 0);
144                        count++;
145                }
146        }
147       
148        if(path == NULL || path[0] == '*' || ostrstr(path, "swap") != NULL)
149        {
150                if(file_exist("/tmp/.swapextensionsdev") == 1)
151                {
152                        if(tpkchecksize(NULL, "/var/swap", isize) == 0)
153                        {
154                                tmpmlist = addmenulist(&mlist, _("Install to SWAP"), NULL, NULL, 0, 0);
155                                changemenulistparam(tmpmlist, "/var/swap", NULL, NULL, NULL);
156                                free(tmpstr); tmpstr = NULL;
157                                tmpstr = ostrcat("/var/swap", NULL, 0, 0);
158                                count++;
159                        }
160                }
161        }
162       
163        //if(count > 1) // if only 1 installpath, don't show choicebox
164        if(count > 0) // show always choicebox
165        {
166                free(tmpstr); tmpstr = NULL;
167                mbox = menulistbox(mlist, "tpkinstallinfo", _("Choice Install Medium"), NULL, NULL, NULL, 0, 0);
168                if(mbox != NULL)
169                        tmpstr = ostrcat(mbox->param, NULL, 0, 0);
170        }
171        else if(count == 0)
172        {
173                textbox(_("Tpk Install Info"), _("Can't install Package. Package to big."), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 200, 0, 0);
174                free(tmpstr); tmpstr = NULL;
175        }
176       
177        freemenulist(mlist, 0); mlist = NULL;
178        return tmpstr;
179}
180
181void screenextensions(int mode, char* path, char* defentry, int first)
182{
183        char* tmpstr = NULL, *tmpinfo = NULL, *installpath = NULL;
184        struct menulist* mlist = NULL, *mbox = NULL;
185        struct menulist* mlist1 = NULL, *mbox1 = NULL;
186        struct skin* load = getscreen("loading");
187               
188        status.hangtime = 99999;
189        unlink(TPKLOG);
190       
191        if(mode == 0)
192        {
193                drawscreen(load, 0, 0);
194
195                if(first == 1) tpkgetindex(0);
196                tpklist();
197
198                clearscreen(load);
199
200                mbox = tpkmenulist(mlist, NULL, _("Tpk Install - select section"), NULL, NULL, 1, defentry, 0);
201
202                if(mbox != NULL)
203                {
204                        debug(130, "section: %s", mbox->name);
205                        mbox1 = tpkmenulist(mlist1, "tpkinstall", _("Tpk Install - select file"), "/tmp/tpk", mbox->name, 2, NULL, 1);
206                       
207                        if(mbox1 != NULL && mbox1->param != NULL && mbox1->param1 != NULL)
208                        {
209                                debug(130, "file: %s", mbox1->name);
210                                if(ostrstr(mbox1->name, _("It may only be a package to be installed. If they want to install another package of this section, they only remove the installed packet. Is not the plugin after reinstalling the software TitanNit in TitanNit Menu Visible then perform an update by Tpk to: ")) == NULL)
211                                {
212                                        installpath = getinstallpath(mbox1->param2, mbox1->param3);
213                                        if(installpath != NULL)
214                                        {
215                                                tmpinfo = ostrcat(tmpinfo, _("Installing"), 1, 0);
216                                                tmpinfo = ostrcat(tmpinfo, " ", 1, 0);
217                                                tmpinfo = ostrcat(tmpinfo, mbox->name, 1, 0);
218                                                tmpinfo = ostrcat(tmpinfo, "-", 1, 0);
219                                                tmpinfo = ostrcat(tmpinfo, mbox1->name, 1, 0);
220                                                tmpinfo = ostrcat(tmpinfo, " ", 1, 0);
221                                                tmpinfo = ostrcat(tmpinfo, _("starting"), 1, 0);
222                                                tmpinfo = ostrcat(tmpinfo, " ?", 1, 0);
223                       
224                                                if(textbox(_("Tpk Install Info"), _(tmpinfo), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0) == 1)
225                                                {
226                                                        drawscreen(load, 0, 0);
227                                                        resettvpic();
228                                                        char* log = NULL;
229                                                        int tpkret = tpkgetpackage(mbox1->param, mbox1->param1, installpath, 0);
230                                                        if(tpkret == 0)
231                                                        {
232                                                                log = gettpklog(installpath, 0);
233                                                                textbox(_("Tpk Install Info - Install OK"), _(log), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 600, 0, 2);
234                                                        }
235                                                        else if(tpkret == 2)
236                                                        {
237                                                                textbox(_("Tpk Install Info - Install ERROR"), _("It may only be a package to be installed. If they want to install another package of this section, they only remove the installed packet. Is not the plugin after reinstalling the software TitanNit in TitanNit Menu Visible then perform an update by Tpk to: "), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 600, 0, 2);
238                                                        }
239                                                        else
240                                                        {
241                                                                log = gettpklog(installpath, 1);
242                                                                textbox(_("Tpk Install Info - Install ERROR"), _(log), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 600, 0, 2);
243                                                        }
244        //                                              textbox(_("Message"), _("Some plugins needs restart.\nIf the plugin is not active\nreboot the box."), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);
245                                                        loadplugin();
246                                                        free(log), log = NULL;
247                                                        unlink(TPKLOG);
248                                                        if(file_exist("/tmp/.tpk_needs_reboot"))
249                                                        {
250                                                                textbox(_("Message"), _("TPK Install done, your system will reboot !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 200, 0, 0);
251                                                                //write only config file
252                                                                writeallconfig(3);
253                                                                oshutdown(2,2);
254                                                                system("init 6");
255                                                        }
256                                                }
257                                        }
258                                }
259                        }
260                }
261                free(installpath); installpath = NULL;
262                free(tmpstr); tmpstr = NULL;   
263                freemenulist(mlist1, 0); mlist1 = NULL;
264                if(mbox != NULL) tmpstr = ostrcat(mbox->name, NULL, 0, 0);
265                freemenulist(mlist, 0); mlist = NULL;
266                free(tmpinfo); tmpinfo = NULL;
267                freetpk();
268                if(mbox != NULL) screenextensions(0, path, tmpstr, 0);
269                free(tmpstr); tmpstr = NULL;
270        }
271        else if(mode == 1)
272        {
273                tpklistinstalled(0);
274                mbox = tpkmenulist(mlist, NULL, _("Tpk Remove - select file"), NULL, NULL, 1, defentry, 2);
275               
276                if(mbox != NULL && mbox->param != NULL)
277                {
278                        debug(130, "file: %s", mbox->name);
279
280                        tmpinfo = ostrcat(tmpinfo, _("Removeing"), 1, 0);
281                        tmpinfo = ostrcat(tmpinfo, " ", 1, 0);
282                        tmpinfo = ostrcat(tmpinfo, mbox->name, 1, 0);
283                        tmpinfo = ostrcat(tmpinfo, " ?", 1, 0);
284
285                        if(textbox(_("Tpk Remove Info"), _(tmpinfo), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 200, 0, 0) == 1)
286                        {
287                                drawscreen(load, 0, 0);
288                                resettvpic();
289                                char* log = NULL;
290                                if(tpkremove(mbox->param, 0, 0) == 0)
291                                {
292                                        log = gettpklog(NULL, 2);
293                                        textbox(_("Tpk Remove Info - Remove OK"), _(log), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 600, 0, 2);
294                                        //del plugin from memory if Titanname is defined in plugin control file
295                                        if(mbox->param1 != NULL && mbox->param1[0] != '*') delplugin(mbox->param1);
296                                }
297                                else
298                                {
299                                        log = gettpklog(NULL, 3);
300                                        textbox(_("Tpk Remove Info - Remove ERROR"), _(log), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 600, 0, 2);
301                                }
302//                              textbox(_("Message"), _("Some plugins needs restart.\nIf the plugin is not active\nreboot the box."), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);
303                                free(log); log = NULL;
304                                unlink(TPKLOG);
305                                if(file_exist("/tmp/.tpk_needs_reboot"))
306                                {
307                                        textbox(_("Message"), _("TPK Remove done, your system will reboot !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 200, 0, 0);
308                                        //write only config file
309                                        writeallconfig(3);
310                                        oshutdown(2,2);
311                                        system("init 6");
312                                }
313                        }
314                }
315                free(tmpstr); tmpstr = NULL;
316                freemenulist(mlist, 0); mlist = NULL;
317                if(mbox != NULL) tmpstr = ostrcat(mbox->name, NULL, 0, 0);
318                free(tmpinfo); tmpinfo = NULL;
319                freetpk();
320                if(mbox != NULL) screenextensions(1, path, tmpstr, 0);
321                free(tmpstr); tmpstr = NULL;
322        }
323        else if(mode == 2)
324        {
325                char* text1 = "Tpk Tmp Install - select file";
326                char* text2 = "Tpk Tmp Info";
327
328                if(path == NULL)
329                        tmpstr = gettpktmplist("/tmp");
330                else
331                {
332                        tmpstr = gettpktmplist(path);
333                        text1 = "Tpk Media Install - select file";
334                        text2 = "Tpk Media Info";
335                }
336   
337                if(tmpstr == NULL || strlen(tmpstr) == 0)
338                {
339                        textbox(_("Message"), _("No plugin found."), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
340                }
341                else
342                {
343                        addmenulistall(&mlist, tmpstr, NULL, 0, defentry);
344                        mbox = menulistbox(mlist, NULL, text1, NULL, NULL, "/skin/plugin.png", 1, 0);
345                }
346               
347                free(tmpstr); tmpstr = NULL;
348               
349                if(mbox != NULL)
350                {
351                        installpath = getinstallpath(NULL, 0);
352                        debug(130, "installpath: %s", installpath);
353                        if(installpath != NULL)
354                        {
355                                debug(130, "file: %s", mbox->name);
356       
357                                tmpinfo = ostrcat(tmpinfo, _("Installing"), 1, 0);
358                                tmpinfo = ostrcat(tmpinfo, " ", 1, 0);
359                                tmpinfo = ostrcat(tmpinfo, mbox->name, 1, 0);
360                                tmpinfo = ostrcat(tmpinfo, " ", 1, 0);
361                                tmpinfo = ostrcat(tmpinfo, _("starting"), 1, 0);
362                                tmpinfo = ostrcat(tmpinfo, " ?", 1, 0);
363                                debug(130, "tmpinfo: %s", tmpinfo);
364       
365                                if(textbox(_(text2), _(tmpinfo), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0) == 2)
366                                {
367                                        char* log = NULL;
368                                        int ret = 0;                           
369                                        drawscreen(load, 0, 0);
370                                        resettvpic();                           
371                                        if(path == NULL)
372                                        {
373                                                tmpstr = ostrcat(tmpstr, "/tmp", 1, 0);
374                                                tmpstr = ostrcat(tmpstr, "/", 1, 0);
375                                                tmpstr = ostrcat(tmpstr, mbox->name, 1, 0);
376                                                debug(130, "tmpstr: %s", tmpstr);
377                                                ret = tpkinstall(tmpstr, installpath, 0);
378                                                free(tmpstr); tmpstr = NULL;
379                                        }
380                                        else
381                                        {
382                                                tmpstr = ostrcat(tmpstr, path, 1, 0);
383                                                tmpstr = ostrcat(tmpstr, "/", 1, 0);
384                                                tmpstr = ostrcat(tmpstr, mbox->name, 1, 0);
385                                                debug(130, "tmpstr: %s", tmpstr);
386                                                ret = tpkinstall(tmpstr, installpath, 0);
387                                                free(tmpstr); tmpstr = NULL;
388                                        }
389       
390                                        if(ret == 0)
391                                                log = gettpklog(installpath, 0);
392                                        else if(ret == 2)
393                                                log = ostrcat(_("It may only be a package to be installed. If they want to install another package of this section, they only remove the installed packet. Is not the plugin after reinstalling the software TitanNit in TitanNit Menu Visible then perform an update by Tpk to: "), NULL, 0, 0);
394                                        else
395                                                log = gettpklog(installpath, 1);
396                                        textbox(_(text2), log, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 600, 0, 0);
397                                        free(log); log = NULL;
398                                        unlink(TPKLOG);
399                                        textbox(_("Message"), _("Some plugins needs restart.\nIf the plugin is not active\nreboot the box."), "EXIT", getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, NULL, 0, 1000, 200, 0, 0);
400                                        loadplugin();
401                                        if(file_exist("/tmp/.tpk_needs_reboot"))
402                                        {
403                                                textbox(_("Message"), _("TPK Tmp Install done, your system will reboot !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
404                                                //write only config file
405                                                writeallconfig(3);
406                                                oshutdown(2,2);
407                                                system("init 6");
408                                        }
409                                }
410                        }
411                }
412                free(installpath); installpath = NULL;
413                free(tmpstr); tmpstr = NULL;
414                freemenulist(mlist, 0); mlist = NULL;
415                if(mbox != NULL) tmpstr = ostrcat(mbox->name, NULL, 0, 0);
416                free(tmpinfo); tmpinfo = NULL;
417                if(mbox != NULL) screenextensions(2, path, tmpstr, 0);
418                free(tmpstr); tmpstr = NULL;
419        }
420        else if(mode == 3)
421        {
422                drawscreen(load, 0, 0);
423                resettvpic();
424                if(first == 1)
425                {
426                        if(tpkgetindex(0) != 0)
427                                textbox(_("Tpk Update Info - Update ERROR"), _("Can't get all TPK index !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
428                }
429                writesys("/tmp/.tpk_upgrade_start", "0", 0);
430                if(tpkupdate() != 0)
431                        textbox(_("Tpk Update Info - Update ERROR"), _("Can't update all packages !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
432                loadplugin();
433                clearscreen(load);
434                drawscreen(skin, 0, 0);
435                unlink(TPKLOG);
436
437                if(file_exist("/tmp/.tpk_needs_reboot"))
438                {
439                        textbox(_("Message"), _("TPK Upgrade done, your system will reboot !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
440                        //write only config file
441                        writeallconfig(3);
442                        oshutdown(2,2);
443                        system("init 6");
444                }
445                unlink("/tmp/.tpk_upgrade_start");
446        }
447
448        if(first == 1) tpkcleantmp(0);
449        status.hangtime = getconfigint("hangtime", NULL);
450}
451
452//flag 0: without message
453//flag 1: with message
454void screenextensions_check(int flag)
455{
456        int treffer = 0;
457        struct hdd *node = NULL;
458        char* tmpstr = NULL, *tmpstr1 = NULL;
459
460        if(status.security == 1)
461        {
462                addhddall();
463                node = hdd;
464
465                while(node != NULL)
466                {
467                        if(node->partition != 0)
468                        {
469                                tmpstr = ostrcat("/autofs/", node->device, 0, 0);
470                                tmpstr1 = gettpktmplist(tmpstr);
471
472                                if(tmpstr1 != NULL)
473                                {
474                                        treffer = 1;
475                                        screenextensions(2, tmpstr, NULL, 1);
476                                }
477
478                                free(tmpstr); tmpstr = NULL;
479                                free(tmpstr1); tmpstr1 = NULL;
480                        }
481                        node = node->next;
482                }
483
484                if(flag == 1 && treffer == 0)
485                        textbox(_("Tpk Install Info"), _("No plugin found."), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
486        }
487}
488
489#endif
Note: See TracBrowser for help on using the repository browser.