source: titan/plugins/mboxinfo/mboxinfo.c @ 41285

Last change on this file since 41285 was 33539, checked in by karlo, 9 years ago

next round createpo

File size: 4.0 KB
Line 
1#include "../titan/struct.h"
2#include "../titan/debug.h"
3#include "../titan/header.h"
4
5char pluginname[] = "Mbox Info";
6char plugindesc[] = "Mbox Info V0.1    25/10/2011 AAF-tiTan";
7char pluginpic[] = "%pluginpath%/mboxinfo/plugin.png";
8
9int pluginaktiv = 0;
10int pluginversion = PLUGINVERSION;
11
12//wird beim laden ausgefuehrt
13void init(void)
14{
15        char* tmpstr = NULL;
16
17        tmpstr = createpluginpath("/mboxinfo/skin.xml", 0);
18        readscreen(tmpstr, 194, 1);
19        free(tmpstr); tmpstr = NULL;
20
21        pluginaktiv = 1;
22        debug(10, "Mbox Info Plugin loadet !!!");
23}
24
25//wird beim entladen ausgefuehrt
26void deinit(void)
27{
28        delmarkedscreen(194);
29        pluginaktiv = 0;
30        debug(10, "Mbox Info Plugin removed !!!");
31}
32
33int show_info(char *titelname, char *filename)
34{
35        FILE* fd = NULL;
36        char *fileline = NULL, *buf = NULL, *buf1 = NULL;
37        int buf1size = 0, buf1oldsize = 0;
38
39        fileline = malloc(MINMALLOC);
40        if(fileline == NULL)
41        {
42                err("no memory");
43                return 0;
44        }
45
46        fd =  fopen(filename, "r");
47        if(fd == NULL)
48        {
49                textbox(_(titelname), _("File not found !!"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), '\0', 0, '\0', 0, 600, 200, 0, 0);
50                free(fileline);
51                return 0;
52        }
53
54        while(fgets(fileline, MINMALLOC, fd) != NULL)
55        {
56                buf = fileline;
57                buf1oldsize = buf1size;
58                buf1size += strlen(buf);
59                buf1 = realloc(buf1, buf1size + 1);
60                if(buf1 == NULL)
61                {
62                        err("no memory");
63                        free(fileline);
64                        fclose(fd);
65                        return 0;
66                }
67
68                sprintf(buf1 + buf1oldsize, "%s", buf);
69        }
70
71        if(buf1 != NULL)
72        {
73                textbox(_(titelname), _(buf1), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), '\0', 0, '\0', 0, 900, 600, 0, 0);
74        }
75        else
76        {
77                textbox(_(titelname), (""), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), '\0', 0, '\0', 0, 600, 200, 0, 0);
78        }
79
80        fclose(fd);
81        free(fileline);
82        free(buf1);
83        return 1;
84}
85
86//wird in der Pluginverwaltung bzw Menue ausfeguehrt
87void start(void)
88{
89        int rcret = 0;
90        struct skin* screen = getscreen("mboxinfo");
91        struct skin* listbox = getscreennode(screen, "listbox");
92        struct skin* tmp = NULL;
93        char* tmpstr = NULL;
94
95        delmarkedscreennodes(screen, 1);
96        listbox->aktpage = -1;
97        listbox->aktline = 1;
98        changetitle(screen, "Mbox Info");
99
100        tmp = addlistbox(screen, listbox, tmp, 1);
101        if(tmp != NULL)
102        {
103                changetext(tmp, "ECM Info");
104                changename(tmp, "ECM Info");
105        }
106        tmp = addlistbox(screen, listbox, tmp, 1);
107        if(tmp != NULL)
108        {
109                changetext(tmp, "Share Online");
110                changename(tmp, "Share Online");
111        }
112        tmp = addlistbox(screen, listbox, tmp, 1);
113        if(tmp != NULL)
114        {
115                changetext(tmp, "Share Info");
116                changename(tmp, "Share Info");
117        }
118        tmp = addlistbox(screen, listbox, tmp, 1);
119        if(tmp != NULL)
120        {
121                changetext(tmp, "Mbox Version");
122                changename(tmp, "Mbox Version");
123        }
124        tmp = addlistbox(screen, listbox, tmp, 1);
125        if(tmp != NULL)
126        {
127                changetext(tmp, "Info");
128                changename(tmp, "Info");
129        }
130
131        drawscreen(screen, 0, 0);
132        addscreenrc(screen, listbox);
133
134        while (1)
135        {
136                rcret = waitrc(screen, 0, 0);
137
138                if(rcret == getrcconfigint("rcexit",NULL)) break;
139                if(listbox->select != NULL && rcret == getrcconfigint("rcok",NULL))
140                {
141                        tmpstr = ostrcat(listbox->select->name, NULL, 0, 0);
142                        debug(10, "[MBOX INFO] active menu = %s\n", tmpstr);
143                        clearscreen(screen);
144
145                        if(ostrcmp("ECM Info", listbox->select->name) == 0)
146                        {
147                                show_info(listbox->select->name, "/tmp/ecm.info");
148                        }
149                        else if(ostrcmp("Share Online", listbox->select->name) == 0)
150                        {
151                                show_info(listbox->select->name, "/tmp/share.onl");
152                        }
153                        else if(ostrcmp("Share Info", listbox->select->name) == 0)
154                        {
155                                show_info(listbox->select->name, "/tmp/share.info");
156                        }
157                        else if(ostrcmp("Mbox Version", listbox->select->name) == 0)
158                        {
159                                show_info(listbox->select->name, "/tmp/mbox.ver");
160                        }
161                        else if(ostrcmp("Info", listbox->select->name) == 0)
162                        {
163                                textbox(_(pluginname), _(plugindesc), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), '\0', 0, '\0', 0, 600, 200, 0, 0);
164                        }
165
166                        free(tmpstr); tmpstr = NULL;
167                        drawscreen(screen, 0, 0);
168                }
169        }
170
171        delownerrc(screen);
172        delmarkedscreennodes(screen, 1);
173        clearscreen(screen);
174}
Note: See TracBrowser for help on using the repository browser.