source: titan/plugins/panel/panel_ipk.h @ 11419

Last change on this file since 11419 was 11419, checked in by nit, 12 years ago

[titan] del AAF text

File size: 8.7 KB
RevLine 
[11419]1#ifndef PANEL_IPK_H
2#define PANEL_IPK_H
[11346]3
4// showpng = 0 (no icon)
5// showpng = 1 (smal icon)
6// showpng = 2 (big icon) (ipk)
7// showpng = 3 (networkbrowser)
8// showpng = 4 same as 1 the first arg splittet ")( " (networkbrowser/harddisk)
9
10char* ipklistbox(char* defaultstr, char* str, char* skinname, char* skintitle, char* skinpath, int showpng)
11{
12        debug(1000, "in");
13        char* skinname1 = NULL;
14        char* skinpath1 = NULL;
15        char* tmpskinpath = NULL;
16        int rcret = 0;
17
18        if (str == NULL)
19                return 0;
20
21        if (skinname == NULL){
22                debug(60, "skinname default=menulist");
23                skinname1 = ostrcat(skinname, "menulist", 1, 0);
24        } else {
25                debug(60, "skinname changed=%s", skinname);
26                skinname1 = ostrcat(skinname, "", 0, 0);
27        }
28
29        if (skinpath == NULL){
30                debug(60, "skinpath default=skin/");
31                skinpath1 = ostrcat(skinpath, "skin/", 1, 0);
32        } else {
33                debug(60, "skinpath changed=%s", skinpath);
34                skinpath1 = ostrcat(skinpath, "", 0, 0);
35        }
36
37        struct skin* screen = getscreen(skinname1);
38        struct skin* listbox = getscreennode(screen, "listbox");
39       
40        listbox->aktpage = -1;
41        listbox->aktline = 1;
42
43        if(skintitle != NULL){
44                debug(60, "skintitle changed=%s", skintitle);
45                changetitle(screen, _(skintitle));
46        }
47
48        struct skin* tmp = NULL;
49        char* tmpstr = NULL;
50        char* defaultdir = NULL;
51        char* tmpinfo = NULL;
52        char* tmptitle = NULL;
53        char* tmpsplit = NULL;
54        char* tmpck = NULL;
55        char* tmpstr1 = NULL;
56        char* tmpstr4 = NULL;
57        char* tmpstr5 = NULL;
58
59        struct splitstr* ret1 = NULL;
60        struct splitstr* ret2 = NULL;
61        struct splitstr* ret3 = NULL;
62        int count = 0;
63        int i = 0;
64        ret1 = strsplit(str, "\n", &count);
65
66        if(showpng == 2)
67                tmpck = get_ipk_listinstall();
68//              tmpck = ostrcat(tmpck, get_ipk_listinstall(), 1, 0);
69
70        for( i = 0; i < count; i++)
71        {
72                if(showpng == 2)
73                {
74                        int count3 = 0;
75                        int a = 0;
76
77                        tmpstr1 = ostrcat("", tmpck, 0, 0);
78
79                        debug(60, "tmpck: (%d) %s", i, tmpstr1);
80
81                        ret3 = strsplit(tmpstr1, "\n", &count3);
82                        int skip = 0;
83
84                        for(a = 0; a < count3; a++)
85                        {
86                                debug(60, "check1: (%d)-(%d) %s", i, a, (&ret3[a])->part);
87                                debug(60, "check2: (%d)-(%d) %s", i, a, (&ret1[i])->part);
88                                if(string_find((&ret3[a])->part,(&ret1[i])->part)){
89                                        debug(60, "set skiped=1");
90                                        skip = 1;
91                                        continue;
92                                }
93                        }
94                        if(skip == 1)
95                        {
96                                skip = 0;
97                                debug(60, "skipped listing: %s",(&ret1[i])->part);
98                                continue;
99                        }
100                }
101
102                int count2 = 0;
103                tmpsplit = ostrcat(tmpsplit, (&ret1[i])->part, 1, 0);
104                free(ret2); ret2 = NULL;
105                ret2 = strsplit(tmpsplit, "-", &count2);
106
107                tmp = addlistbox(screen, listbox, tmp, 1);
108               
109                if(tmp != NULL)
110                {
111                        changetext(tmp, _((&ret1[i])->part));
112                        changename(tmp, (&ret1[i])->part);
113                        if(showpng == 2)
114                        {
115                                // ipk list
116                                // section 2
117                                // name 3
118                                // version 4
119                                // description 5
120                                int j = 0;
121                                for(j = 0; j < count2; j++)
122                                {
123                                        if(j > 0)
124                                        {
125                                                tmptitle = NULL;
126                                                tmptitle = ostrcat(tmptitle, (&ret2[3])->part, 1, 0);
127                                                tmptitle = ostrcat(tmptitle, " v.", 1, 0);
128                                                tmptitle = ostrcat(tmptitle, strstrip((&ret2[4])->part), 1, 0);
129                                                changetext(tmp, _(tmptitle));
130                                                changename(tmp, tmptitle);
131
132                                                tmpinfo = NULL;
133                                                tmpinfo = ostrcat(tmpinfo, "\nSection: ", 1, 0);
134                                                tmpinfo = ostrcat(tmpinfo, (&ret2[2])->part, 1, 0);
135                                                tmpinfo = ostrcat(tmpinfo, "\nDescription:\n", 1, 0);
136                                                tmpinfo = ostrcat(tmpinfo, strstrip((&ret2[5])->part), 1, 0);
137                                                changetext2(tmp, _(tmpinfo));
138
139                                                (&ret1[i])->part = string_remove_whitechars((&ret2[3])->part);
140
141                                                free(tmpinfo); tmpinfo = NULL;
142                                                free(tmptitle); tmptitle = NULL;
143                                        }
144                                }
145                        }
146
147                        tmp->del = 1;
148                        if((showpng == 1) || (showpng == 3) || (showpng == 4))
149                        {
150                                tmp->textposx = 120;
151                                tmp->height = 50;
152//                              tmp->fontsize = 30;
153                                tmp->valign = convertxmlentry("middle", 0);
154                                tmp->hspace = 5;
155                                debug(60, "showpng changed=%d", showpng);
156                        }
157                        else if(showpng == 2)
158                        {
159                                tmp->valign = convertxmlentry("middle", 0);
160                                tmp->textposx = 250;
161//                              tmp->height = 160;
162                                tmp->height = 170;
163//                              tmp->fontsize = 30;
164//                              tmp->fontcol2 = convertcol("ff0000");
165                                tmp->textposx2 = 270;
166//                              tmp->fontsize2 = 22;
167                                tmp->type=TEXTBOX;
168                                tmp->wrap=YES;
169                                tmp->hspace = 5;
170                                debug(60, "showpng changed=%d", showpng);
171                        }
172                        else
173                        {
174                                debug(60, "showpng default=%d", showpng);
175                        }
176
177                        if(ostrcmp((&ret1[i])->part, "\t") == 0)
178                                tmp->deaktivcol = convertcol("deaktivcol");
179                        else
180                        {
181                                if(showpng == 1)
182                                {
183                                        if(string_find("%pluginpath%",skinpath1)){
184                                                struct splitstr* ret6 = NULL;
185                                                int count6 = 0;
186                                                char* tmpstr6 = NULL;
187                                                tmpstr6 = ostrcat("", skinpath1, 0, 0);
188                                                ret6 = strsplit(tmpstr6, "%", &count6);
[11419]189                                                defaultdir = ostrcat(getconfig("skinpath", NULL), "/skin/panel_", 0, 0);
[11346]190                                                defaultdir = ostrcat(defaultdir, (&ret1[i])->part, 1, 0);
191                                                defaultdir = ostrcat(defaultdir, ".png", 1, 0);
192
193                                                if(!file_exist(defaultdir))
194                                                {
195                                                        defaultdir = ostrcat(getconfig("pluginpath", NULL), (&ret6[1])->part, 0, 0);
[11419]196                                                        defaultdir = ostrcat(defaultdir, "panel_", 0, 0);
[11346]197                                                        defaultdir = ostrcat(defaultdir, (&ret1[i])->part, 1, 0);
198                                                        defaultdir = ostrcat(defaultdir, ".png", 1, 0);
199                                                }
200                                                free(ret6), ret6 = NULL;
201                                        } else {
202                                                defaultdir = ostrcat(getconfig("skinpath", NULL), skinpath1, 0, 0);
[11419]203                                                defaultdir = ostrcat(defaultdir, "/skin/panel_", 0, 0);
[11346]204                                                defaultdir = ostrcat(defaultdir, (&ret1[i])->part, 1, 0);
205                                                defaultdir = ostrcat(defaultdir, ".png", 1, 0);
206                                        }
207
208                                        debug(60, "defaultdir %s", defaultdir);
209                                        if(file_exist(defaultdir))
210                                        {
211                                                tmpskinpath = ostrcat("", defaultdir, 0, 0);
212                                                changepic(tmp, tmpskinpath);
213                                                free(tmpskinpath); tmpskinpath = NULL;
214                                        }
215                                        else
216                                        {
[11419]217                                                tmpskinpath = ostrcat(skinpath1, "panel_default.png", 0, 0);
[11346]218                                                changepic(tmp, tmpskinpath);
219                                                free(tmpskinpath); tmpskinpath = NULL;
220                                        }
221                                        free(defaultdir); defaultdir = NULL;
222                                }
223                                else if(showpng == 2)
224                                {               
225                                        struct splitstr* ret4 = NULL;
226                                        int count4 = 0;
227                                        tmpstr4 = ostrcat("", (&ret1[i])->part, 0, 0);
228                                        ret4 = strsplit(tmpstr4, ".", &count4);
229
230                                        defaultdir = ostrcat("", skinpath1, 0, 0);
231                                        defaultdir = ostrcat(defaultdir, "titan-pluginpreview-", 1, 0);
232                                        defaultdir = ostrcat(defaultdir, (&ret4[0])->part, 1, 0);
233                                        defaultdir = ostrcat(defaultdir, ".png", 1, 0);
234               
235                                        debug(60, "defaultdir %s", defaultdir);
236
237                                        if(file_exist(defaultdir))
238                                        {
239                                                debug(60, "defaultdir found");
240                                                tmpskinpath = ostrcat(skinpath1, "titan-pluginpreview-", 0, 0);
241                                                tmpskinpath = ostrcat(tmpskinpath, (&ret4[0])->part, 1, 0);
242                                                tmpskinpath = ostrcat(tmpskinpath, ".png", 1, 0);
243                                                changepic(tmp, tmpskinpath);
244                                                free(tmpskinpath); tmpskinpath = NULL;
245                                        }       
246                                        else
247                                        {
248                                                debug(60, "defaultdir not found use default.png");
249                                                tmpskinpath = ostrcat("", "skin/plugin.png", 0, 0);
250                                                changepic(tmp, tmpskinpath);
251                                                free(tmpskinpath); tmpskinpath = NULL;
252                                        }
253                                        free(defaultdir); defaultdir = NULL;
254                                        free(ret4), ret4 = NULL;
255                                }
256                                else if(showpng == 3)
257                                {
258                                        tmpskinpath = ostrcat(skinpath1, "scanshares.png", 0, 0);
259                                        changepic(tmp, tmpskinpath);
260                                        free(tmpskinpath); tmpskinpath = NULL;
261                                }
262                                else if(showpng == 4)
263                                {
264                                        struct splitstr* ret5 = NULL;
265                                        int count5 = 0;
266                                        tmpstr5 = ostrcat("", (&ret1[i])->part, 0, 0);
267                                        ret5 = strsplit(tmpstr5, ")( ", &count5);
268                                        debug(60, "(&ret5[0])->part %s", (&ret5[0])->part);
269
270                                        if(ostrcmp((&ret5[0])->part, "add") == 0){
271                                                defaultdir = ostrcat("", (&ret1[i])->part, 0, 0);
272                                                defaultdir = ostrcat(defaultdir, ".png", 1, 0);
273                                        } else {
274                                                defaultdir = ostrcat("", (&ret5[0])->part, 0, 0);
275                                                defaultdir = ostrcat(defaultdir, ".png", 1, 0);
276                                        }
277
278                                        tmpskinpath = ostrcat(skinpath1, defaultdir, 0, 0);
279                                        changepic(tmp, tmpskinpath);
280                                        free(tmpskinpath); tmpskinpath = NULL;
281                                        free(defaultdir); defaultdir = NULL;
282                                        free(ret5), ret5 = NULL;
283                                }
284                        }
285                        if(defaultstr != NULL)
286                        {
287                                setlistboxselection(listbox, defaultstr);
288                        //      if(ostrcmp(defaultstr, (&ret1[i])->part) == 0)
289                        //              listbox->aktline = i + 1;
290                        }
291                }
292        }
293
294        free(ret1); ret1 = NULL;
295        free(ret2); ret2 = NULL;
296        free(ret3); ret3 = NULL;
297        free(tmpck); tmpck = NULL;
298        free(tmpsplit); tmpsplit = NULL;
299        free(tmpstr1); tmpstr1 = NULL;
300        free(tmpstr4); tmpstr4 = NULL;
301        free(tmpstr5); tmpstr5 = NULL;
302
303        listbox->aktpage = -1;
304
305        drawscreen(screen,0);
306        addscreenrc(screen, listbox);
307
308        while (1)
309        {
310                rcret = waitrc(screen, 0, 0);
311
312                if(rcret==getrcconfigint("rcexit",NULL)) break;
313                if(listbox->select != NULL && rcret==getrcconfigint("rcok",NULL))
314                {
315                        tmpstr = ostrcat(tmpstr, listbox->select->name, 1, 0);
316                        break;
317                }
318        }
319
320        free(skinname1); skinname1 = NULL;
321        free(skinpath1); skinpath1 = NULL;
322        delownerrc(screen);
323        delmarkedscreennodes(screen, 1);
324        clearscreen(screen);
325        debug(1000, "out");
326        return tmpstr;
327}
328
329#endif
Note: See TracBrowser for help on using the repository browser.