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