1 | #ifndef IPKG_H |
---|
2 | #define IPKG_H |
---|
3 | |
---|
4 | #define IPKG_LIB |
---|
5 | #include "../libipkg/libipkg.h" |
---|
6 | #include "../libipkg/args.h" |
---|
7 | #include "../libipkg/ipkg_cmd.h" |
---|
8 | |
---|
9 | struct ipkg |
---|
10 | { |
---|
11 | char* name; |
---|
12 | char* desc; |
---|
13 | char* version; |
---|
14 | char* section; |
---|
15 | char* showname; |
---|
16 | struct ipkg* prev; |
---|
17 | struct ipkg* next; |
---|
18 | }; |
---|
19 | |
---|
20 | struct ipkg *ipkg = NULL; |
---|
21 | |
---|
22 | void debugipkg() |
---|
23 | { |
---|
24 | struct ipkg *node = ipkg; |
---|
25 | |
---|
26 | while(node != NULL) |
---|
27 | { |
---|
28 | if(node->name != NULL) |
---|
29 | printf("pkg name: %s\n", node->name); |
---|
30 | if(node->desc != NULL) |
---|
31 | printf("pkg desc: %s\n", node->desc); |
---|
32 | if(node->version != NULL) |
---|
33 | printf("pkg version: %s\n", node->version); |
---|
34 | if(node->section != NULL) |
---|
35 | printf("pkg section: %s\n", node->section); |
---|
36 | if(node->showname != NULL) |
---|
37 | printf("pkg showname: %s\n", node->showname); |
---|
38 | node = node->next; |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
42 | struct ipkg* addipkg(char *name, char* desc, char* version, char* section, char* showname, struct ipkg* last) |
---|
43 | { |
---|
44 | //debug(1000, "in"); |
---|
45 | struct ipkg *newnode = NULL, *prev = NULL, *node = ipkg; |
---|
46 | |
---|
47 | newnode = (struct ipkg*)malloc(sizeof(struct ipkg)); |
---|
48 | if(newnode == NULL) |
---|
49 | { |
---|
50 | err("no memory"); |
---|
51 | return NULL; |
---|
52 | } |
---|
53 | memset(newnode, 0, sizeof(struct ipkg)); |
---|
54 | |
---|
55 | newnode->name = ostrcat(name, NULL, 0, 0); |
---|
56 | newnode->desc = ostrcat(desc, NULL, 0, 0); |
---|
57 | newnode->version = ostrcat(version, NULL, 0, 0); |
---|
58 | newnode->section = ostrcat(section, NULL, 0, 0); |
---|
59 | newnode->showname = ostrcat(showname, NULL, 0, 0); |
---|
60 | |
---|
61 | if(last == NULL) |
---|
62 | { |
---|
63 | while(node != NULL) |
---|
64 | { |
---|
65 | prev = node; |
---|
66 | node = node->next; |
---|
67 | } |
---|
68 | } |
---|
69 | else |
---|
70 | { |
---|
71 | prev = last; |
---|
72 | node = last->next; |
---|
73 | } |
---|
74 | |
---|
75 | if(prev == NULL) |
---|
76 | ipkg = newnode; |
---|
77 | else |
---|
78 | { |
---|
79 | prev->next = newnode; |
---|
80 | newnode->prev = prev; |
---|
81 | } |
---|
82 | newnode->next = node; |
---|
83 | if(node != NULL) node->prev = newnode; |
---|
84 | |
---|
85 | //debug(1000, "out"); |
---|
86 | return newnode; |
---|
87 | } |
---|
88 | |
---|
89 | void delipkg(struct ipkg* ipkgnode) |
---|
90 | { |
---|
91 | //debug(1000, "in"); |
---|
92 | struct ipkg *node = ipkg, *prev = ipkg; |
---|
93 | |
---|
94 | while(node != NULL) |
---|
95 | { |
---|
96 | if(node == ipkgnode) |
---|
97 | { |
---|
98 | if(node == ipkg) |
---|
99 | { |
---|
100 | ipkg = node->next; |
---|
101 | if(ipkg != NULL) |
---|
102 | ipkg->prev = NULL; |
---|
103 | } |
---|
104 | else |
---|
105 | { |
---|
106 | prev->next = node->next; |
---|
107 | if(node->next != NULL) |
---|
108 | node->next->prev = prev; |
---|
109 | } |
---|
110 | |
---|
111 | free(node->name); |
---|
112 | node->name = NULL; |
---|
113 | |
---|
114 | free(node->desc); |
---|
115 | node->desc = NULL; |
---|
116 | |
---|
117 | free(node->version); |
---|
118 | node->version = NULL; |
---|
119 | |
---|
120 | free(node->section); |
---|
121 | node->section = NULL; |
---|
122 | |
---|
123 | free(node->showname); |
---|
124 | node->showname = NULL; |
---|
125 | |
---|
126 | free(node); |
---|
127 | node = NULL; |
---|
128 | break; |
---|
129 | } |
---|
130 | |
---|
131 | prev = node; |
---|
132 | node = node->next; |
---|
133 | } |
---|
134 | //debug(1000, "out"); |
---|
135 | } |
---|
136 | |
---|
137 | void freeipkg() |
---|
138 | { |
---|
139 | debug(1000, "in"); |
---|
140 | struct ipkg *node = ipkg, *prev = ipkg; |
---|
141 | |
---|
142 | while(node != NULL) |
---|
143 | { |
---|
144 | prev = node; |
---|
145 | node = node->next; |
---|
146 | if(prev != NULL) |
---|
147 | delipkg(prev); |
---|
148 | } |
---|
149 | debug(1000, "out"); |
---|
150 | } |
---|
151 | |
---|
152 | int ipkg_list_cb(char *name, char *desc, char *version, pkg_state_status_t status, void *userdata) |
---|
153 | { |
---|
154 | int count = 0; |
---|
155 | #ifndef SIMULATE |
---|
156 | char* tmpstr = NULL; |
---|
157 | struct splitstr* ret = NULL; |
---|
158 | |
---|
159 | tmpstr = ostrcat(name, NULL, 0, 0); |
---|
160 | ret = strsplit(tmpstr, "-", &count); |
---|
161 | |
---|
162 | if(count >= 4) |
---|
163 | { |
---|
164 | if(desc) |
---|
165 | addipkg(name, desc, version, (&ret[2])->part, (&ret[3])->part, NULL); |
---|
166 | else |
---|
167 | addipkg(name, NULL, version, (&ret[2])->part, (&ret[3])->part, NULL); |
---|
168 | } |
---|
169 | |
---|
170 | free(ret); ret = NULL; |
---|
171 | free(tmpstr); tmpstr = NULL; |
---|
172 | #endif |
---|
173 | |
---|
174 | return 0; |
---|
175 | } |
---|
176 | |
---|
177 | int ipkg_status_cb(char *name, int istatus, char *desc, void *userdata) |
---|
178 | { |
---|
179 | addipkg(name, desc, NULL, NULL, NULL, NULL); |
---|
180 | return 0; |
---|
181 | } |
---|
182 | |
---|
183 | int ipkg_update(void) |
---|
184 | { |
---|
185 | unlink("/var/usr/lib/ipkg/cross"); |
---|
186 | unlink("/var/usr/lib/ipkg/secret"); |
---|
187 | unlink("/var/usr/lib/ipkg/titan"); |
---|
188 | int err = 0; |
---|
189 | #ifndef SIMULATE |
---|
190 | args_t args; |
---|
191 | |
---|
192 | args_init(&args); |
---|
193 | err = ipkg_lists_update(&args); |
---|
194 | args_deinit(&args); |
---|
195 | #endif |
---|
196 | return err; |
---|
197 | } |
---|
198 | |
---|
199 | int ipkg_packages_list_installed(args_t *args, const char *packages, ipkg_list_callback cblist, void *userdata) |
---|
200 | { |
---|
201 | int err = 0; |
---|
202 | #ifndef SIMULATE |
---|
203 | ipkg_cmd_t *cmd; |
---|
204 | ipkg_conf_t ipkg_conf; |
---|
205 | |
---|
206 | err = ipkg_conf_init (&ipkg_conf, args); |
---|
207 | if(err) |
---|
208 | { |
---|
209 | return err; |
---|
210 | } |
---|
211 | |
---|
212 | ipkg_cb_list = cblist; |
---|
213 | /* we need to do this because of static declarations, |
---|
214 | * maybe a good idea to change */ |
---|
215 | cmd = ipkg_cmd_find ("list_installed"); |
---|
216 | if(packages) |
---|
217 | err = ipkg_cmd_exec(cmd, &ipkg_conf, 1, &packages, userdata); |
---|
218 | else |
---|
219 | err = ipkg_cmd_exec(cmd, &ipkg_conf, 0, NULL, userdata); |
---|
220 | ipkg_cb_list = NULL; |
---|
221 | ipkg_conf_deinit(&ipkg_conf); |
---|
222 | #endif |
---|
223 | return(err); |
---|
224 | } |
---|
225 | |
---|
226 | int ipkg_list_installed(void) |
---|
227 | { |
---|
228 | int err = 0; |
---|
229 | #ifndef SIMULATE |
---|
230 | args_t args; |
---|
231 | |
---|
232 | args_init(&args); |
---|
233 | err = ipkg_packages_list_installed(&args, NULL, ipkg_list_cb, NULL); |
---|
234 | args_deinit(&args); |
---|
235 | #endif |
---|
236 | return err; |
---|
237 | } |
---|
238 | |
---|
239 | int ipkg_list(void) |
---|
240 | { |
---|
241 | int err = 0; |
---|
242 | #ifndef SIMULATE |
---|
243 | args_t args; |
---|
244 | |
---|
245 | args_init(&args); |
---|
246 | err = ipkg_packages_list(&args, NULL, ipkg_list_cb, NULL); |
---|
247 | args_deinit(&args); |
---|
248 | #endif |
---|
249 | return err; |
---|
250 | } |
---|
251 | |
---|
252 | int ipkg_status(const char* package) |
---|
253 | { |
---|
254 | int err = 0; |
---|
255 | #ifndef SIMULATE |
---|
256 | args_t args; |
---|
257 | |
---|
258 | args_init(&args); |
---|
259 | err = ipkg_packages_status(&args, package, ipkg_status_cb, NULL); |
---|
260 | args_deinit(&args); |
---|
261 | #endif |
---|
262 | return err; |
---|
263 | } |
---|
264 | |
---|
265 | int ipkg_info(const char* package) |
---|
266 | { |
---|
267 | int err = 0; |
---|
268 | #ifndef SIMULATE |
---|
269 | args_t args; |
---|
270 | |
---|
271 | args_init(&args); |
---|
272 | err = ipkg_packages_info(&args, package, ipkg_status_cb, NULL); |
---|
273 | args_deinit(&args); |
---|
274 | #endif |
---|
275 | return err; |
---|
276 | } |
---|
277 | |
---|
278 | int ipkg_install(const char* package) |
---|
279 | { |
---|
280 | debug(130, "package: %s", package); |
---|
281 | |
---|
282 | int err = 0; |
---|
283 | #ifndef SIMULATE |
---|
284 | args_t args; |
---|
285 | |
---|
286 | args_init(&args); |
---|
287 | debug(130, "package1: %s", package); |
---|
288 | err = ipkg_packages_install(&args, package); |
---|
289 | debug(130, "package2: %s", package); |
---|
290 | args_deinit(&args); |
---|
291 | debug(130, "package3: %s", package); |
---|
292 | #endif |
---|
293 | return err; |
---|
294 | } |
---|
295 | |
---|
296 | int ipkg_remove(const char* package, int purge) |
---|
297 | { |
---|
298 | int err = 0; |
---|
299 | #ifndef SIMULATE |
---|
300 | args_t args; |
---|
301 | |
---|
302 | args_init(&args); |
---|
303 | err = ipkg_packages_remove(&args, package, purge); |
---|
304 | args_deinit(&args); |
---|
305 | #endif |
---|
306 | return err; |
---|
307 | } |
---|
308 | |
---|
309 | int ipkg_upgrade(void) |
---|
310 | { |
---|
311 | int err = 0; |
---|
312 | #ifndef SIMULATE |
---|
313 | args_t args; |
---|
314 | |
---|
315 | args_init(&args); |
---|
316 | err = ipkg_packages_upgrade(&args); |
---|
317 | args_deinit(&args); |
---|
318 | #endif |
---|
319 | return err; |
---|
320 | } |
---|
321 | |
---|
322 | int ipkg_download(ipkg_conf_t *conf, const char *src, const char *filename) |
---|
323 | { |
---|
324 | int err = 0, count = 0, i = 0, withoutgui = 0; |
---|
325 | char* ip = NULL, *pos = NULL, *path = NULL, *tmpstr = NULL; |
---|
326 | struct splitstr* ret = NULL; |
---|
327 | |
---|
328 | if(src == NULL) return 1; |
---|
329 | |
---|
330 | debug(130, "src: %s", src); |
---|
331 | ip = string_replace("http://", "", (char*)src, 0); |
---|
332 | |
---|
333 | if(ip != NULL) |
---|
334 | pos = strchr(ip, '/'); |
---|
335 | if(pos != NULL) |
---|
336 | { |
---|
337 | pos[0] = '\0'; |
---|
338 | path = pos + 1; |
---|
339 | } |
---|
340 | |
---|
341 | tmpstr = ostrcat("", path, 0, 0); |
---|
342 | ret = strsplit(tmpstr, "/", &count); |
---|
343 | |
---|
344 | for(i = 0; i < count; i++) |
---|
345 | { |
---|
346 | if(ostrcmp("Packages.gz", (&ret[i])->part) == 0) |
---|
347 | withoutgui = 1; |
---|
348 | } |
---|
349 | free(ret); ret = NULL; |
---|
350 | free(tmpstr); tmpstr = NULL; |
---|
351 | |
---|
352 | debug(130, "src: %s", src); |
---|
353 | debug(130, "ip: %s", ip); |
---|
354 | debug(130, "path: %s", path); |
---|
355 | |
---|
356 | if(withoutgui == 1) |
---|
357 | { |
---|
358 | if(ostrcmp("97.74.32.10", ip) == 0) |
---|
359 | { |
---|
360 | if(ostrcmp((char*)src, "//97.74.32.10/svn/ipk/sh4/titan") != 0) |
---|
361 | { |
---|
362 | textbox(_("Message"), _("check your Secret Feed !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0); |
---|
363 | free(ip); ip = NULL; |
---|
364 | //free(path); //path = NULL; |
---|
365 | return 1; |
---|
366 | } |
---|
367 | } |
---|
368 | |
---|
369 | char* checkfile = NULL; |
---|
370 | checkfile = ostrcat("/tmp/Packages.", ip, 0, 0); |
---|
371 | |
---|
372 | if(!file_exist(checkfile)) // +status.ipkg = date + 1day |
---|
373 | { |
---|
374 | char* tmppath = NULL; |
---|
375 | tmppath = ostrcat(tmppath, path, 1, 0); |
---|
376 | tmppath = string_replace("Packages.gz", "Packages.preview.tar.gz", tmppath, 1); |
---|
377 | gethttp(ip, tmppath, 80, "/tmp/Packages.preview.tar.gz", "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0=", NULL, 0); |
---|
378 | free(tmppath); tmppath = NULL; |
---|
379 | |
---|
380 | system("tar -zxvf /tmp/Packages.preview.tar.gz -C /tmp"); |
---|
381 | unlink("/tmp/Packages.preview.tar.gz"); |
---|
382 | writesys(checkfile, ".", 1); |
---|
383 | } |
---|
384 | free(checkfile); checkfile = NULL; |
---|
385 | gethttp(ip, path, 80, (char*)filename, "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0=", NULL, 0); |
---|
386 | } |
---|
387 | else |
---|
388 | err = screendownload("Download", ip, path, 80, (char*)filename, "aXBrLUdaRmg6RkhaVkJHaG56ZnZFaEZERlRHenVpZjU2NzZ6aGpHVFVHQk5Iam0=", 0); |
---|
389 | free(ip); ip = NULL; |
---|
390 | //free(path);// path = NULL; segfault |
---|
391 | return err; |
---|
392 | } |
---|
393 | |
---|
394 | int ipkg_files(const char* package) |
---|
395 | { |
---|
396 | int err = 0; |
---|
397 | #ifndef SIMULATE |
---|
398 | args_t args; |
---|
399 | |
---|
400 | args_init(&args); |
---|
401 | err = ipkg_package_files(&args, package, ipkg_list_cb, NULL); |
---|
402 | args_deinit(&args); |
---|
403 | #endif |
---|
404 | return err; |
---|
405 | } |
---|
406 | |
---|
407 | int ipkg_search(const char* package) |
---|
408 | { |
---|
409 | int err = 0; |
---|
410 | #ifndef SIMULATE |
---|
411 | args_t args; |
---|
412 | |
---|
413 | args_init(&args); |
---|
414 | err = ipkg_file_search(&args, package, ipkg_list_cb, NULL); |
---|
415 | args_deinit(&args); |
---|
416 | #endif |
---|
417 | return err; |
---|
418 | } |
---|
419 | |
---|
420 | char* get_ipk_section() |
---|
421 | { |
---|
422 | struct ipkg *node = ipkg; |
---|
423 | char* sectionlist = NULL; |
---|
424 | char* namelist = NULL; |
---|
425 | char* tmpstr = NULL; |
---|
426 | while(node != NULL) |
---|
427 | { |
---|
428 | if(node->name != NULL && node->section != NULL) |
---|
429 | { |
---|
430 | tmpstr = ostrcat("-", node->section, 0, 0); |
---|
431 | tmpstr = ostrcat(tmpstr, "-", 1, 0); |
---|
432 | if(!string_find(tmpstr,namelist)) |
---|
433 | { |
---|
434 | namelist = ostrcat(namelist, node->name, 1, 0); |
---|
435 | namelist = ostrcat(namelist, " ", 1, 0); |
---|
436 | sectionlist = ostrcat(sectionlist, node->section, 1, 0); |
---|
437 | sectionlist = ostrcat(sectionlist, "\n", 1, 0); |
---|
438 | } |
---|
439 | free(tmpstr), tmpstr = NULL; |
---|
440 | } |
---|
441 | node = node->next; |
---|
442 | } |
---|
443 | free(namelist), namelist = NULL; |
---|
444 | return sectionlist; |
---|
445 | } |
---|
446 | |
---|
447 | char* ipk_listbox(char* defaultstr, char* str, char* skinname, char* skintitle, char* skinpath, int showpng) |
---|
448 | { |
---|
449 | debug(1000, "in"); |
---|
450 | char* skinname1 = NULL; |
---|
451 | char* skinpath1 = NULL; |
---|
452 | char* tmpskinpath = NULL; |
---|
453 | int rcret = 0; |
---|
454 | |
---|
455 | if(str == NULL) |
---|
456 | return 0; |
---|
457 | |
---|
458 | if(skinname == NULL) |
---|
459 | { |
---|
460 | debug(130, "skinname default=menulist"); |
---|
461 | skinname1 = ostrcat(skinname, "menulist", 1, 0); |
---|
462 | } |
---|
463 | else |
---|
464 | { |
---|
465 | debug(130, "skinname changed=%s", skinname); |
---|
466 | skinname1 = ostrcat(skinname, "", 0, 0); |
---|
467 | } |
---|
468 | |
---|
469 | if(skinpath == NULL) |
---|
470 | { |
---|
471 | debug(130, "skinpath default=skin/"); |
---|
472 | skinpath1 = ostrcat(skinpath, "skin/", 1, 0); |
---|
473 | } |
---|
474 | else |
---|
475 | { |
---|
476 | debug(130, "skinpath changed=%s", skinpath); |
---|
477 | skinpath1 = ostrcat(skinpath, "", 0, 0); |
---|
478 | } |
---|
479 | |
---|
480 | struct skin* screen = getscreen(skinname1); |
---|
481 | struct skin* listbox = getscreennode(screen, "listbox"); |
---|
482 | |
---|
483 | listbox->aktpage = -1; |
---|
484 | listbox->aktline = 1; |
---|
485 | |
---|
486 | if(skintitle != NULL) |
---|
487 | { |
---|
488 | debug(130, "skintitle changed=%s", skintitle); |
---|
489 | changetitle(screen, _(skintitle)); |
---|
490 | } |
---|
491 | |
---|
492 | struct skin* tmp = NULL; |
---|
493 | char* tmpstr = NULL; |
---|
494 | char* defaultdir = NULL; |
---|
495 | char* tmpinfo = NULL; |
---|
496 | char* tmptitle = NULL; |
---|
497 | char* showname = NULL; |
---|
498 | // char* tmpstr1 = NULL; |
---|
499 | // char* tmpck = NULL; |
---|
500 | char* tmpsplit = NULL; |
---|
501 | char* tmpck = NULL; |
---|
502 | char* tmpstr1 = NULL; |
---|
503 | char* tmpstr4 = NULL; |
---|
504 | char* tmpstr5 = NULL; |
---|
505 | if(showpng == 1) |
---|
506 | { |
---|
507 | struct splitstr* ret1 = NULL; |
---|
508 | struct splitstr* ret2 = NULL; |
---|
509 | struct splitstr* ret3 = NULL; |
---|
510 | int count = 0; |
---|
511 | int i = 0; |
---|
512 | ret1 = strsplit(str, "\n", &count); |
---|
513 | |
---|
514 | for( i = 0; i < count; i++) |
---|
515 | { |
---|
516 | int count2 = 0; |
---|
517 | tmpsplit = ostrcat(tmpsplit, (&ret1[i])->part, 1, 0); |
---|
518 | free(ret2); ret2 = NULL; |
---|
519 | ret2 = strsplit(tmpsplit, "-", &count2); |
---|
520 | |
---|
521 | tmp = addlistbox(screen, listbox, tmp, 1); |
---|
522 | |
---|
523 | if(tmp != NULL) |
---|
524 | { |
---|
525 | changetext(tmp, _((&ret1[i])->part)); |
---|
526 | changename(tmp, (&ret1[i])->part); |
---|
527 | |
---|
528 | tmp->del = 1; |
---|
529 | tmp->textposx = 120; |
---|
530 | tmp->height = 50; |
---|
531 | // tmp->fontsize = 30; |
---|
532 | tmp->valign = convertxmlentry("middle", 0); |
---|
533 | tmp->hspace = 5; |
---|
534 | debug(130, "showpng changed=%d", showpng); |
---|
535 | |
---|
536 | if(string_find("%pluginpath%",skinpath1)) |
---|
537 | { |
---|
538 | struct splitstr* ret6 = NULL; |
---|
539 | int count6 = 0; |
---|
540 | char* tmpstr6 = NULL; |
---|
541 | tmpstr6 = ostrcat("", skinpath1, 0, 0); |
---|
542 | ret6 = strsplit(tmpstr6, "%", &count6); |
---|
543 | defaultdir = ostrcat(getconfig("skinpath", NULL), "/skin/panel_", 0, 0); |
---|
544 | defaultdir = ostrcat(defaultdir, (&ret1[i])->part, 1, 0); |
---|
545 | defaultdir = ostrcat(defaultdir, ".png", 1, 0); |
---|
546 | |
---|
547 | if(!file_exist(defaultdir)) |
---|
548 | { |
---|
549 | defaultdir = ostrcat(getconfig("pluginpath", NULL), (&ret6[1])->part, 0, 0); |
---|
550 | defaultdir = ostrcat(defaultdir, "panel_", 0, 0); |
---|
551 | defaultdir = ostrcat(defaultdir, (&ret1[i])->part, 1, 0); |
---|
552 | defaultdir = ostrcat(defaultdir, ".png", 1, 0); |
---|
553 | } |
---|
554 | free(ret6), ret6 = NULL; |
---|
555 | } |
---|
556 | else |
---|
557 | { |
---|
558 | defaultdir = ostrcat(getconfig("skinpath", NULL), skinpath1, 0, 0); |
---|
559 | defaultdir = ostrcat(defaultdir, "/skin/panel_", 0, 0); |
---|
560 | defaultdir = ostrcat(defaultdir, (&ret1[i])->part, 1, 0); |
---|
561 | defaultdir = ostrcat(defaultdir, ".png", 1, 0); |
---|
562 | } |
---|
563 | |
---|
564 | debug(130, "defaultdir %s", defaultdir); |
---|
565 | if(file_exist(defaultdir)) |
---|
566 | { |
---|
567 | tmpskinpath = ostrcat("", defaultdir, 0, 0); |
---|
568 | changepic(tmp, tmpskinpath); |
---|
569 | free(tmpskinpath); tmpskinpath = NULL; |
---|
570 | } |
---|
571 | else |
---|
572 | { |
---|
573 | tmpskinpath = ostrcat(skinpath1, "panel_default.png", 0, 0); |
---|
574 | changepic(tmp, tmpskinpath); |
---|
575 | free(tmpskinpath); tmpskinpath = NULL; |
---|
576 | } |
---|
577 | free(defaultdir); defaultdir = NULL; |
---|
578 | |
---|
579 | if(defaultstr != NULL) |
---|
580 | setlistboxselection(listbox, defaultstr); |
---|
581 | } |
---|
582 | free(ret2),ret2 = NULL; |
---|
583 | } |
---|
584 | free(ret1),ret1 = NULL; |
---|
585 | } |
---|
586 | else if(showpng == 2) |
---|
587 | { |
---|
588 | int i = 0; |
---|
589 | tmpck = get_ipk_listinstall(); |
---|
590 | |
---|
591 | debug(130, "tmpck: %s", tmpck); |
---|
592 | debug(130, "tmpck list_installed ret: %d", ipkg_list_installed()); |
---|
593 | |
---|
594 | struct ipkg *node = ipkg; |
---|
595 | while(node != NULL) |
---|
596 | { |
---|
597 | debug(130, "name: %s", node->name); |
---|
598 | debug(130, "section: %s", node->section); |
---|
599 | debug(130, "showname: %s", node->showname); |
---|
600 | debug(130, "str: %s", str); |
---|
601 | |
---|
602 | if(node->section != NULL && ostrcmp(str, node->section) == 0) |
---|
603 | { |
---|
604 | struct splitstr* ret1 = NULL; |
---|
605 | int count1 = 0; |
---|
606 | tmpstr1 = ostrcat("", node->showname, 0, 0); |
---|
607 | ret1 = strsplit(tmpstr1, ".", &count1); |
---|
608 | int max = count1; |
---|
609 | i += 1; |
---|
610 | showname = ostrcat("", (&ret1[0])->part, 0, 0); |
---|
611 | free(ret1),ret1 = NULL; |
---|
612 | // showname = ostrcat(node->showname, NULL, 0, 0); |
---|
613 | |
---|
614 | struct splitstr* ret3 = NULL; |
---|
615 | int count3 = 0; |
---|
616 | int a = 0; |
---|
617 | tmpstr1 = ostrcat("", tmpck, 0, 0); |
---|
618 | |
---|
619 | debug(130, "tmpck: (%d) %s", i, tmpstr1); |
---|
620 | |
---|
621 | ret3 = strsplit(tmpstr1, "\n", &count3); |
---|
622 | int skip = 0; |
---|
623 | |
---|
624 | debug(130, "check list_installed"); |
---|
625 | for(a = 0; a < count3; a++) |
---|
626 | { |
---|
627 | debug(130, "node->name=%s", node->name); |
---|
628 | debug(130, "(&ret3[a])->part=%s", (&ret3[a])->part); |
---|
629 | |
---|
630 | char* installed = NULL; |
---|
631 | installed = ostrcat(installed, node->section, 1, 0); |
---|
632 | installed = ostrcat(installed, "-", 1, 0); |
---|
633 | installed = ostrcat(installed, node->showname, 1, 0); |
---|
634 | |
---|
635 | if(ostrcmp((&ret3[a])->part, installed) == 0) |
---|
636 | { |
---|
637 | debug(130, "set skiped=1"); |
---|
638 | skip = 1; |
---|
639 | break; |
---|
640 | } |
---|
641 | free(installed),installed = NULL; |
---|
642 | } |
---|
643 | free(ret3),ret3 = NULL; |
---|
644 | debug(130, "check list_installed done"); |
---|
645 | if(skip == 0) |
---|
646 | { |
---|
647 | tmp = addlistbox(screen, listbox, tmp, 1); |
---|
648 | tmp->del = 1; |
---|
649 | tmp->valign = convertxmlentry("middle", 0); |
---|
650 | tmp->textposx = 250; |
---|
651 | tmp->height = 170; |
---|
652 | tmp->textposx2 = 270; |
---|
653 | tmp->type=TEXTBOX; |
---|
654 | tmp->wrap=YES; |
---|
655 | tmp->hspace = 5; |
---|
656 | debug(130, "showpng changed=%d", showpng); |
---|
657 | |
---|
658 | defaultdir = ostrcat("", skinpath1, 0, 0); |
---|
659 | defaultdir = ostrcat(defaultdir, "titan-pluginpreview-", 1, 0); |
---|
660 | defaultdir = ostrcat(defaultdir, showname, 1, 0); |
---|
661 | defaultdir = ostrcat(defaultdir, ".png", 1, 0); |
---|
662 | |
---|
663 | debug(130, "defaultdir %s", defaultdir); |
---|
664 | |
---|
665 | if(file_exist(defaultdir)) |
---|
666 | { |
---|
667 | debug(130, "defaultdir found"); |
---|
668 | tmpskinpath = ostrcat(skinpath1, "titan-pluginpreview-", 0, 0); |
---|
669 | tmpskinpath = ostrcat(tmpskinpath, showname, 1, 0); |
---|
670 | tmpskinpath = ostrcat(tmpskinpath, ".png", 1, 0); |
---|
671 | changepic(tmp, tmpskinpath); |
---|
672 | free(tmpskinpath); tmpskinpath = NULL; |
---|
673 | } |
---|
674 | else |
---|
675 | { |
---|
676 | debug(130, "defaultdir not found use default.png"); |
---|
677 | tmpskinpath = ostrcat("", "skin/plugin.png", 0, 0); |
---|
678 | changepic(tmp, tmpskinpath); |
---|
679 | free(tmpskinpath); tmpskinpath = NULL; |
---|
680 | } |
---|
681 | free(defaultdir); defaultdir = NULL; |
---|
682 | |
---|
683 | if(defaultstr != NULL) |
---|
684 | { |
---|
685 | setlistboxselection(listbox, defaultstr); |
---|
686 | // if(ostrcmp(defaultstr, (&ret1[i])->part) == 0) |
---|
687 | // listbox->aktline = i + 1; |
---|
688 | } |
---|
689 | tmptitle = ostrcat(tmptitle, node->showname, 1, 0); |
---|
690 | tmptitle = ostrcat(tmptitle, " v.", 1, 0); |
---|
691 | tmptitle = ostrcat(tmptitle, node->version, 1, 0); |
---|
692 | changetext(tmp, _(tmptitle)); |
---|
693 | changename(tmp, tmptitle); |
---|
694 | |
---|
695 | tmpinfo = ostrcat(tmpinfo, "\nSection: ", 1, 0); |
---|
696 | tmpinfo = ostrcat(tmpinfo, node->section, 1, 0); |
---|
697 | tmpinfo = ostrcat(tmpinfo, "\nDescription:\n", 1, 0); |
---|
698 | if(node->desc != NULL) |
---|
699 | tmpinfo = ostrcat(tmpinfo, node->desc, 1, 0); |
---|
700 | else |
---|
701 | tmpinfo = ostrcat(tmpinfo, _("no description found"), 1, 0); |
---|
702 | changetext2(tmp, _(tmpinfo)); |
---|
703 | |
---|
704 | free(tmpinfo); tmpinfo = NULL; |
---|
705 | free(tmptitle); tmptitle = NULL; |
---|
706 | free(tmpstr1);tmpstr1 = NULL; |
---|
707 | free(showname);showname = NULL; |
---|
708 | } |
---|
709 | free(ret1),ret1 = NULL; |
---|
710 | } |
---|
711 | node = node->next; |
---|
712 | } |
---|
713 | } |
---|
714 | listbox->aktpage = -1; |
---|
715 | drawscreen(screen,0); |
---|
716 | addscreenrc(screen, listbox); |
---|
717 | |
---|
718 | while (1) |
---|
719 | { |
---|
720 | rcret = waitrc(screen, 0, 0); |
---|
721 | |
---|
722 | if(rcret==getrcconfigint("rcexit",NULL)) break; |
---|
723 | if(listbox->select != NULL && rcret==getrcconfigint("rcok",NULL)) |
---|
724 | { |
---|
725 | tmpstr = ostrcat(tmpstr, listbox->select->name, 1, 0); |
---|
726 | break; |
---|
727 | } |
---|
728 | } |
---|
729 | free(skinname1); skinname1 = NULL; |
---|
730 | free(skinpath1); skinpath1 = NULL; |
---|
731 | delownerrc(screen); |
---|
732 | delmarkedscreennodes(screen, 1); |
---|
733 | clearscreen(screen); |
---|
734 | debug(1000, "out"); |
---|
735 | return tmpstr; |
---|
736 | |
---|
737 | } |
---|
738 | |
---|
739 | char* get_ipk_tmpinstall(char* ipk) |
---|
740 | { |
---|
741 | debug(130, "in"); |
---|
742 | |
---|
743 | unlink("/var/usr/lib/ipkg/cross"); |
---|
744 | unlink("/var/usr/lib/ipkg/secret"); |
---|
745 | unlink("/var/usr/lib/ipkg/titan"); |
---|
746 | |
---|
747 | char* cmd = NULL, *tmpstr = NULL; |
---|
748 | cmd = ostrcat(cmd, "ipkg install /tmp/", 1, 0); |
---|
749 | cmd = ostrcat(cmd, ipk, 1, 0); |
---|
750 | |
---|
751 | tmpstr = command(cmd); |
---|
752 | |
---|
753 | debug(130, "out %s",cmd); |
---|
754 | free(cmd); cmd = NULL; |
---|
755 | return tmpstr; |
---|
756 | } |
---|
757 | |
---|
758 | char* get_ipk_listinstall() |
---|
759 | { |
---|
760 | debug(130, "in"); |
---|
761 | char* cmd = NULL, *tmpstr = NULL; |
---|
762 | |
---|
763 | cmd = ostrcat(cmd, "ipkg list_installed | awk '{ print $1 }' | sed 's/Successfully//' | sed 's/titan-plugin-//'", 1, 0); |
---|
764 | |
---|
765 | tmpstr = command(cmd); |
---|
766 | |
---|
767 | debug(130, "out %s",cmd); |
---|
768 | free(cmd); cmd = NULL; |
---|
769 | return tmpstr; |
---|
770 | } |
---|
771 | |
---|
772 | char* get_ipk_tmplistinstall() |
---|
773 | { |
---|
774 | debug(130, "in"); |
---|
775 | char* cmd = NULL, *tmpstr = NULL; |
---|
776 | |
---|
777 | cmd = ostrcat(cmd, "ls /tmp | grep '.ipk'", 1, 0); |
---|
778 | |
---|
779 | tmpstr = command(cmd); |
---|
780 | |
---|
781 | debug(130, "out %s",cmd); |
---|
782 | free(cmd); cmd = NULL; |
---|
783 | return tmpstr; |
---|
784 | } |
---|
785 | |
---|
786 | #endif |
---|
787 | |
---|