source: titan/plugins/xupnpd/xupnpd.h @ 43368

Last change on this file since 43368 was 35952, checked in by Stephan, 8 years ago

[xupnpd] save config and start

File size: 2.8 KB
Line 
1#ifndef XUPNPD_H
2#define XUPNPD_H
3
4void screenxupnpd()
5{
6        int rcret = -1, ret = 0;
7        struct skin* xupnpd = getscreen("xupnpdsettings");
8        struct skin* listbox = getscreennode(xupnpd, "listbox");
9        char* tmpstr = NULL, *xupnpdstop = NULL, *xupnpdstart = NULL;
10        struct skin* tmp = NULL;
11        struct skin* node = NULL;
12
13        tmpstr = createpluginpath("/xupnpd/xupnpd.sh", 0);
14        xupnpdstop = ostrcat(tmpstr, " stop ", 0, 0);
15        xupnpdstart = ostrcat(tmpstr, " start ", 0, 0);
16       
17        tmpstr = string_replace("/usr/local/share/titan/plugins/xupnpd/xupnpd.sh", "/etc/xupnpd", tmpstr, 1);
18        xupnpdstop = ostrcat(xupnpdstop, tmpstr, 1, 0);
19        xupnpdstart = ostrcat(xupnpdstart, tmpstr, 1, 0);
20
21        addscreenrc(xupnpd, listbox);
22        listbox->aktline = 1;
23        listbox->aktpage = 1;
24
25        node = addlistbox(xupnpd, listbox, node, 1);
26        if(node != NULL)
27        {
28                node->type = CHOICEBOX;
29                changetext(node, _("autostart")); changename(node, "xupnpd");
30                addchoicebox(node, "n", _("no")); addchoicebox(node, "y", _("yes"));
31                setchoiceboxselection(node, getownconfig(node->name));
32        }
33
34        drawscreen(xupnpd, 0, 0);
35        tmp = listbox->select;
36
37        while(1)
38        {
39                addscreenrc(xupnpd, tmp);
40                rcret = waitrc(xupnpd, 0, 0);
41                tmp = listbox->select;
42
43                if(listbox->select != NULL)
44                {
45                        addownconfigscreentmp(listbox->select->name, listbox->select);
46                }
47
48                if(rcret == getrcconfigint("rcexit", NULL)) break;
49
50                if(rcret == getrcconfigint("rcok", NULL))
51                {
52                        debug(10, "cmd: %s", xupnpdstop);
53                        system(xupnpdstop);
54                        debug(10, "cmd: %s", xupnpdstart);
55                        ret = system(xupnpdstart);
56                        if(ret == 0)
57                                textbox(_("Message"), _("xupnpd started and config saved"), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 600, 200, 5, 0);
58                        else
59                                textbox(_("Message"), _("xupnpd not started,\nPlease check your config."), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 600, 200, 0, 0);
60                        drawscreen(xupnpd, 0, 0);                       
61                        writeownconfigtmp();
62                        writeallconfig(1);
63                        break;
64                }
65
66                if(rcret == getrcconfigint("rcred", NULL))
67                {
68                        debug(10, "cmd: %s", xupnpdstop);
69                        system(xupnpdstop);
70                        textbox(_("Message"), _("xupnpd now stopped"), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 600, 200, 5, 0);
71                        drawscreen(xupnpd, 0, 0);
72                }
73
74                if(rcret == getrcconfigint("rcgreen", NULL))
75                {
76                        debug(10, "cmd: %s", xupnpdstop);
77                        system(xupnpdstop);
78                        debug(10, "cmd: %s", xupnpdstart);
79                        ret = system(xupnpdstart);
80                        if(ret == 0)
81                                textbox(_("Message"), _("xupnpd started."), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 600, 200, 5, 0);
82                        else
83                                textbox(_("Message"), _("xupnpd not started,\nPlease check your config."), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 600, 200, 0, 0);
84                        drawscreen(xupnpd, 0, 0);
85                }
86        }
87
88        delownconfigtmpall();
89        delmarkedscreennodes(xupnpd, 1);
90        delownerrc(xupnpd);
91        clearscreen(xupnpd);
92}
93
94#endif
Note: See TracBrowser for help on using the repository browser.